コード例 #1
0
        private static void Compare(int[][] expected, int n)
        {
            var e     = new NumberAscCombinationEnumeration(n);
            int count = 0;

            while (count < expected.Length)
            {
                Assert.IsTrue(e.MoveNext());
                int[] next        = e.Current;
                int[] expectedArr = expected[count];
                if (!Collections.AreEqual(expectedArr, next))
                {
                    Assert.Fail("Expected " + expectedArr.Render() + " Received " + next.Render() + " at index " + count);
                }
                count++;
            }

            Assert.IsFalse(e.MoveNext());
            try
            {
                Assert.That(e.Current, Is.Null); // should throw exception
                Assert.Fail();
            }
            catch (InvalidOperationException ex)
            {
                // expected
            }
        }
コード例 #2
0
        public bool Equals(IndexMultiKey other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }
            if (other.IsUnique.Equals(IsUnique) &&
                Collections.AreEqual(other.HashIndexedProps, HashIndexedProps) &&
                Collections.AreEqual(other.RangeIndexedProps, RangeIndexedProps))
            {
                if (AdvancedIndexDesc == null)
                {
                    return(other.AdvancedIndexDesc == null);
                }
                else
                {
                    return(other.AdvancedIndexDesc != null && AdvancedIndexDesc.EqualsAdvancedIndex(other.AdvancedIndexDesc));
                }
            }

            return(false);
        }
コード例 #3
0
ファイル: FilterSpecParamIn.cs プロジェクト: ikvm/nesper
        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>.
        /// </summary>
        /// <param name="obj">The <see cref="T:System.Object"></see> to compare with the current <see cref="T:System.Object"></see>.</param>
        /// <returns>
        /// true if the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>; otherwise, false.
        /// </returns>
        public override bool Equals(Object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            if (!(obj is FilterSpecParamIn))
            {
                return(false);
            }

            FilterSpecParamIn other = (FilterSpecParamIn)obj;

            if (!base.Equals(other))
            {
                return(false);
            }

            if (_listOfValues.Count != other._listOfValues.Count)
            {
                return(false);
            }

            if (!Collections.AreEqual(_listOfValues, other._listOfValues))
            {
                return(false);
            }
            return(true);
        }
コード例 #4
0
 private static void ValidateCompare(int[] one, int[] other)
 {
     if (Collections.AreEqual(one, other))
     {
         throw new GroupByRollupDuplicateException(one);
     }
 }
コード例 #5
0
        private void TryPermutation(int[] numberSet, int[][] expectedValues)
        {
            var enumeration = NumberSetShiftGroupEnumeration.New(numberSet).GetEnumerator();

            int count = 0;

            while (enumeration.MoveNext())
            {
                Log.Debug(".tryPermutation count=" + count);

                int[] result   = enumeration.Current;
                int[] expected = expectedValues[count];

                Log.Debug(".tryPermutation result=" + result.Render());
                Log.Debug(".tryPermutation expected=" + expected.Render());

                AssertSet(expected, result);

                count++;
                Assert.IsTrue(Collections.AreEqual(result, expected), "Mismatch in count=" + count);
            }
            Assert.AreEqual(count, expectedValues.Length);

            Assert.IsFalse(enumeration.MoveNext());
        }
コード例 #6
0
        public EventType AddReturnExistingAnonymousType(EventType requiredType)
        {
            lock (this)
            {
                // only EventTypeSPI compliant implementations considered
                if (!(requiredType is EventTypeSPI))
                {
                    return(requiredType);
                }

                // check recent types
                foreach (EventTypeSPI existing in _recentTypes)
                {
                    if (existing.GetType() == requiredType.GetType() &&
                        Collections.AreEqual(requiredType.PropertyNames, existing.PropertyNames) &&
                        Collections.AreEqual(requiredType.PropertyDescriptors, existing.PropertyDescriptors) &&
                        existing.EqualsCompareType(requiredType))
                    {
                        return(existing);
                    }
                }

                // add, removing the oldest
                if (_recentTypes.Count == _size && !_recentTypes.IsEmpty())
                {
                    _recentTypes.RemoveFirst();
                }
                if (_recentTypes.Count < _size)
                {
                    _recentTypes.AddLast((EventTypeSPI)requiredType);
                }
                return(requiredType);
            }
        }
