public void DeleteInvalidAddress() { var options = TestDbContext.TestDbInitalizer("Delete Invalid Address"); //Want to delete Address1 but accidentally use Address2 Key. using (var dbcreate = TestDbContext.CreateTestDb(options)) { dbcreate.Add( AddressTestData.ValidAddress1()); dbcreate.SaveChanges(); } using (var dbcreate = TestDbContext.CreateTestDb(options)) { var TestKey = AddressTestData.ValidAddress2().Key; var AddressResult = new AddressRepository(dbcreate).Delete(TestKey); Assert.False(AddressResult); } }
public void ReadAllAddress() { var options = TestDbContext.TestDbInitalizer("Read All Addresses"); //Create Instance of DB. //Insert data into test database using (var dbcreate = TestDbContext.CreateTestDb(options)) { dbcreate.AddRange( AddressTestData.ValidAddress1(), AddressTestData.ValidAddress2()); dbcreate.SaveChanges(); } using (var dbcreate = TestDbContext.CreateTestDb(options)) { var AddressExpected = new AddressRepository(dbcreate).ReadAll(); var count = AddressExpected.Count(); Assert.Equal(2, count); } }
public void DeleteAddress() { var options = TestDbContext.TestDbInitalizer("Delete Address"); using (var dbcreate = TestDbContext.CreateTestDb(options)) { dbcreate.AddRange( AddressTestData.ValidAddress1(), AddressTestData.ValidAddress2()); dbcreate.SaveChanges(); } //We want to delete Address2. using (var dbcreate = TestDbContext.CreateTestDb(options)) { var TestKey = AddressTestData.ValidAddress2().Key; var AddressResult = new AddressRepository(dbcreate).Delete(TestKey); Assert.True(AddressResult); } }