public void opImplicit_string_BritishPostcode()
        {
            const string expected = "GU21 4XG";
            string       actual   = BritishPostcode.FromString(expected);

            Assert.Equal(expected, actual);
        }
        public void op_GetHashCode(string value)
        {
            var expected = value.GetHashCode();
            var actual   = BritishPostcode.FromString(value).GetHashCode();

            Assert.Equal(expected, actual);
        }
        public void op_FromString_string_whenPartialUnit(string expected,
                                                         string value)
        {
            var actual = BritishPostcode.FromString(value).ToString();

            Assert.Equal <BritishPostcode>(expected, actual);
        }
        public void op_FromString_string_whenThreeParts()
        {
            const string original = "GU21 4XG BB";
            var          obj      = BritishPostcode.FromString(original);

            Assert.Null(obj.Area);
            Assert.Null(obj.District);
            Assert.Null(obj.Sector);
            Assert.Null(obj.Unit);
        }
        public void op_FromString_string_whenPlaceName()
        {
            const string original = "ABERDEEN";
            var          obj      = BritishPostcode.FromString(original);

            Assert.Null(obj.Area);
            Assert.Null(obj.District);
            Assert.Null(obj.Sector);
            Assert.Null(obj.Unit);
        }
        public void op_FromString_string_whenPeriod()
        {
            const string original = ".AB10 1AA.";
            var          obj      = BritishPostcode.FromString(original);

            Assert.Equal("AB", obj.Area);
            Assert.Equal("AB10", obj.District);
            Assert.Equal("AB10 1", obj.Sector);
            Assert.Equal("AB10 1AA", obj.Unit);
        }
        public void op_FromString_string_WhenInvalid(string value)
        {
            var obj = BritishPostcode.FromString(value);

            Assert.Null(obj.Area);
            Assert.Null(obj.District);
            Assert.Null(obj.Sector);
            Assert.Null(obj.Unit);

            Assert.Null(obj.OutCode);
            Assert.Null(obj.InCode);
        }
        public void op_FromString_stringEmpty()
        {
            var obj = BritishPostcode.FromString(string.Empty);

            Assert.Null(obj.Area);
            Assert.Null(obj.District);
            Assert.Null(obj.Sector);
            Assert.Null(obj.Unit);

            Assert.Null(obj.OutCode);
            Assert.Null(obj.InCode);
        }
        public void op_FromString_string_whenOnlySector()
        {
            const string original = "GU21 4";
            var          obj      = BritishPostcode.FromString(original);

            Assert.Equal("GU", obj.Area);
            Assert.Equal("GU21", obj.District);
            Assert.Equal("GU21 4", obj.Sector);
            Assert.Null(obj.Unit);

            Assert.Equal("GU21", obj.OutCode);
            Assert.Null(obj.InCode);
        }
        public void op_FromString_string_whenLondonWC()
        {
            const string original = "WC1A 2HR";
            var          obj      = BritishPostcode.FromString(original);

            Assert.Equal("WC", obj.Area);
            Assert.Equal("WC1A", obj.District);
            Assert.Equal("WC1A 2", obj.Sector);
            Assert.Equal("WC1A 2HR", obj.Unit);

            Assert.Equal("WC1A", obj.OutCode);
            Assert.Equal("2HR", obj.InCode);
        }
        public void op_FromString_string(string value,
                                         string area,
                                         string district,
                                         string number,
                                         string sector,
                                         string unit)
        {
            var obj = BritishPostcode.FromString(value);

            Assert.Equal(area, obj.Area);
            Assert.Equal(district, obj.District);
            Assert.Equal(number, obj.DistrictNumber);
            Assert.Equal(sector, obj.Sector);
            Assert.Equal(unit, obj.Unit);

            Assert.Equal(district, obj.OutCode);
            Assert.Equal(unit.RemoveFromStart(district, StringComparison.OrdinalIgnoreCase).Trim(), obj.InCode);
        }
        public void op_ToString(string expected)
        {
            var actual = BritishPostcode.FromString(expected).ToString();

            Assert.Equal(expected, actual);
        }
        public void op_FromString_string_whenNoSpaces(string expected)
        {
            var actual = BritishPostcode.FromString(expected.RemoveAny(' ')).ToString();

            Assert.Equal(expected, actual);
        }
 public void op_FromString_stringNull()
 {
     Assert.Throws <ArgumentNullException>(() => BritishPostcode.FromString(null));
 }