コード例 #7
0
        internal Type[] KeyPropTypes; // { get; private set; }

        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>.</param>
        /// <returns>
        /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
        /// </returns>
        /// <exception cref="T:System.NullReferenceException">The <paramref name="obj"/> parameter is null.</exception>
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            HistoricalStreamIndexDesc that = (HistoricalStreamIndexDesc)obj;

            if (!Collections.AreEqual(IndexPropTypes, that.IndexPropTypes))
            {
                return(false);
            }
            if (!Collections.AreEqual(IndexProperties, that.IndexProperties))
            {
                return(false);
            }
            if (!Collections.AreEqual(KeyPropTypes, that.KeyPropTypes))
            {
                return(false);
            }

            return(true);
        }
コード例 #8
0
        private void RunAssertionCompatExisting(EPServiceProvider epService)
        {
            string epl = "insert into AvroExistingType select 1 as myLong," +
                         "{1L, 2L} as myLongArray," +
                         GetType().FullName + ".MakeByteArray() as myByteArray, " +
                         GetType().FullName + ".MakeMapStringString() as myMap " +
                         "from SupportBean";

            var schema = SchemaBuilder.Record(
                "name",
                RequiredLong("myLong"),
                Field("myLongArray", Array(LongType())),
                Field("myByteArray", BytesType()),
                Field("myMap", Map(StringType(Property(AvroConstant.PROP_STRING_KEY, AvroConstant.PROP_STRING_VALUE))))
                );

            epService.EPAdministrator.Configuration.AddEventTypeAvro("AvroExistingType", new ConfigurationEventTypeAvro(schema));

            EPStatement statement = epService.EPAdministrator.CreateEPL(epl);
            var         listener  = new SupportUpdateListener();

            statement.Events += listener.Update;

            epService.EPRuntime.SendEvent(new SupportBean());
            EventBean @event = listener.AssertOneGetNewAndReset();

            SupportAvroUtil.AvroToJson(@event);
            Assert.AreEqual(1L, @event.Get("myLong"));
            EPAssertionUtil.AssertEqualsExactOrder(new long[] { 1L, 2L }, @event.Get("myLongArray").UnwrapIntoArray <long>());
            Assert.IsTrue(Collections.AreEqual(new byte[] { 1, 2, 3 }, @event.Get("myByteArray").UnwrapIntoArray <byte>()));
            Assert.AreEqual("[k1=v1]", @event.Get("myMap").UnwrapStringDictionary().Render());

            statement.Dispose();
        }
コード例 #9
0
ファイル: CollectionUtil.cs プロジェクト: ikvm/nesper
 public static bool Compare(string[] otherIndexProps, string[] thisIndexProps)
 {
     if (otherIndexProps != null && thisIndexProps != null)
     {
         return(Collections.AreEqual(otherIndexProps, thisIndexProps));
     }
     return(otherIndexProps == null && thisIndexProps == null);
 }
コード例 #10
0
 public override bool CompareTo(ContextPartitionIdentifier other)
 {
     if (!(other is ContextPartitionIdentifierPartitioned))
     {
         return(false);
     }
     return(Collections.AreEqual(_keys, ((ContextPartitionIdentifierPartitioned)other)._keys));
 }
コード例 #11
0
        public static void TestGetPermutation()
        {
            int[] factors = PermutationEnumerator.GetFactors(4);
            int[] result  = PermutationEnumerator.GetPermutation(4, 21, factors);

            Log.Debug(".testGetPermutation result=" + result.Render());
            Assert.IsTrue(Collections.AreEqual(result, new[] { 3, 1, 2, 0 }));
        }
