private void AssertItem <T>(IObjectContainer container, object objExpected, object objActual, T updateValue)
        {
            Item <T> expected = (Item <T>)objExpected;
            Item <T> actual   = (Item <T>)objActual;

            Assert.AreEqual(expected.name, actual.name);

            Iterator4Assert.AreEqual(
                EnumeratorFor(expected.typed),
                EnumeratorFor(actual.typed));

            Iterator4Assert.AreEqual(
                EnumeratorFor(expected.typedInterface),
                EnumeratorFor(actual.typedInterface));

            Iterator4Assert.AreEqual(
                EnumeratorFor(expected.untyped),
                EnumeratorFor(actual.untyped));

            Iterator4Assert.AreEqual(
                EnumeratorFor(expected.untypedEnumerable),
                EnumeratorFor(actual.untypedEnumerable));


            AssertQuery(container, actual);
        }
 public virtual void TestDuplicateEntry()
 {
     _map.Put(new IdentityHashtable4TestCase.Item(Key), Key);
     _map.Put(new IdentityHashtable4TestCase.Item(Key), Key);
     Iterator4Assert.AreEqual(new object[] { Key, Key }, _map.Values().GetEnumerator()
                              );
 }
Ejemplo n.º 3
0
            public void Test()
            {
                IDictionary actual = RetrieveOnlyInstance <Item>().dictionary;

                Iterator4Assert.AreEqual(Subject().Values, actual.Values);
                Iterator4Assert.AreEqual(Subject().Keys, actual.Keys);
            }
Ejemplo n.º 4
0
        public void test()
        {
            Item item = (Item)RetrieveOnlyInstance(typeof(Item));

            Assert.IsNotNull(item.nullableList);
            Iterator4Assert.AreEqual(nullableIntList1().GetEnumerator(), item.nullableList.GetEnumerator());
        }
Ejemplo n.º 5
0
        public virtual void TestIterator()
        {
            string[]    expected = new string[] { "1", "2", "3" };
            Collection4 c        = NewCollection(expected);

            Iterator4Assert.AreEqual(expected, c.GetEnumerator());
        }
 private static void AssertItemArray(IEnumerable[] expected, IEnumerable[] actual)
 {
     Assert.AreEqual(expected.Length, actual.Length);
     for (int i = 0; i < expected.Length; i++)
     {
         Iterator4Assert.AreEqual(expected[i].GetEnumerator(), actual[i].GetEnumerator());
     }
 }
Ejemplo n.º 7
0
        public virtual void TestFlatten()
        {
            IEnumerator iterator = Iterate(new object[] { "1", "2", Iterate(new object[] { Iterate
                                                                                               (new object[] { "3", "4" }), Iterators.EmptyIterator, Iterators.EmptyIterator, "5" }), Iterators.EmptyIterator, "6" });

            Iterator4Assert.AreEqual(new object[] { "1", "2", "3", "4", "5", "6" }, Iterators
                                     .Flatten(iterator));
        }
Ejemplo n.º 8
0
 private void AssertConverterBehaviorForVersion(int converterVersion)
 {
     ConverterTestCase.RecordingStage stage = new ConverterTestCase.RecordingStage(converterVersion
                                                                                   );
     Converter.Convert(stage);
     Iterator4Assert.AreEqual(Iterators.Iterator(ExpectedConversionsFor(converterVersion
                                                                        )), Iterators.Iterator(stage.Conversions()));
 }
Ejemplo n.º 9
0
        private void AssertPath(object t, object expression, string[] expected)
        {
            var path = _prototypes.BackingFieldPath(t.GetType(), expression
                                                    );

            // print(Iterators.join(path, "[", "]", ", "));
            path.Reset();
            Iterator4Assert.AreEqual(expected, path);
        }
