Exemple #1
0
        public void iswatermarked_initialized_to_default_value()
        {
            bool expectedValue = false;

            StampBase stamp = (StampBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.StampType);

            Assert.AreEqual(expectedValue, stamp.IsWatermarked);
        }
Exemple #2
0
        public void create_new_stamp_from_factory_country_set_to_country_default()
        {
            Type stampType = CollectableBaseFactory.StampType;

            StampBase newStamp = (StampBase)CollectableBaseFactory.CreateCollectableBase(stampType);

            Assert.IsTrue(newStamp.Country == StampBase.COUNTRY_DEFAULT);
        }
Exemple #3
0
        public void ispostagestamp_initialized_to_default_value()
        {
            bool expectedValue = true;

            StampBase stamp = (StampBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.StampType);

            Assert.AreEqual(expectedValue, stamp.IsPostageStamp);
        }
Exemple #4
0
        public void create_new_stamp_from_factory_isPostageStamp_defaults_to_true()
        {
            Type stampType = CollectableBaseFactory.StampType;

            StampBase newStamp = (StampBase)CollectableBaseFactory.CreateCollectableBase(stampType);

            Assert.IsTrue(newStamp.IsPostageStamp);
        }
Exemple #5
0
        public void display_name_initialized_to_default_value()
        {
            string expectedValue = StampBase.DISPLAYNAME_DEFAULT;

            StampBase stamp = (StampBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.StampType);

            Assert.AreEqual(expectedValue, stamp.DisplayName);
        }
Exemple #6
0
        public void country_name_initialized_to_default_value()
        {
            string expectedValue = StampBase.COUNTRY_DEFAULT;

            StampBase stamp = (StampBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.StampType);

            Assert.AreEqual(expectedValue, stamp.Country);
        }
Exemple #7
0
        public void validatecountry_returns_false_when_passed_unexpected_country()
        {
            string invalidCountry = "invalid";

            bool isValid = StampBase.ValidateCountry(invalidCountry);

            Assert.IsFalse(isValid, $"Expected ValidateCountry to return false an unexpected condition: {invalidCountry}");
        }
Exemple #8
0
        public void issueyearend_set_to_nonnegative_succeeds()
        {
            int       validEnd = 2005;
            StampBase stamp    = (StampBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.StampType);

            stamp.IssueYearEnd = validEnd;

            Assert.AreEqual(validEnd, stamp.IssueYearEnd);
        }
Exemple #9
0
        public void issueyearend_set_to_negative_throws_exception()
        {
            int       invalidEnd = -5;
            StampBase stamp      = (StampBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.StampType);

            stamp.IssueYearEnd = invalidEnd;

            Assert.Fail("Expected exception to be thrown when passed a negative issue year end");
        }
Exemple #10
0
        public void issueyearstart_set_to_nonnegative_succeeds()
        {
            int       validStart = 2005;
            StampBase stamp      = (StampBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.StampType);

            stamp.IssueYearStart = validStart;

            Assert.AreEqual(validStart, stamp.IssueYearStart);
        }
Exemple #11
0
        public void setting_displayname_to_valid_name_successful()
        {
            string    displayName = "Display Name";
            StampBase stamp       = (StampBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.StampType);

            stamp.DisplayName = displayName;

            Assert.AreEqual(displayName, stamp.DisplayName);
        }
Exemple #12
0
        public void validatecountry_returns_true_when_passed_valid_country()
        {
            foreach (string country in StampBase.STAMP_COUNTRIES)
            {
                bool isValid = StampBase.ValidateCountry(country);

                Assert.IsTrue(isValid);
            }
        }
Exemple #13
0
        public void compare_stamp_base_instances_by_explicitly_by_scottnumber_returns_false_when_null()
        {
            StampBase stamp     = (StampBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.StampType);
            StampBase testStamp = null;

            bool isEqual = stamp.IsSame(testStamp, false);

            Assert.IsFalse(isEqual, "Expected test to throw exception when comparing a null base instance");
        }
