public void ReturnsEmptyPropertyWhereThereIsNoMatch() { var expectedResponse = new UhPropertyEntity(); var result = _classUnderTest.FromUHProperty(expectedResponse); Assert.True(result is Property); Assert.IsNull(result.PropRef); Assert.IsNull(result.Telephone); }
public Property GetPropertyByPropertyReference(string propertyReference) { var response = _uhContext.UhPropertys.SingleOrDefault(p => p.PropRef == propertyReference); if (response == null) { return(null); } return(_factory.FromUHProperty(response)); }
public void GivenListOfPropRefsAreProvided_WhenEndpointIsCalled_ThenItShouldReturnTheMultiplePropertiesSpecified(string propertyReference, string propertyReference2) { //arrange var property1 = _uhPropertyHelper.GenerateUhProperty(); property1.PropRef = propertyReference; var property2 = _uhPropertyHelper.GenerateUhProperty(); property2.PropRef = propertyReference2; _uhContext.UhPropertys.Add(property1); _uhContext.UhPropertys.Add(property2); _uhContext.SaveChanges(); var propertyReferences = new GetMultiplePropertiesUseCaseRequest(new List <string> { propertyReference, propertyReference2 }); var expectedJson = JsonConvert.SerializeObject( new GetMultiplePropertiesUseCaseResponse(new List <Property> { _factory.FromUHProperty(property1), _factory.FromUHProperty(property2) }) ); //act var actual = _classUnderTest.GetMultipleByReference(propertyReferences); //assert actual.Should().NotBeNull(); var okObjectResult = (OkObjectResult)actual; var response = (GetMultiplePropertiesUseCaseResponse)okObjectResult.Value; response.Should().NotBeNull(); response.Properties.Should().NotBeNullOrEmpty(); response.Properties.Should().BeOfType <List <Property> >(); Assert.AreSame(propertyReference, response.Properties[0].PropRef); Assert.AreSame(propertyReference2, response.Properties[1].PropRef); var actualJson = JsonConvert.SerializeObject(response); expectedJson.Should().BeEquivalentTo(actualJson); }