public void CanFindStoreAddressIfOneDoesntExist() { RequestContext c = new RequestContext(); c.CurrentStore.Id = 100; AddressRepository target = AddressRepository.InstantiateForMemory(c); int countBefore = target.CountOfAll(); Assert.AreEqual(0, countBefore, "No Addresses should exist before the request for store address"); // Target Store Address Should Not Exist Address actual; actual = target.FindStoreContactAddress(); // Make sure we received an address Assert.IsNotNull(actual, "Actual address should not be null"); Assert.AreNotEqual(string.Empty, actual.Bvin, "Bvin should be a valid value"); // Make sure it was saved in the database int countAfter = target.CountOfAll(); Assert.AreEqual(1, countAfter, "Request for store address should have created one if missing."); // Make sure we can update it actual.City = "My New City"; Assert.IsTrue(target.Update(actual), "Update should be true"); Address actual2 = target.FindStoreContactAddress(); Assert.IsNotNull(actual2, "Second request should return an address"); Assert.AreEqual(actual.Bvin, actual2.Bvin, "Both request should return the same address"); Assert.AreEqual("My New City", actual2.City, "City should have been updated."); }