public void TestClean() { client1 = null; clientsQ = null; kkRepo = null; client1 = null; client2 = null; clientsQ = null; clientsL = null; clientsDel = null; dbSet = null; kkRepo = null; }
public void TestInit() { dbSet = new Mock <DbSet <KEY_CLIENTS_SQL> >(); client1 = new KEY_CLIENTS_SQL() { MERCHANT = 900000000, RESPONSIBILITY_MANAGER = @"MNG1", ID = 0 }; client2 = new KEY_CLIENTS_SQL() { MERCHANT = 100000001, RESPONSIBILITY_MANAGER = @"MNG0", ID = -1 }; clientsL = new List <KEY_CLIENTS_SQL>() { new KEY_CLIENTS_SQL() { MERCHANT = 900000001, RESPONSIBILITY_MANAGER = @"MNG2", ID = 1 }, new KEY_CLIENTS_SQL() { MERCHANT = 900000002, RESPONSIBILITY_MANAGER = @"MNG2", ID = 2 }, new KEY_CLIENTS_SQL() { MERCHANT = 900000003, RESPONSIBILITY_MANAGER = @"MNG2", ID = 3 }, new KEY_CLIENTS_SQL() { MERCHANT = 900000004, RESPONSIBILITY_MANAGER = @"MNG3", ID = 4 }, new KEY_CLIENTS_SQL() { MERCHANT = 900000005, RESPONSIBILITY_MANAGER = @"MNG3", ID = 5 } }; clientsDel = new List <KEY_CLIENTS_SQL> { (from s in clientsL where s.ID == 4 select s).FirstOrDefault(), (from s in clientsL where s.ID == 5 select s).FirstOrDefault() }; clientsQ = clientsL.AsQueryable(); kkRepo = new Mock <IRepository <KEY_CLIENTS_SQL> > (); clientsInitialCount = clientsL.Count(); clientAfterAddCount = clientsInitialCount + 1; clientsAfterDeleteCount = clientAfterAddCount - 1; clientsAfterListDeleteCount = clientsAfterDeleteCount - clientsDel.Count(); //Arrange kkRepo.Setup(m => m.Add(It.IsAny <KEY_CLIENTS_SQL>())).Callback( (KEY_CLIENTS_SQL s) => { clientsL.Add(s); }); kkRepo.Setup(m => m.DeleteByID(It.IsAny <int>())).Callback( (int s) => { clientsL.Remove(clientsL.Where(r => r.ID == s).FirstOrDefault()); }); kkRepo.Setup(m => m.DeleteByList(It.IsAny <List <KEY_CLIENTS_SQL> >())).Callback( (List <KEY_CLIENTS_SQL> s) => { clientsL = clientsL.Except(clientsDel.AsEnumerable()).ToList(); }); kkRepo.Setup(m => m.Save()).Verifiable(); kkRepo.Setup(m => m.GetByID(It.IsAny <int>())) .Returns <int>(id => clientsQ.SingleOrDefault(r => r.ID == id)); kkRepo.Setup(m => m.GetALL()).Returns(clientsL.AsQueryable()); }