Пример #1
0
        public void TwoPostalCodeObjects_UsingStrings_HaveToShareStrings()
        {
            var country           = new string(new char[] { 'D', 'Z' });
            var postalCodeFactory = new PostalCodeFactory();
            var postalCode1       = postalCodeFactory.CreatePostalCode(new Country(country), "12345");
            var postalCode2       = postalCodeFactory.CreatePostalCode(new Country(country), "12345");

            Assert.AreSame(postalCode1.ToString(), postalCode2.ToString(), "Country: " + country.ToUpper());
        }
        public void TwoPostalCodeObjects_UsingStrings_HaveToShareStrings()
        {
            var country = new string(new[] { 'D', 'Z' });
            var postalCodeFactory = new PostalCodeFactory();
            var postalCode1 = postalCodeFactory.CreatePostalCode(new Country(country), "12345");
            var postalCode2 = postalCodeFactory.CreatePostalCode(new Country(country), "12345");

            Assert.AreSame(postalCode1.ToString(), postalCode2.ToString(), "Country: " + country.ToUpper());
        }
Пример #3
0
        public void WithBritishZipCode_ReturnsTrueIfFormatMatchedAndCodesAreContained()
        {
            var cFactory  = new CountryFactory(new IsoCountryCodeValidator());
            var pcFactory = new PostalCodeFactory();
            var country   = cFactory.CreateCountry("GB");
            var right     = new PostalCodeRange(pcFactory.CreatePostalCode(country, "AA9 9AA"), pcFactory.CreatePostalCode(country, "BB9 9AA"));
            var left      = new PostalCodeRange(pcFactory.CreatePostalCode(country, "AA9 9AA"), pcFactory.CreatePostalCode(country, "CC9 9AA"));

            Assert.IsTrue(PostalCodeRange.Contains(left, right));
        }
Пример #4
0
        public void WithBritishZipCode_ReturnsFalseIfFormatsSameLengthButDifferentFormat()
        {
            var cFactory  = new CountryFactory(new IsoCountryCodeValidator());
            var pcFactory = new PostalCodeFactory();
            var country   = cFactory.CreateCountry("GB");
            var right     = new PostalCodeRange(pcFactory.CreatePostalCode(country, "A99 9AA"), pcFactory.CreatePostalCode(country, "B99 9AA"));
            var left      = new PostalCodeRange(pcFactory.CreatePostalCode(country, "AA9 9AA"), pcFactory.CreatePostalCode(country, "CC9 9AA"));

            Assert.IsFalse(PostalCodeRange.Contains(left, right));
        }
Пример #5
0
        public void CreatePostalCode_ReturnsCorrectObjectType(string country, string postalCode, string normalizedPostalCode, string objectTypeName)
        {
            var postalCodeFactory = new PostalCodeFactory();
            var postalCodeObject  = postalCodeFactory.CreatePostalCode(new Country(country), postalCode);

            Assert.AreEqual(objectTypeName, postalCodeObject.GetType().Name);
            Assert.AreEqual(normalizedPostalCode, postalCodeObject.ToString());
        }
        public void CreatePostalCode_ReturnsCorrectObjectType(string country, string postalCode, string normalizedPostalCode, string objectTypeName)
        {
            var postalCodeFactory = new PostalCodeFactory();
            var postalCodeObject = postalCodeFactory.CreatePostalCode(new Country(country), postalCode);

            Assert.AreEqual(objectTypeName, postalCodeObject.GetType().Name);
            Assert.AreEqual(normalizedPostalCode, postalCodeObject.ToString());
        }
 public void WithBritishZipCode_ReturnsTrueIfFormatMatchedAndCodesAreContained()
 {
     var cFactory = new CountryFactory(new IsoCountryCodeValidator());
     var pcFactory = new PostalCodeFactory();
     var country = cFactory.CreateCountry("GB");
     var right = new PostalCodeRange(pcFactory.CreatePostalCode(country, "AA9 9AA"), pcFactory.CreatePostalCode(country, "BB9 9AA"));
     var left = new PostalCodeRange(pcFactory.CreatePostalCode(country, "AA9 9AA"), pcFactory.CreatePostalCode(country, "CC9 9AA"));
     Assert.IsTrue(PostalCodeRange.Contains(left, right));
 }
 public void WithBritishZipCode_ReturnsFalseIfFormatsSameLengthButDifferentFormat()
 {
     var cFactory = new CountryFactory(new IsoCountryCodeValidator());
     var pcFactory = new PostalCodeFactory();
     var country = cFactory.CreateCountry("GB");
     var right = new PostalCodeRange(pcFactory.CreatePostalCode(country, "A99 9AA"), pcFactory.CreatePostalCode(country, "B99 9AA"));
     var left = new PostalCodeRange(pcFactory.CreatePostalCode(country, "AA9 9AA"), pcFactory.CreatePostalCode(country, "CC9 9AA"));
     Assert.IsFalse(PostalCodeRange.Contains(left, right));
 }