public void Response_should_contain_response_from_children_usecase(string propertyReference)
        {
            //arrange
            var expectedResponse = new GetPropertyChildrenResponse
            {
                Children = new List <Property>
                {
                    new Property {
                        MajorRef = propertyReference
                    }
                }
            };

            _mockUseCase.Setup(s => s.Execute(It.Is <GetPropertyChildrenRequest>(i => i.PropertyReference == propertyReference)))
            .Returns(expectedResponse);

            //act
            var response      = _classUnderTest.GetChildenProperties(propertyReference);
            var okResult      = (OkObjectResult)response;
            var resultContent = (GetPropertyChildrenResponse)okResult.Value;

            //assert
            okResult.Should().NotBeNull();
            okResult.Value.Should().NotBeNull();
            resultContent.Should().NotBeNull();
            JsonConvert.SerializeObject(expectedResponse).Should().BeEquivalentTo(JsonConvert.SerializeObject(resultContent));
        }
Пример #2
0
        public void WhenCallingGetAndTheUseCaseReturnsAResponseThenTheControllerReturnsThatResponse(string propertyReference)
        {
            //arrange
            var expectedResponse = new GetPropertyChildrenResponse
            {
                Children = new List <property_api.V1.Domain.Property>
                {
                    new property_api.V1.Domain.Property
                    {
                        MajorRef = propertyReference
                    }
                }
            };

            _mockUseCase.Setup(s => s.Execute(It.Is <GetPropertyChildrenRequest>(i => i.PropertyReference == propertyReference))).Returns(expectedResponse);
            //act
            var response      = _classUnderTest.Get(propertyReference);
            var okResult      = (OkObjectResult)response;
            var resultContent = (GetPropertyChildrenResponse)okResult.Value;

            //assert
            okResult.Should().NotBeNull();
            okResult.Value.Should().NotBeNull();
            resultContent.Should().NotBeNull();
            JsonConvert.SerializeObject(expectedResponse).Should().BeEquivalentTo(JsonConvert.SerializeObject(resultContent));
        }