public virtual void Initializer() { //Add a client to be removed by our test. //Instantiate a new context. using (var context = new MainContext()) { //Create a repository based on the context. var myRepo = new Repository<Address>(context); //Have to provide valid info. MyNewAddress = new Address { AddressLine1 = "Barão de Mesquita Street", AddressLine2 = "Tijuca", Country = MyCountryTest, State = "RJ", Zip = "20540-156" }; myRepo.Add(MyNewAddress); myRepo.Save(); } }
public void Insert() { using (var context = new MainContext()) { var myRepo = new Repository<Address>(context); TotalAdresssBeforeTestRuns = myRepo.GetAll().Count(); //Have to provide a valid name and e-mail address MyNewAddress = new Address { AddressLine1 = "Barão de Mesquita Street", AddressLine2 = "Tijuca", Country = MyCountryTest, State = "RJ", Zip = "20540-156" }; myRepo.Add(MyNewAddress); myRepo.Save(); TotalOfClientsAfterTheTestRuns = myRepo.GetAll().Count(); //Assert that the number of clients increase by 1 Assert.AreEqual(TotalAdresssBeforeTestRuns + 1, TotalOfClientsAfterTheTestRuns); } }
public virtual void Dispose() { //Clean the database using (var context = new MainContext()) { var myRepo = new Repository<Address>(context); //Get the Address to be removed. MyNewAddress = myRepo.Query(s => s.AddressLine1 == MyNewAddress.AddressLine1).FirstOrDefault(); if (myRepo.GetAll().Any()) { myRepo.Remove(MyNewAddress); myRepo.Save(); } } }
public void AddAdress(Address myAddress) { Address.Add(myAddress); }