コード例 #1
0
        public void ShouldReturnNullIfNoAddressFound()
        {
            //Arrange
            var postalAddressLookupProvider = new Mock <IPostalAddressLookupProvider>();
            var serviceUnderTest            = new PostalAddressSearchService(postalAddressLookupProvider.Object);

            List <PostalAddress> findResult = null;

            postalAddressLookupProvider.Setup(m => m.GetValidatedPostalAddresses(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(findResult);

            //Act
            var result = serviceUnderTest.GetValidatedAddress(It.IsAny <string>(), It.IsAny <string>());

            //Assert
            result.Should().BeNull();
        }
コード例 #2
0
        public void ShouldReturnSinglePostalAddressIfSingleAddressFound()
        {
            //Arrange
            var postalAddressLookupProvider = new Mock <IPostalAddressLookupProvider>();
            var serviceUnderTest            = new PostalAddressSearchService(postalAddressLookupProvider.Object);

            var singleResult = new List <PostalAddress> {
                new Fixture().Build <PostalAddress>().Create()
            };

            postalAddressLookupProvider.Setup(m => m.GetValidatedPostalAddresses(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(singleResult);

            //Act
            var result = serviceUnderTest.GetValidatedAddress(It.IsAny <string>(), It.IsAny <string>());

            //Assert
            result.Should().NotBeNull();
        }