コード例 #12
0
ファイル: TestVariablesCreate.cs プロジェクト: ikvm/nesper
        public void TestSubscribeAndIterate()
        {
            String      stmtCreateTextOne = "create variable long var1 = null";
            EPStatement stmtCreateOne     = _epService.EPAdministrator.CreateEPL(stmtCreateTextOne);

            Assert.AreEqual(StatementType.CREATE_VARIABLE, ((EPStatementSPI)stmtCreateOne).StatementMetadata.StatementType);
            stmtCreateOne.Events += _listenerCreateOne.Update;
            String[] fieldsVar1 = new String[] { "var1" };
            EPAssertionUtil.AssertPropsPerRow(stmtCreateOne.GetEnumerator(), fieldsVar1, new Object[][] { new Object[] { null } });
            Assert.IsFalse(_listenerCreateOne.IsInvoked);

            EventType typeSet = stmtCreateOne.EventType;

            Assert.AreEqual(typeof(long?), typeSet.GetPropertyType("var1"));
            Assert.AreEqual(typeof(Map), typeSet.UnderlyingType);
            Assert.IsTrue(Collections.AreEqual(typeSet.PropertyNames, new String[] { "var1" }));

            String      stmtCreateTextTwo = "create variable long var2 = 20";
            EPStatement stmtCreateTwo     = _epService.EPAdministrator.CreateEPL(stmtCreateTextTwo);

            stmtCreateTwo.Events += _listenerCreateTwo.Update;
            String[] fieldsVar2 = new String[] { "var2" };
            EPAssertionUtil.AssertPropsPerRow(stmtCreateTwo.GetEnumerator(), fieldsVar2, new Object[][] { new Object[] { 20L } });
            Assert.IsFalse(_listenerCreateTwo.IsInvoked);

            String stmtTextSet = "on " + typeof(SupportBean).FullName + " set var1 = IntPrimitive * 2, var2 = var1 + 1";

            _epService.EPAdministrator.CreateEPL(stmtTextSet);

            SendSupportBean("E1", 100);
            EPAssertionUtil.AssertProps(_listenerCreateOne.LastNewData[0], fieldsVar1, new Object[] { 200L });
            EPAssertionUtil.AssertProps(_listenerCreateOne.LastOldData[0], fieldsVar1, new Object[] { null });
            _listenerCreateOne.Reset();
            EPAssertionUtil.AssertProps(_listenerCreateTwo.LastNewData[0], fieldsVar2, new Object[] { 201L });
            EPAssertionUtil.AssertProps(_listenerCreateTwo.LastOldData[0], fieldsVar2, new Object[] { 20L });
            _listenerCreateOne.Reset();
            EPAssertionUtil.AssertPropsPerRow(stmtCreateOne.GetEnumerator(), fieldsVar1, new Object[][] { new Object[] { 200L } });
            EPAssertionUtil.AssertPropsPerRow(stmtCreateTwo.GetEnumerator(), fieldsVar2, new Object[][] { new Object[] { 201L } });

            SendSupportBean("E2", 200);
            EPAssertionUtil.AssertProps(_listenerCreateOne.LastNewData[0], fieldsVar1, new Object[] { 400L });
            EPAssertionUtil.AssertProps(_listenerCreateOne.LastOldData[0], fieldsVar1, new Object[] { 200L });
            _listenerCreateOne.Reset();
            EPAssertionUtil.AssertProps(_listenerCreateTwo.LastNewData[0], fieldsVar2, new Object[] { 401L });
            EPAssertionUtil.AssertProps(_listenerCreateTwo.LastOldData[0], fieldsVar2, new Object[] { 201L });
            _listenerCreateOne.Reset();
            EPAssertionUtil.AssertPropsPerRow(stmtCreateOne.GetEnumerator(), fieldsVar1, new Object[][] { new Object[] { 400L } });
            EPAssertionUtil.AssertPropsPerRow(stmtCreateTwo.GetEnumerator(), fieldsVar2, new Object[][] { new Object[] { 401L } });

            stmtCreateTwo.Stop();
            stmtCreateTwo.Start();

            EPAssertionUtil.AssertPropsPerRow(stmtCreateOne.GetEnumerator(), fieldsVar1, new Object[][] { new Object[] { 400L } });
            EPAssertionUtil.AssertPropsPerRow(stmtCreateTwo.GetEnumerator(), fieldsVar2, new Object[][] { new Object[] { 20L } });
        }
コード例 #13
0
 public override bool Equals(Object other)
 {
     if (other == this)
     {
         return(true);
     }
     if (other is MultiKeyUntypedEventPair)
     {
         MultiKeyUntypedEventPair otherKeys = (MultiKeyUntypedEventPair)other;
         return(Collections.AreEqual(_keys, otherKeys._keys));
     }
     return(false);
 }
