コード例 #1
0
        public void create_new_book_from_factory_datepublished_defaults_to_min_date()
        {
            BookBase book = (BookBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.BookType);

            Assert.AreEqual(0, book.Year);
            Assert.AreEqual(0, book.Month);
        }
コード例 #2
0
        public void create_new_collectable_from_interface_type_string_throws_exception()
        {
            string validTypeName = "ICollectableBase";

            ICollectableBase newItem = CollectableBaseFactory.CreateCollectableBase(validTypeName);

            Assert.IsFalse(true, "Expected test to fail if passed an interface type name");
        }
コード例 #3
0
        public void book_year_can_be_set_to_zero_successfully()
        {
            BookBase book = (BookBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.BookType);

            book.Year = 0;

            Assert.AreEqual(0, book.Year);
        }
コード例 #4
0
        public void create_new_collectable_from_empty_string_throws_exception()
        {
            string invalidTypeName = "";

            ICollectableBase newItem = CollectableBaseFactory.CreateCollectableBase(invalidTypeName);

            Assert.IsFalse(true, "Expected test to fail if passed a null type");
        }
コード例 #5
0
        public void create_new_book_from_factory_getitems_defaults_to_zero_items_in_list()
        {
            BookBase book = (BookBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.BookType);

            IList <ICollectableItem> bookItems = book.ItemInstances;

            Assert.AreEqual(0, bookItems.Count);
        }
コード例 #6
0
        public void create_new_factory_instance_from_valid_collectable_base_name_case_insensitive_succeeds()
        {
            string validTypeName = "BOOkBaSe";   // implements ICollectableBase

            ICollectableBase newItem = CollectableBaseFactory.CreateCollectableBase(validTypeName);

            Assert.AreEqual(validTypeName.ToUpper(), newItem.CollectableType.Name.ToUpper(), "Expected to get instance of a book base type");
        }
コード例 #7
0
        public void create_new_collectable_from_null_type_throws_exception()
        {
            Type invalidType = null;

            ICollectableBase newItem = CollectableBaseFactory.CreateCollectableBase(invalidType);

            Assert.IsFalse(true, "Expected test to fail if passed a null type");
        }
コード例 #8
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);
        }
コード例 #9
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);
        }
コード例 #10
0
        public void create_new_stamp_from_factory_returns_stampbase_type()
        {
            Type stampType = CollectableBaseFactory.StampType;

            ICollectableBase newStamp = CollectableBaseFactory.CreateCollectableBase(stampType);

            Assert.IsTrue(stampType == newStamp.CollectableType);
        }
コード例 #11
0
        public void create_new_collectable_from_interface_type_throws_exception()
        {
            Type invalidType = typeof(IStampBase);

            ICollectableBase newItem = CollectableBaseFactory.CreateCollectableBase(invalidType);

            Assert.IsFalse(true, "Expected test to fail if passed an interface instead of valid collectable base type");
        }
コード例 #12
0
        public void display_name_cannot_be_set_to_blank_string()
        {
            BookBase book = (BookBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.BookType);

            book.DisplayName = "";

            Assert.IsFalse(true, "Expected an exception to be thrown if a blank display name is set");
        }
コード例 #13
0
        public void display_name_initialized_to_default_value()
        {
            string expectedValue = BookBase.DISPLAYNAME_DEFAULT;

            BookBase book = (BookBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.BookType);

            Assert.AreEqual(expectedValue, book.DisplayName);
        }
コード例 #14
0
        public void iswatermarked_initialized_to_default_value()
        {
            bool expectedValue = false;

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

            Assert.AreEqual(expectedValue, stamp.IsWatermarked);
        }
コード例 #15
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);
        }
コード例 #16
0
        public void ispostagestamp_initialized_to_default_value()
        {
            bool expectedValue = true;

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

            Assert.AreEqual(expectedValue, stamp.IsPostageStamp);
        }
コード例 #17
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);
        }
コード例 #18
0
        public void book_year_cannot_be_set_to_negative()
        {
            BookBase book = (BookBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.BookType);

            book.Year = -100;

            Assert.IsFalse(true, "Expected an exception to be thrown if a negative year is set");
        }
コード例 #19
0
        public void create_new_book_from_factory_getitems_does_not_return_null_list()
        {
            BookBase book = (BookBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.BookType);

            IList <ICollectableItem> bookItems = book.ItemInstances;

            Assert.IsNotNull(bookItems);
        }
コード例 #20
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");
        }
コード例 #21
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);
        }
コード例 #22
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);
        }
コード例 #23
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");
        }
コード例 #24
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);
        }
コード例 #25
0
        public void create_new_factory_instance_from_valid_collectable_base_succeeds()
        {
            foreach (Type validType in CollectableBaseFactory.CollectableTypes)
            {
                ICollectableBase newCollectable = CollectableBaseFactory.CreateCollectableBase(validType);

                Assert.AreEqual(validType, newCollectable.CollectableType, $"Expected to get instance of a {validType.Name} base type");
            }
        }
コード例 #26
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");
        }
コード例 #27
0
        public void book_year_can_be_set_to_valid_year_successfully()
        {
            BookBase book     = (BookBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.BookType);
            int      testYear = 2015;

            book.Year = testYear;

            Assert.AreEqual(testYear, book.Year);
        }
コード例 #28
0
        public void compare_book_base_instances_by_explicit_scottnumber_returns_false_when_null()
        {
            BookBase book     = (BookBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.BookType);
            BookBase testbook = null;

            bool isEqual = book.IsSame(testbook, false);

            Assert.IsFalse(isEqual, "Expected test to throw exception when comparing a null base instance");
        }
コード例 #29
0
        public void display_name_set_to_nonblank_value_succeeds()
        {
            string   expectedValue = "Display Name";
            BookBase book          = (BookBase)CollectableBaseFactory.CreateCollectableBase(CollectableBaseFactory.BookType);

            book.DisplayName = expectedValue;

            Assert.AreEqual(expectedValue, book.DisplayName);
        }
コード例 #30
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);
        }