Guest User

Untitled

a guest
Jul 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. public bool Save(T entity)
  2. {
  3. entity = new T();
  4.  
  5. AllItem.Add(entity);
  6.  
  7. return true;
  8. }
  9.  
  10. List<AccountModel> Accounts = new List<AccountModel>();
  11.  
  12. private BaseServices<AccountModel> AccountBS = new BaseServices<AccountModel>();
  13.  
  14. Random rnd = new Random();
  15.  
  16. private int SomeId;
  17.  
  18. private int AccountsLenth;
  19.  
  20. [TestInitialize]
  21. public void Repletion()
  22. {
  23. SomeId = rnd.Next(100);
  24.  
  25. for (int index = 0; index < 100; ++index)
  26. {
  27. AccountBS.AllItem.Add(new AccountModel { Id = index });
  28. }
  29.  
  30. AccountsLenth = Accounts.Count;
  31. }
  32.  
  33. [TestMethod]
  34. public void GetTest()
  35. {
  36. AccountModel result = AccountBS.Get(SomeId);
  37.  
  38. Assert.IsNotNull(result);
  39. }
  40.  
  41. [TestMethod]
  42. public void DeleteBoolTest()
  43. {
  44. bool result = AccountBS.Delete(SomeId);
  45.  
  46. Assert.IsTrue(result);
  47. }
  48.  
  49. [TestMethod]
  50. public void SaveBoolTest()
  51. {
  52. var ent = new AccountModel();
  53.  
  54. bool result = AccountBS.Save(ent);
  55.  
  56. Assert.IsTrue(result);
  57. }
  58.  
  59. [TestMethod]
  60. public void SaveCountTest()
  61. {
  62. var ent = new AccountModel();
  63.  
  64. AccountBS.Save(ent);
  65.  
  66. int AccountsLenth1 = Accounts.Count;
  67.  
  68. Assert.AreNotEqual(AccountsLenth, this.Accounts.Count);
  69. }
  70. }
Add Comment
Please, Sign In to add comment