Ejemplo n.º 10
0
 public virtual void TestRange()
 {
     Iterator4Assert.AreEqual(new object[] {}, Iterators.Range(1, 1));
     Iterator4Assert.AreEqual(new object[] { 1 }, Iterators.Range(1, 2));
     Iterator4Assert.AreEqual(new object[] { 1, 2 }, Iterators.Range(1, 3));
     Iterator4Assert.AreEqual(new object[] { -2, -1, 0, 1, 2 }, Iterators.Range(-2, 3)
                              );
     Assert.Expect(typeof(ArgumentException), new _ICodeBlock_24());
 }
Ejemplo n.º 11
0
        public override void EnsureContent(ITestableReplicationProviderInside provider)
        {
            Container replicated = (Container)QueryItem(provider, typeof(Container));
            Container expected   = (Container)CreateItem();

            Assert.AreNotSame(expected, replicated);
            Assert.AreEqual(expected._name, replicated._name);
            Iterator4Assert.AreEqual(expected._items.GetEnumerator(), replicated._items.GetEnumerator());
        }
 private void AssertSingleEntry(IdentityHashtable4TestCase.Item key, int value)
 {
     Assert.IsTrue(_map.ContainsKey(key));
     Assert.IsFalse(_map.ContainsKey(new IdentityHashtable4TestCase.Item(value)));
     Assert.AreEqual(value, _map.Get(key));
     Assert.IsNull(_map.Get(new IdentityHashtable4TestCase.Item(value)));
     Assert.AreEqual(1, _map.Size());
     Iterator4Assert.AreEqual(new object[] { value }, _map.Values().GetEnumerator());
 }
        private void AssertSort()
        {
            Person[] expectedOrder = (Person[])Persons.Clone();
            Array.Sort(expectedOrder, Person.SortByYear);

            Iterator4Assert.AreEqual(
                expectedOrder,
                _client.Query(Person.SortByYear).GetEnumerator());
        }
Ejemplo n.º 14
0
        public void TestProduceWithEqualityComparer()
        {
            var cache4  = CacheFactory.NewLRUCache(2);
            var subject = CacheFactory <string, int> .For(cache4, StringComparer.CurrentCultureIgnoreCase);

            Assert.AreEqual(42, subject.Produce("foo", key => 42));
            Assert.AreEqual(42, subject.Produce("FOO", key => - 1));

            Iterator4Assert.AreEqual(new object[] { 42 }, cache4);
        }
Ejemplo n.º 15
0
        public virtual void TestLabel()
        {
            FixtureBasedTestSuite suite  = new _FixtureBasedTestSuite_142();
            IEnumerable           labels = Iterators.Map(suite, new _IFunction4_154());

            Iterator4Assert.AreEqual(new object[] { TestLabel("testFoo", 0, 0), TestLabel("testFoo"
                                                                                          , 1, 0), TestLabel("testFoo", 0, 1), TestLabel("testFoo", 1, 1), TestLabel("testBar"
                                                                                                                                                                     , 0, 0), TestLabel("testBar", 1, 0), TestLabel("testBar", 0, 1), TestLabel("testBar"
                                                                                                                                                                                                                                                , 1, 1) }, labels.GetEnumerator());
        }
Ejemplo n.º 16
0
        public virtual void TestCrossProduct()
        {
            IEnumerable[] source = new IEnumerable[] { Iterable(new object[] { "1", "2" }), Iterable
                                                           (new object[] { "3", "4" }), Iterable(new object[] { "5", "6" }) };
            string[] expected = new string[] { "[1, 3, 5]", "[1, 3, 6]", "[1, 4, 5]", "[1, 4, 6]"
                                               , "[2, 3, 5]", "[2, 3, 6]", "[2, 4, 5]", "[2, 4, 6]" };
            IEnumerator iterator = Iterators.CrossProduct(source).GetEnumerator();

            Iterator4Assert.AreEqual(expected, Iterators.Map(iterator, new _IFunction4_75()));
        }