Exemple #14
0
        public void setting_displayname_to_empty_string_throws_exception()
        {
            string    invalidDisplayName = "";
            StampBase stamp = (StampBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.StampType);

            stamp.DisplayName = invalidDisplayName;

            Assert.Fail("Expected exception to be thrown when passed a null display name");
        }
Exemple #15
0
        public void firstdayofissue_sets_is_set_to_date_part_only_when_passed_date_only()
        {
            DateTime firstDateOnly = DateTime.Today;

            StampBase stamp = (StampBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.StampType);

            stamp.FirstDayOfIssue = firstDateOnly;

            Assert.AreEqual(firstDateOnly, stamp.FirstDayOfIssue);
        }
Exemple #16
0
        public void issueyearend_set_to_zero_set_to_issueyearstart_value()
        {
            int       endDate   = 0;
            int       startDate = 2011;
            StampBase stamp     = (StampBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.StampType);

            stamp.IssueYearStart = startDate;
            stamp.IssueYearEnd   = endDate;

            Assert.AreEqual(startDate, stamp.IssueYearEnd);
        }
Exemple #17
0
        public void compare_stamp_base_instances_by_country_and_scottnumber_are_not_equal_scottnumber()
        {
            StampBase stamp = (StampBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.StampType);

            stamp.Country     = StampBase.COUNTRY_DEFAULT;
            stamp.ScottNumber = "1000";
            StampBase testStamp = new StampBase()
            {
                ScottNumber = "1001", Country = stamp.Country
            };

            bool isEqual = stamp.IsSame(testStamp, false);

            Assert.IsFalse(isEqual);
        }
Exemple #18
0
        public void compare_stamp_base_instances_by_country_and_alternateid_are_not_equal_alternateid()
        {
            StampBase stamp = (StampBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.StampType);

            stamp.Country     = StampBase.COUNTRY_DEFAULT;
            stamp.AlternateId = "1000";
            StampBase testStamp = new StampBase()
            {
                Country     = stamp.Country,
                AlternateId = "1001"
            };

            bool isEqual = stamp.IsSame(testStamp, true);

            Assert.IsFalse(isEqual);
        }
Exemple #19
0
        private StampBase GetTestStampBase(int i)
        {
            StampBase collectable = new StampBase()
            {
                AlternateId     = $"alternateid{i}",
                Country         = StampBase.COUNTRY_DEFAULT,
                Description     = $"description{i}",
                DisplayName     = $"displayname{i}",
                FirstDayOfIssue = DateTime.Today.AddDays(-i * 100),
                IsPostageStamp  = true,
                ScottNumber     = $"scottnumber{i}",
                IssueYearStart  = 2000 + i
            };

            return(collectable);
        }
Exemple #20
0
        public void collectable_serialize_deserialize_stamp_success()
        {
            StampBase collectable = GetTestStampBase(5);

            collectable.AddItem(GetTestStampItem(0));
            collectable.AddItem(GetTestStampItem(1));
            collectable.AddItem(GetTestStampItem(2));

            string    jsonItem       = JsonConvert.SerializeObject(collectable);
            StampBase newCollectable = (StampBase)HomeCollectionRepository.GetCollectableFromJson(jsonItem, collectable.CollectableType); //JsonConvert.DeserializeObject<StampBase>(jsonItem);

            Assert.AreEqual(collectable.CollectableType, newCollectable.CollectableType);
            Assert.AreEqual(collectable.AlternateId, newCollectable.AlternateId);
            Assert.AreEqual(collectable.Country, newCollectable.Country);
            Assert.AreEqual(collectable.Description, newCollectable.Description);
            Assert.AreEqual(collectable.DisplayName, newCollectable.DisplayName);
            Assert.AreEqual(collectable.FirstDayOfIssue, newCollectable.FirstDayOfIssue);
            Assert.AreEqual(collectable.IsPostageStamp, newCollectable.IsPostageStamp);
            Assert.AreEqual(collectable.ScottNumber, newCollectable.ScottNumber);
            Assert.AreEqual(collectable.IssueYearStart, newCollectable.IssueYearStart);
        }