Пример #1
0
        public void AddressThrowsExceptionsWhenFormatIsCalledAndNoAddressLinesArePopulated()
        {
            // Arrange
            var sut = new UKAddressBuilder();

            // Act & Assert
            Assert.Throws <AddressEmptyException>(() => sut.Build().Format()).Message.Should().Be("No address lines were populated");
        }
Пример #2
0
        public void AddressWithAllLinesFormatsCorrectly()
        {
            // Arrange
            var sut = new UKAddressBuilder();

            // Act
            sut.WithAddressLineOne("62 The Street")
            .WithAddressLineTwo("Suburb")
            .WithAddressLineThree("Town")
            .WithAddressLineFour("County")
            .WithAddressLineFive("City")
            .WithPostcode("Postcode");

            // Assert
            var expected = "62 The Street, Suburb, Town, County, City, Postcode";
            var actual   = sut.Build();

            actual.Format().Should().Be(expected);
        }
Пример #3
0
        public void AddressFormattedCorrectlyWithSingleLines(string addressLineOne, string addressLineTwo, string addressLineThree, string addressLineFour, string addressLineFive, string postcode, string expectedFormattedOutput)
        {
            // Arrange
            var sut = new UKAddressBuilder();

            // Act
            sut
            .WithAddressLineOne(addressLineOne)
            .WithAddressLineTwo(addressLineTwo)
            .WithAddressLineThree(addressLineThree)
            .WithAddressLineFour(addressLineFour)
            .WithAddressLineFive(addressLineFive)
            .WithPostcode(postcode);

            // Assert
            var address          = sut.Build();
            var formattedAddress = address.Format();

            formattedAddress.Should().Be(expectedFormattedOutput);
        }