Ejemplo n.º 17
0
        private void AssertOrderBy(Comparison <object> comparison, Action <IQuery> setOrderBy)
        {
            _items.Sort(comparison);
            IQuery query = NewQuery(ItemVariable().Type());

            setOrderBy(query.Descend("_value"));

            Iterator4Assert.AreEqual(
                _items.ToArray(),
                query.Execute().GetEnumerator());
        }
Ejemplo n.º 18
0
        public virtual void TestSeries()
        {
            Collection4 calls  = new Collection4();
            IEnumerator series = Iterators.Series(string.Empty, new _IFunction4_11(calls)).GetEnumerator
                                     ();

            Assert.IsTrue(series.MoveNext());
            Assert.IsTrue(series.MoveNext());
            Iterator4Assert.AreEqual(new object[] { string.Empty, "*" }, calls.GetEnumerator(
                                         ));
        }
Ejemplo n.º 19
0
        private void AssertQuery(int[] expectedItemIds, SodaQueryComparator.Ordering[] orderings
                                 )
        {
            long[] ids = NewQuery(typeof(SodaQueryComparatorTestCase.Item)).Execute().Ext().GetIDs
                             ();
            IList sorted = new SodaQueryComparator(FileSession(), typeof(SodaQueryComparatorTestCase.Item
                                                                         ), orderings).Sort(ids);

            Iterator4Assert.AreEqual(Iterators.Map(expectedItemIds, oidByItemId), Iterators.Iterator
                                         (sorted));
        }
Ejemplo n.º 20
0
        private void AssertQueryEvents(IRunnable query)
        {
            var events        = new ArrayList();
            var eventRegistry = EventRegistryFactory.ForObjectContainer(FileSession
                                                                            ());

            eventRegistry.QueryStarted  += new _IEventListener4_40(events).OnEvent;
            eventRegistry.QueryFinished += new _IEventListener4_45(events).OnEvent;
            query.Run();
            string[] expected = { QueryStarted, QueryFinished };
            Iterator4Assert.AreEqual(expected, Iterators.Iterator(events));
        }
Ejemplo n.º 21
0
            public virtual void Test()
            {
                ItemWithUntypedField item = new ItemWithUntypedField(Subject());

                StoreToProviderA(item);
                ReplicatedAllToB();
                ItemWithUntypedField replicated = ReplicatedItem();

                Assert.IsNotNull(replicated.Array());
                Iterator4Assert.AreEqual(ArrayIterator(item.Array()), ArrayIterator(replicated.Array
                                                                                        ()));
            }
Ejemplo n.º 22
0
 private void AssertList <T, S>(IList <T> expected, IList <S> actual)
 {
     if (expected != null)
     {
         Assert.IsNotNull(actual);
         Iterator4Assert.AreEqual(expected.GetEnumerator(), actual.GetEnumerator());
     }
     else
     {
         Assert.IsNull(actual);
     }
 }
Ejemplo n.º 23
0
        private void AssertQueryEvents(IRunnable query)
        {
            ArrayList      events        = new ArrayList();
            IEventRegistry eventRegistry = EventRegistryFactory.ForObjectContainer(FileSession
                                                                                       ());

            eventRegistry.QueryStarted += new System.EventHandler <Db4objects.Db4o.Events.QueryEventArgs>
                                              (new _IEventListener4_40(events).OnEvent);
            eventRegistry.QueryFinished += new System.EventHandler <Db4objects.Db4o.Events.QueryEventArgs>
                                               (new _IEventListener4_45(events).OnEvent);
            query.Run();
            string[] expected = new string[] { QueryStarted, QueryFinished };
            Iterator4Assert.AreEqual(expected, Iterators.Iterator(events));
        }
 public virtual void TestClear()
 {
     IdentityHashtable4TestCase.Item key1 = new IdentityHashtable4TestCase.Item(Key);
     IdentityHashtable4TestCase.Item key2 = new IdentityHashtable4TestCase.Item(Key +
                                                                                1);
     _map.Put(key1, Key);
     _map.Put(key2, Key + 1);
     _map.Clear();
     Assert.IsFalse(_map.ContainsKey(key1));
     Assert.IsFalse(_map.ContainsKey(key2));
     Assert.IsNull(_map.Get(key1));
     Assert.IsNull(_map.Get(key2));
     Assert.AreEqual(0, _map.Size());
     Iterator4Assert.AreEqual(new object[] {  }, _map.Values().GetEnumerator());
 }
