示例#1
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);
        }
示例#2
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);
        }