/// <summary>
        /// Generates a nicely formatted address which is nice and human readable.
        /// </summary>
        /// <param name="isStreetAndStreetNumberIncluded">Include the street number and street name? Defaults to: TRUE.</param>
        /// <param name="stateReplacementType">Do we replace the State with any pre-hardcoded values? Defaults to: DON'T REPLACE.</param>
        /// <param name="isCountryCodeIncluded">Do we include the country ISO code? Defaults to: FALSE.</param>
        /// <param name="isPostCodeIncluded">Do we include the postcode? Defaults to: FALSE.</param>
        public string ToFormattedAddress(bool isStreetAndStreetNumberIncluded      = true,
                                         StateReplacementType stateReplacementType = StateReplacementType.DontReplace,
                                         bool isCountryCodeIncluded = false,
                                         bool isPostCodeIncluded    = false)
        {
            var state = string.IsNullOrWhiteSpace(State)
                            ? null
                            : stateReplacementType == StateReplacementType.DontReplace
                                ? State                             // Don't check or change the current 'State' value.
                                : string.IsNullOrWhiteSpace(State)
                                    ? State                         // Have nothing to check/change.
                                    : stateReplacementType == StateReplacementType.ReplaceToShortText
                                        ? ToShortStateString(State) // e.g. VIC.
                                        : ToLongStateString(State); // e.g. Victoria.

            return(ToFormattedAddress(isStreetAndStreetNumberIncluded
                                        ? StreetNumber
                                        : null,
                                      isStreetAndStreetNumberIncluded
                                        ? Street
                                        : null,
                                      Suburb,
                                      state,
                                      isCountryCodeIncluded
                                        ? CountryIsoCode
                                        : null,
                                      isPostCodeIncluded
                                        ? Postcode
                                        : null));
        }
예제 #2
0
        [InlineData(false, StateReplacementType.DontReplace, false, false, "RICHMOND, vic")]                                  // No street number or street, no ISO, no postcode.
        public void GivenVariousOptions_ToFormattedAddress_ReturnsAFormattedAddress(bool isStreetAndStreetNumberIncluded,
                                                                                    StateReplacementType stateReplacementType,
                                                                                    bool isCountryCodeIncluded,
                                                                                    bool isPostCodeIncluded,
                                                                                    string expectedformattedAddress)
        {
            // Arrange.


            // Act.
            var formattedAddress = FakeData.FakeAddress.ToFormattedAddress(isStreetAndStreetNumberIncluded,
                                                                           stateReplacementType,
                                                                           isCountryCodeIncluded,
                                                                           isPostCodeIncluded);

            // Assert.
            formattedAddress.ShouldBe(expectedformattedAddress);
        }