コード例 #14
0
ファイル: MultiKeyUntyped.cs プロジェクト: ikvm/nesper
 public override bool Equals(Object other)
 {
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     if (other is MultiKeyUntyped)
     {
         var otherKeys = (MultiKeyUntyped)other;
         return(Collections.AreEqual(_keys, otherKeys._keys));
     }
     return(false);
 }
コード例 #15
0
ファイル: TestQueryGraph.cs プロジェクト: ikvm/nesper
        public void TestGetProperties()
        {
            // s1.p11 = s0.p01 and s0.p02 = s1.p12
            _queryGraph.AddStrictEquals(1, "p11", Make(1, "p11"), 0, "p01", Make(0, "p01"));
            _queryGraph.AddStrictEquals(0, "p02", Make(0, "p02"), 1, "p12", Make(1, "p12"));
            Log.Debug(_queryGraph.ToString());

            String[] expectedOne = new String[] { "p11", "p12" };
            String[] expectedTwo = new String[] { "p01", "p02" };
            Assert.IsTrue(Collections.AreEqual(expectedTwo, QueryGraphTestUtil.GetIndexProperties(_queryGraph, 1, 0)));
            Assert.IsTrue(Collections.AreEqual(expectedOne, QueryGraphTestUtil.GetIndexProperties(_queryGraph, 0, 1)));
            Assert.IsTrue(Collections.AreEqual(expectedOne, QueryGraphTestUtil.GetStrictKeyProperties(_queryGraph, 1, 0)));
            Assert.IsTrue(Collections.AreEqual(expectedTwo, QueryGraphTestUtil.GetStrictKeyProperties(_queryGraph, 0, 1)));
        }
コード例 #16
0
        public void TestBuildDefaultNestingOrder()
        {
            int[] result = NStreamQueryPlanBuilder.BuildDefaultNestingOrder(4, 0);
            Assert.IsTrue(Collections.AreEqual(result, new int[] { 1, 2, 3 }));

            result = NStreamQueryPlanBuilder.BuildDefaultNestingOrder(4, 1);
            Assert.IsTrue(Collections.AreEqual(result, new int[] { 0, 2, 3 }));

            result = NStreamQueryPlanBuilder.BuildDefaultNestingOrder(4, 2);
            Assert.IsTrue(Collections.AreEqual(result, new int[] { 0, 1, 3 }));

            result = NStreamQueryPlanBuilder.BuildDefaultNestingOrder(4, 3);
            Assert.IsTrue(Collections.AreEqual(result, new int[] { 0, 1, 2 }));
        }
コード例 #17
0
 public bool Equals(IndexMultiKey other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(other.IsUnique.Equals(IsUnique) &&
            Collections.AreEqual(other.HashIndexedProps, HashIndexedProps) &&
            Collections.AreEqual(other.RangeIndexedProps, RangeIndexedProps));
 }
コード例 #18
0
ファイル: CollectionUtil.cs プロジェクト: ikvm/nesper
 public static bool SortCompare(string[] valuesOne, string[] valuesTwo)
 {
     if (valuesOne == null)
     {
         return(valuesTwo == null);
     }
     if (valuesTwo == null)
     {
         return(false);
     }
     string[] copyOne = CopySortArray(valuesOne);
     string[] copyTwo = CopySortArray(valuesTwo);
     return(Collections.AreEqual(copyOne, copyTwo));
 }
コード例 #19
0
        public override bool Equals(Object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (o == null || GetType() != o.GetType())
            {
                return(false);
            }

            var that = (MultiKeyInt)o;

            return(Collections.AreEqual(_keys, that._keys));
        }
コード例 #20
0
        public void TestComputeBestPath()
        {
            NStreamQueryPlanBuilder.BestChainResult bestChain = NStreamQueryPlanBuilder.ComputeBestPath(
                0, _queryGraph, _dependencyGraph);
            Assert.AreEqual(3, bestChain.Depth);
            Assert.IsTrue(Collections.AreEqual(bestChain.Chain, new int[] { 2, 4, 3, 1 }));

            bestChain = NStreamQueryPlanBuilder.ComputeBestPath(3, _queryGraph, _dependencyGraph);
            Assert.AreEqual(4, bestChain.Depth);
            Assert.IsTrue(Collections.AreEqual(bestChain.Chain, new int[] { 4, 2, 0, 1 }));

            // try a stream that is not connected in any way
            _queryGraph = new QueryGraph(6, null, false);
            bestChain   = NStreamQueryPlanBuilder.ComputeBestPath(5, _queryGraph, _dependencyGraph);
            Log.Debug(".testComputeBestPath bestChain=" + bestChain);
            Assert.AreEqual(0, bestChain.Depth);
            Assert.IsTrue(Collections.AreEqual(bestChain.Chain, new int[] { 0, 1, 2, 3, 4 }));
        }