Ejemplo n.º 25
0
        public virtual void TestRemove()
        {
            var key1 = new Item(Key);
            var key2 = new Item(Key +
                                1);

            _map.Put(key1, Key);
            _map.Put(key2, Key + 1);
            Assert.AreEqual(Key, _map.Remove(key1));
            Assert.IsFalse(_map.ContainsKey(key1));
            Assert.IsTrue(_map.ContainsKey(key2));
            Assert.IsNull(_map.Get(key1));
            Assert.AreEqual(Key + 1, _map.Get(key2));
            Assert.AreEqual(1, _map.Size());
            Iterator4Assert.AreEqual(new object[] { Key + 1 }, _map.Values().GetEnumerator());
        }
Ejemplo n.º 26
0
 private void AssertDictionary <T, S>(IDictionary <T, T> expected, IDictionary <S, S> actual)
 {
     if (expected != null)
     {
         Assert.IsNotNull(actual);
         Iterator4Assert.AreEqual(expected.GetEnumerator(), actual.GetEnumerator());
         foreach (var key in expected.Keys)
         {
             Assert.AreEqual(key, expected[key]);
         }
     }
     else
     {
         Assert.IsNull(actual);
     }
 }
        public void Test()
        {
            object list = new LinkedList <int>();
            ICollectionInitializer initializer = CollectionInitializer.For(list);

            Assert.IsNotNull(initializer);

            foreach (object item in Values)
            {
                initializer.Add(item);
            }

            initializer.FinishAdding();

            Iterator4Assert.AreEqual(Values, ((IEnumerable)list).GetEnumerator());
        }
Ejemplo n.º 28
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestClose()
        {
            var container = Db();
            var session   = FileSession();
            var actual    = new Collection4();

            EventRegistry().Closing += new _IEventListener4_21(actual).OnEvent;
            Fixture().Close();
            if (IsEmbedded())
            {
                Iterator4Assert.AreEqual(new object[] { container, session }, actual.GetEnumerator
                                             ());
            }
            else
            {
                Assert.AreSame(container, actual.SingleElement());
            }
        }
        /// <exception cref="System.Exception"></exception>
        public virtual void TestClose()
        {
            IExtObjectContainer  container = Db();
            LocalObjectContainer session   = FileSession();
            Collection4          actual    = new Collection4();

            EventRegistry().Closing += new System.EventHandler <Db4objects.Db4o.Events.ObjectContainerEventArgs>
                                           (new _IEventListener4_21(actual).OnEvent);
            Fixture().Close();
            if (IsEmbedded())
            {
                Iterator4Assert.AreEqual(new object[] { container, session }, actual.GetEnumerator
                                             ());
            }
            else
            {
                Assert.AreSame(container, actual.SingleElement());
            }
        }
        public virtual void TestClientConnectedEvent()
        {
            ArrayList           connections = new ArrayList();
            IObjectServerEvents events      = (IObjectServerEvents)server;

            events.ClientConnected += new System.EventHandler <ClientConnectionEventArgs>(new
                                                                                          _IEventListener4_83(connections).OnEvent);
            IObjectContainer client = OpenClient();

            try
            {
                Assert.AreEqual(1, connections.Count);
                Iterator4Assert.AreEqual(ServerMessageDispatchers(), Iterators.Iterator(connections
                                                                                        ));
            }
            finally
            {
                client.Close();
            }
        }