コード例 #1
0
        public void DefaultActionValue_Add_NonMapCollection()
        {
            int location   = 10;
            G   groupState = Mock.Of <G>();
            DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>();
            Dictionary <IValuable <G>, ValuePointer <G> > collectionValues = new Dictionary <IValuable <G>, ValuePointer <G> >()
            {
                { new DefaultIntValue <G>(0), new ValuePointer <G> {
                      Value = Mock.Of <IValuable <G> >()
                  } },
                { new DefaultIntValue <G>(1), new ValuePointer <G> {
                      Value = Mock.Of <IValuable <G> >()
                  } },
                { new DefaultIntValue <G>(2), new ValuePointer <G> {
                      Value = Mock.Of <IValuable <G> >()
                  } }
            };
            ICollectionValue <G> collectionValue = valueProvider.GetCollection(collectionValues, null);

            DefaultActionValue <G>     sut    = new DefaultActionValue <G>(groupState, location);
            DefaultCollectionValue <G> result = (DefaultCollectionValue <G>)sut.Add(collectionValue, valueProvider);

            List <KeyValuePair <IValuable <G>, ValuePointer <G> > > entries = result.GetEntries();

            Assert.Equal(Enumerable.Range(0, 4), entries.Select(kv => kv.Key).Cast <IValue>().Select(v => Convert.ToInt32(v.GetData())));
            Assert.Equal(new IValuable <G>[] { sut }.Concat(collectionValues.Values.Select(v => v.Value)), entries.Select(kv => kv.Value).Select(vp => vp.Value));
            Assert.False(result.IsMap);
            Assert.Equal(Enumerable.Range(0, 4), entries.Select(e => e.Value).Cast <EntryValuePointer <G> >().Select(v => v.Index));
        }
コード例 #2
0
        public void DefaultValueProvider_GetCollection_WithEntries()
        {
            Dictionary <IValuable <G>, ValuePointer <G> > values = new Dictionary <IValuable <G>, ValuePointer <G> >()
            {
                { new DefaultIntValue <G>(0), new ValuePointer <G> {
                      Value = Mock.Of <IValuable <G> >()
                  } },
                { new DefaultIntValue <G>(1), new ValuePointer <G> {
                      Value = Mock.Of <IValuable <G> >()
                  } },
                { new DefaultIntValue <G>(2), new ValuePointer <G> {
                      Value = Mock.Of <IValuable <G> >()
                  } },
                { new DefaultIntValue <G>(3), new ValuePointer <G> {
                      Value = Mock.Of <IValuable <G> >()
                  } },
                { new DefaultIntValue <G>(4), new ValuePointer <G> {
                      Value = Mock.Of <IValuable <G> >()
                  } },
                { new DefaultIntValue <G>(5), new ValuePointer <G> {
                      Value = Mock.Of <IValuable <G> >()
                  } }
            };

            DefaultValueProvider <G> sut    = new DefaultValueProvider <G>();
            ICollectionValue <G>     result = sut.GetCollection(values, null);

            Assert.Equal(6, result.Size);
        }
コード例 #3
0
        public void DefaultValueProvider_GetCollection_WithList()
        {
            ValuePointer <G>[] values = new ValuePointer <G>[]
            {
                new ValuePointer <G> {
                    Value = Mock.Of <IValuable <G> >()
                },
                new ValuePointer <G> {
                    Value = Mock.Of <IValuable <G> >()
                },
                new ValuePointer <G> {
                    Value = Mock.Of <IValuable <G> >()
                },
                new ValuePointer <G> {
                    Value = Mock.Of <IValuable <G> >()
                },
                new ValuePointer <G> {
                    Value = Mock.Of <IValuable <G> >()
                },
                new ValuePointer <G> {
                    Value = Mock.Of <IValuable <G> >()
                }
            };

            DefaultValueProvider <G> sut    = new DefaultValueProvider <G>();
            ICollectionValue <G>     result = sut.GetCollection(values, null);

            Assert.Equal(6, result.Size);
        }
コード例 #4
0
        public void DefaultValueProvider_GetCollection_WithCapacity()
        {
            int capacity = 20;

            DefaultValueProvider <G> sut    = new DefaultValueProvider <G>();
            ICollectionValue <G>     result = sut.GetCollection(capacity, null);

            Assert.Equal(0, result.Size);
        }