コード例 #21
0
        public static void TestGetFactors()
        {
            int[] factors = PermutationEnumerator.GetFactors(5);
            Assert.IsTrue(Collections.AreEqual(factors, new[] { 24, 6, 2, 1, 0 }));

            factors = PermutationEnumerator.GetFactors(4);
            Assert.IsTrue(Collections.AreEqual(factors, new[] { 6, 2, 1, 0 }));

            factors = PermutationEnumerator.GetFactors(3);
            Assert.IsTrue(Collections.AreEqual(factors, new[] { 2, 1, 0 }));

            factors = PermutationEnumerator.GetFactors(2);
            Assert.IsTrue(Collections.AreEqual(factors, new[] { 1, 0 }));

            factors = PermutationEnumerator.GetFactors(1);
            Assert.IsTrue(Collections.AreEqual(factors, new[] { 0 }));

            //Log.Debug(".testGetFactors " + CompatExtensions.Render(factors));
        }
コード例 #22
0
        /// <summary>
        /// Compare the objects in the two 2-dim String arrays assuming the exact same
        /// order.
        /// </summary>
        /// <param name="data">is the data to assertEqualsExactOrder against</param>
        /// <param name="expectedValues">is the expected values</param>
        public static void AssertEqualsStringArr(String[][] data, String[][] expectedValues)
        {
            if ((expectedValues == null) && (data == null))
            {
                return;
            }
            if (((expectedValues == null) && (data != null)) ||
                ((expectedValues != null) && (data == null)))
            {
                Assert.Fail();
            }

            Assert.AreEqual(expectedValues.Length, data.Length, "mismatch in number to elements");

            for (int i = 0; i < expectedValues.Length; i++)
            {
                Assert.IsTrue(Collections.AreEqual(data[i], expectedValues[i]));
            }
        }
コード例 #23
0
        public void TestLookup()
        {
            List <QueryGraphValueEntryHashKeyed> keys = new List <QueryGraphValueEntryHashKeyed>();

            keys.Add(new QueryGraphValueEntryHashKeyedProp(new ExprIdentNodeImpl(_types[0], "IntBoxed", 0), "IntBoxed"));
            IndexedTableLookupPlanMulti spec = new IndexedTableLookupPlanMulti(0, 1, new TableLookupIndexReqKey("idx1"), keys);

            IDictionary <TableLookupIndexReqKey, EventTable>[] indexes = new IDictionary <TableLookupIndexReqKey, EventTable> [2];
            indexes[0] = new Dictionary <TableLookupIndexReqKey, EventTable>();
            indexes[1] = new Dictionary <TableLookupIndexReqKey, EventTable>();
            indexes[1][new TableLookupIndexReqKey("idx1")] = _propertyMapEventIndex;

            JoinExecTableLookupStrategy lookupStrategy = spec.MakeStrategy("ABC", "001", null, indexes, _types, new VirtualDWView[2]);

            IndexedTableLookupStrategy strategy = (IndexedTableLookupStrategy)lookupStrategy;

            Assert.AreEqual(_types[0], strategy.EventType);
            Assert.AreEqual(_propertyMapEventIndex, strategy.Index);
            Assert.IsTrue(Collections.AreEqual(new String[] { "IntBoxed" }, strategy.Properties));
        }
