Esempio n. 1
0
        public void GivenAListOfMultipleProperties_WhenIExecute_ThenParametersArePassedIntoTheUseCase(string propertyReference, string propertyReference2)
        {
            //arrange
            var propertyReferences = new GetMultiplePropertiesUseCaseRequest(new List <string> {
                propertyReference, propertyReference2
            });

            //act
            _classUnderTest.GetMultipleByReference(propertyReferences);
            //assert
            _mockGetMultiplePropertiesUseCase.Verify(v => v.Execute(It.Is <GetMultiplePropertiesUseCaseRequest>(i => i.PropertyReferences[0] == propertyReference && i.PropertyReferences[1] == propertyReference2)), Times.Once);
        }
Esempio n. 2
0
        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);
        }