Пример #1
0
        public void Should_Add_Selector_To_Back_Of_List()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some selectors that we're going to add
            var stringSelector1 = new StringSelector();
            var stringSelector2 = new FullNameSelector();

            Assert.AreEqual(0, table.CountSelectors<string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");

            //Add the first selector (our default string selector)
            table.AddSelector<string>(stringSelector1);
            Assert.AreEqual(1, table.CountSelectors<string>(), "should have ONE type selectors for type 'string'");

            var firstselector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstselector);

            //Add the second selector (FullNameSelector) to the back of the processing queue
            table.AddSelector(stringSelector2, SelectorPosition.Last);
            Assert.AreEqual(2, table.CountSelectors<string>(), "should have TWO type selectors for type 'string'");

            firstselector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstselector);

            var lastselector = table.GetSelectors<string>().Last();
            Assert.IsInstanceOf<FullNameSelector>(lastselector);
        }
Пример #2
0
        public void Should_Add_Type_Selectors_For_Single_Type_To_TypeTable()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some selectors that we're going to add
            var stringSelector1 = new StringSelector();
            var stringSelector2 = new FullNameSelector();
            var stringSelector3 = new EmailSelector();

            Assert.AreEqual(0, table.CountSelectors <string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");

            //Add the first selector (our default string selector)
            table.AddSelector <string>(stringSelector1);
            Assert.AreEqual(1, table.CountSelectors <string>(), "should have ONE type selectors for type 'string'");

            var firstselector = table.GetSelectors <string>().First();

            Assert.IsInstanceOf <StringSelector>(firstselector);

            //Add the second selector (the full name selector)
            table.AddSelector <string>(stringSelector2);
            Assert.AreEqual(2, table.CountSelectors <string>(), "should have TWO type selectors for type 'string'");

            firstselector = table.GetSelectors <string>().First();
            Assert.IsInstanceOf <FullNameSelector>(firstselector); //Oh snap, the new front of the line should be our full name selector!

            //Add the thrid selector (the email address selector)
            table.AddSelector <string>(stringSelector3);
            Assert.AreEqual(3, table.CountSelectors <string>(), "should have THREE type selectors for type 'string'");

            firstselector = table.GetSelectors <string>().First();
            Assert.IsInstanceOf <EmailSelector>(firstselector); //Oh snap, the new front of the line should be our full name selector!
        }
Пример #3
0
        public void Should_Add_Selector_To_Back_Of_List()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some selectors that we're going to add
            var stringSelector1 = new StringSelector();
            var stringSelector2 = new FullNameSelector();

            Assert.AreEqual(0, table.CountSelectors <string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");

            //Add the first selector (our default string selector)
            table.AddSelector <string>(stringSelector1);
            Assert.AreEqual(1, table.CountSelectors <string>(), "should have ONE type selectors for type 'string'");

            var firstselector = table.GetSelectors <string>().First();

            Assert.IsInstanceOf <StringSelector>(firstselector);

            //Add the second selector (FullNameSelector) to the back of the processing queue
            table.AddSelector(stringSelector2, SelectorPosition.Last);
            Assert.AreEqual(2, table.CountSelectors <string>(), "should have TWO type selectors for type 'string'");

            firstselector = table.GetSelectors <string>().First();
            Assert.IsInstanceOf <StringSelector>(firstselector);

            var lastselector = table.GetSelectors <string>().Last();

            Assert.IsInstanceOf <FullNameSelector>(lastselector);
        }
Пример #4
0
        public void TypeTable_changes_to_clone_should_not_modify_original()
        {
            var typeTable = new TypeTable();
            var typeTableIntSelectorCount = typeTable.CountSelectors(typeof(int));
            var clone = typeTable.Clone();
            var oldCloneTableIntSelectorCount = clone.CountSelectors(typeof(int));

            clone.AddSelector(new IntSelector());
            var newCloneTableSelectorCount = clone.CountSelectors(typeof(int));

            // sanity check to make sure we added the new type selector
            Assert.AreEqual(typeTableIntSelectorCount, oldCloneTableIntSelectorCount);
            Assert.AreNotEqual(oldCloneTableIntSelectorCount, newCloneTableSelectorCount);
            Assert.True(newCloneTableSelectorCount > oldCloneTableIntSelectorCount);

            // make sure we didn't modify old originak
            var newTypeTableSelectorCount = typeTable.CountSelectors(typeof(int));

            Assert.AreEqual(typeTableIntSelectorCount, oldCloneTableIntSelectorCount);
        }