コード例 #24
0
ファイル: TestQueryGraph.cs プロジェクト: ikvm/nesper
        public void TestFillEquivalency()
        {
            // test with just 3 streams
            _queryGraph.AddStrictEquals(0, "p00", Make(0, "p00"), 1, "p10", Make(1, "p10"));
            _queryGraph.AddStrictEquals(1, "p10", Make(1, "p10"), 2, "p20", Make(2, "p20"));

            Assert.IsFalse(_queryGraph.IsNavigableAtAll(0, 2));
            Assert.AreEqual(0, QueryGraphTestUtil.GetStrictKeyProperties(_queryGraph, 0, 2).Count);
            Assert.AreEqual(0, QueryGraphTestUtil.GetIndexProperties(_queryGraph, 0, 2).Count);

            QueryGraph.FillEquivalentNav(_types, _queryGraph);

            Assert.IsTrue(_queryGraph.IsNavigableAtAll(0, 2));
            String[] expectedOne = new String[] { "p00" };
            String[] expectedTwo = new String[] { "p20" };
            Assert.IsTrue(Collections.AreEqual(expectedOne, QueryGraphTestUtil.GetStrictKeyProperties(_queryGraph, 0, 2)));
            Assert.IsTrue(Collections.AreEqual(expectedTwo, QueryGraphTestUtil.GetIndexProperties(_queryGraph, 0, 2)));

            // test with 5 streams, connect all streams to all streams
            _queryGraph = new QueryGraph(5, null, false);
            _queryGraph.AddStrictEquals(0, "p0", Make(0, "p0"), 1, "p1", Make(1, "p1"));
            _queryGraph.AddStrictEquals(3, "p3", Make(3, "p3"), 4, "p4", Make(4, "p4"));
            _queryGraph.AddStrictEquals(2, "p2", Make(2, "p2"), 3, "p3", Make(3, "p3"));
            _queryGraph.AddStrictEquals(1, "p1", Make(1, "p1"), 2, "p2", Make(2, "p2"));

            QueryGraph.FillEquivalentNav(_types, _queryGraph);

            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }
                    Assert.IsTrue(_queryGraph.IsNavigableAtAll(i, j), "Not navigable: i=" + i + " j=" + j);
                }
            }
        }
コード例 #25
0
        public void TestCopySort()
        {
            var testdata = new Object[][] {
                new Object[] { new String[] { "a", "b" }, new String[] { "a", "b" } },
                new Object[] { new String[] { "b", "a" }, new String[] { "a", "b" } },
                new Object[] { new String[] { "a" }, new String[] { "a" } },
                new Object[] { new String[] { "c", "b", "a" }, new String[] { "a", "b", "c" } },
                new Object[] { new String[0], new String[0] },
            };

            for (var i = 0; i < testdata.Length; i++)
            {
                var expected = (String[])testdata[i][1];
                var input    = (String[])testdata[i][0];
                var received = CollectionUtil.CopySortArray(input);
                if (!Collections.AreEqual(expected, received))
                {
                    Assert.Fail("Failed for input " + input.Render() + " expected " + expected.Render() + " received " + received.Render());
                }
                Assert.AreNotSame(input, expected);
            }
        }
コード例 #26
0
        public void TestCompare()
        {
            var testdata = new Object[][] {
                new Object[] { new String[] { "a", "b" }, new String[] { "a", "b" }, true },
                new Object[] { new String[] { "a" }, new String[] { "a", "b" }, false },
                new Object[] { new String[] { "a" }, new String[] { "a" }, true },
                new Object[] { new String[] { "b" }, new String[] { "a" }, false },
                new Object[] { new String[] { "b", "a" }, new String[] { "a", "b" }, true },
                new Object[] { new String[] { "a", "b", "b" }, new String[] { "a", "b" }, false },
                new Object[] { new String[] { "a", "b", "b" }, new String[] { "b", "a", "b" }, true },
                new Object[] { new String[0], new String[0], true },
            };

            for (var i = 0; i < testdata.Length; i++)
            {
                var left     = (String[])testdata[i][0];
                var right    = (String[])testdata[i][1];
                var expected = testdata[i][2].AsBoolean();
                Assert.AreEqual(expected, CollectionUtil.SortCompare(left, right), "Failed for input " + left.Render());
                Assert.IsTrue(Collections.AreEqual(left, (String[])testdata[i][0]));
                Assert.IsTrue(Collections.AreEqual(right, (String[])testdata[i][1]));
            }
        }
