public void AddAddress_ShouldThrowValidationError() { // Arrange Exception caugthException = null; var address = new Address { Name = "Heineken", AddressLine = "Rietveldenweg 25", City = "'s-Hertogenbosch", PostalCode = null }; var addressService = new AddressService(_fakeApplicationDbContext, _mockCurrentUserService.Object); // Act try { address = addressService.AddAddress(address); } catch (DbEntityValidationException ex) { caugthException = ex; } // Assert Assert.IsNull(address); Assert.IsNotNull(caugthException); }
public void AddAddress_CanAdd() { // Arrange var address = new Address { Name = "Heineken", AddressLine = "Rietveldenweg 25", City = "'s-Hertogenbosch", PostalCode = "5222 AP" }; var addressService = new AddressService(_fakeApplicationDbContext, _mockCurrentUserService.Object); // Act address = addressService.AddAddress(address); // Assert Assert.IsNotNull(address); Assert.AreEqual(address.Name, "Heineken"); Assert.AreEqual(address.AddressLine, "Rietveldenweg 25"); Assert.AreEqual(address.City, "'s-Hertogenbosch"); Assert.AreEqual(address.PostalCode, "5222 AP"); }