public void Put_Ok() { // Arrange var householdList = addTestHousehold(); // household to update var household = householdList.ElementAt(0); int householdId = household.HouseholdId; // household with updated data HouseholdEntity updatedHousehold = new HouseholdEntity(); // data for update string newName = "UpdatedName"; string newAddress1 = "UpdatedAddress1"; string newAddress2 = "Updatedaddress2"; string newCity = "UpdatedAalborg"; string newPostCode = "Updated9000"; string newCountry = "UpdatedDK"; // preparing an updated entity updatedHousehold.HouseholdId = householdId; updatedHousehold.Name = newName; AddressDto addressDto = new AddressDto(); addressDto.Address1 = newAddress1; addressDto.Address2 = newAddress2; addressDto.City = newCity; addressDto.PostCode = newPostCode; addressDto.Country = newCountry; updatedHousehold.Address = addressDto; try { var controller = TestData.GetHouseholdController(); // Act var result = (OkNegotiatedContentResult <HouseholdDto>)controller.Update(householdId, updatedHousehold); // Assert if (result.Content.Name.Equals(newName) && result.Content.Address.Address1.Equals(newAddress1) && result.Content.Address.Address2.Equals(newAddress2) && result.Content.Address.City.Equals(newCity) && result.Content.Address.PostCode.Equals(newPostCode) && result.Content.Address.Country.Equals(newCountry)) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } } finally { cleanup(householdList); } }
public void Create_Ok() { // Arrange string name = "CreateTest"; string address1 = "address1CreateTest"; string address2 = "address2CreateTest"; string city = "CityCreateTest"; string postCode = "PostCodeCreateTest"; string country = "CountryCreateTest"; // new entity to insert HouseholdEntity householdEntity = new HouseholdEntity(); householdEntity.Name = name; householdEntity.Address = new AddressDto(); householdEntity.Address.Address1 = address1; householdEntity.Address.Address2 = address2; householdEntity.Address.City = city; householdEntity.Address.PostCode = postCode; householdEntity.Address.Country = country; try { var controller = TestData.GetHouseholdController(); // Act var result = (OkNegotiatedContentResult <HouseholdDto>)controller.Create(householdEntity); // Assert if (result.Content.Name.Equals(name) && result.Content.Address.Address1.Equals(address1) && result.Content.Address.Address2.Equals(address2) && result.Content.Address.City.Equals(city) && result.Content.Address.PostCode.Equals(postCode) && result.Content.Address.Country.Equals(country)) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } } finally { } }