コード例 #27
0
        private void RunAssertionNewSchema(EPServiceProvider epService)
        {
            string epl = EventRepresentationChoice.AVRO.GetAnnotationText() + " select 1 as myInt," +
                         "{1L, 2L} as myLongArray," +
                         GetType().FullName + ".MakeByteArray() as myByteArray, " +
                         GetType().FullName + ".MakeMapStringString() as myMap " +
                         "from SupportBean";

            EPStatement statement = epService.EPAdministrator.CreateEPL(epl);
            var         listener  = new SupportUpdateListener();

            statement.Events += listener.Update;

            epService.EPRuntime.SendEvent(new SupportBean());
            EventBean @event = listener.AssertOneGetNewAndReset();
            string    json   = SupportAvroUtil.AvroToJson(@event);

            Assert.AreEqual(1, @event.Get("myInt"));
            EPAssertionUtil.AssertEqualsExactOrder(new long[] { 1L, 2L }, @event.Get("myLongArray").UnwrapIntoArray <long>());
            Assert.IsTrue(Collections.AreEqual(new byte[] { 1, 2, 3 }, @event.Get("myByteArray").UnwrapIntoArray <byte>()));
            Assert.AreEqual("[k1=v1]", @event.Get("myMap").UnwrapStringDictionary().Render());

            var designSchema = SchemaBuilder.Record(
                "name",
                RequiredInt("myInt"),
                Field("myLongArray", Array(Union(NullType(), LongType()))),
                Field("myByteArray", BytesType()),
                Field("myMap", Map(StringType(Property(AvroConstant.PROP_STRING_KEY, AvroConstant.PROP_STRING_VALUE))))
                );
            Schema assembledSchema = ((AvroEventType)@event.EventType).SchemaAvro;
            string compareMsg      = SupportAvroUtil.CompareSchemas(designSchema, assembledSchema);

            Assert.IsNull(compareMsg, compareMsg);

            statement.Dispose();
        }
コード例 #28
0
        public override IList <int[]> Evaluate(GroupByRollupEvalContext context)
        {
            IList <int[]> rollup = new List <int[]>();

            foreach (GroupByRollupNodeBase node in this.ChildNodes)
            {
                IList <int[]> result = node.Evaluate(context);

                // find dups
                foreach (var row in result)
                {
                    foreach (var existing in rollup)
                    {
                        if (Collections.AreEqual(row, existing))
                        {
                            throw new GroupByRollupDuplicateException(row);
                        }
                    }
                }

                rollup.AddAll(result);
            }
            return(rollup);
        }
コード例 #29
0
        public static void AssertEqualsAnyOrder(IEnumerator <EventBean> enumerator, String[] propertyNames,
                                                Object[][] propertiesListPerRow)
        {
            // convert to array of events
            EventBean[] received = EnumeratorToArray(enumerator);
            if (propertiesListPerRow == null)
            {
                if ((received == null) || (received.Length == 0))
                {
                    return;
                }
                Assert.Fail("Expected no results but received " + received.Length + " events");
            }
            Assert.AreEqual(propertiesListPerRow.Length, received.Length);

            // build map of event and values
            IDictionary <EventBean, Object[]> valuesEachEvent = new Dictionary <EventBean, Object[]>();

            for (int i = 0; i < received.Length; i++)
            {
                var values = new Object[propertyNames.Length];
                for (int j = 0; j < propertyNames.Length; j++)
                {
                    values[j] = received[i].Get(propertyNames[j]);
                }
                valuesEachEvent.Put(received[i], values);
            }

            // Find each list of properties
            for (int i = 0; i < propertiesListPerRow.Length; i++)
            {
                Object[] propertiesThisRow = propertiesListPerRow[i];
                bool     isFound           = false;

                foreach (var entry in valuesEachEvent)
                {
                    if (Collections.AreEqual(entry.Value, propertiesThisRow))
                    {
                        valuesEachEvent[entry.Key] = null;
                        //entry.Value = null;
                        isFound = true;
                        break;
                    }
                }

                if (!isFound)
                {
                    String text = "Error finding property set: " + propertiesListPerRow[i].Render() +
                                  " among values: \n" + Dump(valuesEachEvent);
                    Assert.Fail(text);
                }
            }

            // Should be all null values
            foreach (var entry in valuesEachEvent)
            {
                if (entry.Value != null)
                {
                    Assert.Fail();
                }
            }
        }
コード例 #30
0
        public override bool EqualsNode(ExprNode node)
        {
            var other = node as ExprInstanceofNode;

            return(other != null && Collections.AreEqual(other._classIdentifiers, _classIdentifiers));
        }