Пример #5
0
        public void Should_Add_Type_Selectors_For_Multiple_Types_To_TypeTable()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some string selectors that we're going to add
            var stringSelector1 = new StringSelector();

            //Create some long selectors that we're going to use...
            var longSelector1 = new LongSelector();
            var longSelector2 = new TimeStampSelector();

            Assert.AreEqual(0, table.CountSelectors <string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");
            Assert.AreEqual(0, table.CountSelectors <long>(), "should have ZERO type selectors for type 'long' since we haven't added any yet");

            //Add the first and only string selector (our default string selector)
            table.AddSelector <string>(stringSelector1);
            Assert.AreEqual(1, table.CountSelectors <string>(), "should have ONE type selectors for type 'string'");
            Assert.AreEqual(0, table.CountSelectors <long>(), "should have ZERO type selectors for type 'long' since we haven't added any yet"); //Assert that we haven't added any long selectors yet

            var firstStringSelector = table.GetSelectors <string>().First();

            Assert.IsInstanceOf <StringSelector>(firstStringSelector);

            var currentLongSelector = table.GetSelectors <long>().FirstOrDefault();

            Assert.IsNull(currentLongSelector); //Since we haven't added any long selectors yet, this should return null

            //Add the first long selector (our default long selector)
            table.AddSelector <long>(longSelector1);
            Assert.AreEqual(1, table.CountSelectors <string>(), "should have ONE type selectors for type 'string'");
            Assert.AreEqual(1, table.CountSelectors <long>(), "should have ONE type selectors for type 'long'");

            firstStringSelector = table.GetSelectors <string>().First();
            Assert.IsInstanceOf <StringSelector>(firstStringSelector);

            currentLongSelector = table.GetSelectors <long>().FirstOrDefault();
            Assert.IsInstanceOf <LongSelector>(currentLongSelector);

            //Add the final long selector (our timestamp selector)
            table.AddSelector <long>(longSelector2);
            Assert.AreEqual(1, table.CountSelectors <string>(), "should have ONE type selectors for type 'string'");
            Assert.AreEqual(2, table.CountSelectors <long>(), "should have TWO type selectors for type 'long'");

            firstStringSelector = table.GetSelectors <string>().First();
            Assert.IsInstanceOf <StringSelector>(firstStringSelector);

            currentLongSelector = table.GetSelectors <long>().FirstOrDefault();
            Assert.IsInstanceOf <TimeStampSelector>(currentLongSelector);
        }
Пример #6
0
        public void Should_Clear_TypeSelector_List()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some selectors that we're going to add
            var stringSelector1 = new StringSelector();
            var stringSelector2 = new FullNameSelector();

            Assert.AreEqual(0, table.CountSelectors <string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");

            //Add some type selectors to our typetable
            table.AddSelector(stringSelector1);
            table.AddSelector(stringSelector2);

            //Check to see that our table contains at least two items...
            Assert.AreEqual(2, table.CountSelectors <string>(), "should have TWO type selectors for type 'string'");

            //Clear all of the string selectors
            table.ClearSelectors <string>();

            //Count the new number of string selectors (should equal zero)
            Assert.AreEqual(0, table.CountSelectors <string>());
        }
Пример #7
0
        public void Should_Add_Type_Selectors_For_Multiple_Types_To_TypeTable()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some string selectors that we're going to add
            var stringSelector1 = new StringSelector();

            //Create some long selectors that we're going to use...
            var longSelector1 = new LongSelector();
            var longSelector2 = new TimeStampSelector();

            Assert.AreEqual(0, table.CountSelectors<string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");
            Assert.AreEqual(0, table.CountSelectors<long>(), "should have ZERO type selectors for type 'long' since we haven't added any yet");

            //Add the first and only string selector (our default string selector)
            table.AddSelector<string>(stringSelector1);
            Assert.AreEqual(1, table.CountSelectors<string>(), "should have ONE type selectors for type 'string'");
            Assert.AreEqual(0, table.CountSelectors<long>(), "should have ZERO type selectors for type 'long' since we haven't added any yet"); //Assert that we haven't added any long selectors yet

            var firstStringSelector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstStringSelector);

            var currentLongSelector = table.GetSelectors<long>().FirstOrDefault();
            Assert.IsNull(currentLongSelector); //Since we haven't added any long selectors yet, this should return null

            //Add the first long selector (our default long selector)
            table.AddSelector<long>(longSelector1);
            Assert.AreEqual(1, table.CountSelectors<string>(), "should have ONE type selectors for type 'string'");
            Assert.AreEqual(1, table.CountSelectors<long>(), "should have ONE type selectors for type 'long'");

            firstStringSelector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstStringSelector);

            currentLongSelector = table.GetSelectors<long>().FirstOrDefault();
            Assert.IsInstanceOf<LongSelector>(currentLongSelector);

            //Add the final long selector (our timestamp selector)
            table.AddSelector<long>(longSelector2);
            Assert.AreEqual(1, table.CountSelectors<string>(), "should have ONE type selectors for type 'string'");
            Assert.AreEqual(2, table.CountSelectors<long>(), "should have TWO type selectors for type 'long'");

            firstStringSelector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstStringSelector);

            currentLongSelector = table.GetSelectors<long>().FirstOrDefault();
            Assert.IsInstanceOf<TimeStampSelector>(currentLongSelector);
        }
Пример #8
0
        public void Should_Add_Type_Selectors_For_Single_Type_To_TypeTable()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some selectors that we're going to add
            var stringSelector1 = new StringSelector();
            var stringSelector2 = new FullNameSelector();
            var stringSelector3 = new EmailSelector();

            Assert.AreEqual(0, table.CountSelectors<string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");

            //Add the first selector (our default string selector)
            table.AddSelector<string>(stringSelector1);
            Assert.AreEqual(1, table.CountSelectors<string>(), "should have ONE type selectors for type 'string'");

            var firstselector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstselector);

            //Add the second selector (the full name selector)
            table.AddSelector<string>(stringSelector2);
            Assert.AreEqual(2, table.CountSelectors<string>(), "should have TWO type selectors for type 'string'");

            firstselector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<FullNameSelector>(firstselector); //Oh snap, the new front of the line should be our full name selector!

            //Add the thrid selector (the email address selector)
            table.AddSelector<string>(stringSelector3);
            Assert.AreEqual(3, table.CountSelectors<string>(), "should have THREE type selectors for type 'string'");

            firstselector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<EmailSelector>(firstselector); //Oh snap, the new front of the line should be our full name selector!
        }
Пример #9
0
        public void Should_Clear_TypeSelector_List()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some selectors that we're going to add
            var stringSelector1 = new StringSelector();
            var stringSelector2 = new FullNameSelector();

            Assert.AreEqual(0, table.CountSelectors<string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");

            //Add some type selectors to our typetable
            table.AddSelector(stringSelector1);
            table.AddSelector(stringSelector2);

            //Check to see that our table contains at least two items...
            Assert.AreEqual(2, table.CountSelectors<string>(), "should have TWO type selectors for type 'string'");

            //Clear all of the string selectors
            table.ClearSelectors<string>();

            //Count the new number of string selectors (should equal zero)
            Assert.AreEqual(0, table.CountSelectors<string>());
        }
Пример #10
0
        public void TypeTable_changes_to_original_should_not_modify_clone()
        {
            var typeTable = new TypeTable();
            var typeTableIntSelectorCount = typeTable.CountSelectors(typeof(int));
            var clone = typeTable.Clone();
            var oldCloneTableIntSelectorCount = clone.CountSelectors(typeof(int));

            typeTable.AddSelector(new IntSelector());
            var newTypeTableSelectorCount = typeTable.CountSelectors(typeof(int));

            // sanity check to make sure we added the new type selector
            Assert.AreEqual(typeTableIntSelectorCount, oldCloneTableIntSelectorCount);
            Assert.AreNotEqual(typeTableIntSelectorCount, newTypeTableSelectorCount);
            Assert.True(newTypeTableSelectorCount > typeTableIntSelectorCount);

            // make sure we didn't modify old originak
            var newCloneSelectorCount = clone.CountSelectors(typeof(int));
            Assert.AreEqual(oldCloneTableIntSelectorCount, newCloneSelectorCount);
        }