public void TestInvalid() { EventType parentType = SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)); try { _factory.SetViewParameters(null, TestViewSupport.ToExprListBean(new Object[] { 50, 20 })); _factory.Attach(parentType, SupportStatementContextFactory.MakeContext(), null, null); Assert.Fail(); } catch (ViewParameterException ex) { // expected } try { _factory.SetViewParameters(null, TestViewSupport.ToExprListBean(new Object[] { "TheString", 20 })); _factory.Attach(parentType, SupportStatementContextFactory.MakeContext(), null, null); Assert.Fail(); } catch (ViewParameterException ex) { // expected } _factory.SetViewParameters(null, TestViewSupport.ToExprListBean(new Object[] { "LongPrimitive", 20 })); _factory.Attach(parentType, SupportStatementContextFactory.MakeContext(), null, null); Assert.AreSame(parentType, _factory.EventType); }
public void TestMake() { Assert.IsTrue(_service.Create(new PatternGuardSpec("g", "h", TestViewSupport.ToExprListBean(new Object[] { 100 }))) is SupportGuardFactory); Assert.IsTrue(_service.Create(new PatternObserverSpec("a", "b", TestViewSupport.ToExprListBean(new Object[] { 100 }))) is SupportObserverFactory); Assert.IsTrue(_service.Create(new PatternGuardSpec("timer", "within", TestViewSupport.ToExprListBean(new Object[] { 100 }))) is TimerWithinGuardFactory); Assert.IsTrue(_service.Create(new PatternObserverSpec("timer", "interval", TestViewSupport.ToExprListBean(new Object[] { 100 }))) is TimerIntervalObserverFactory); }
public void TestCanReuse() { AgentInstanceContext agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceContext(); _factory.SetViewParameters(null, TestViewSupport.ToExprListBean(new Object[] { "IntPrimitive" })); _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)), SupportStatementContextFactory.MakeContext(), null, null); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null), agentInstanceContext)); }
public void TestAttaches() { // Should attach to anything as long as the fields exists EventType parentType = SupportEventTypeFactory.CreateBeanType( typeof(SupportBean)); _factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListBean(new Object[] { "IntBoxed" })); _factory.Attach(parentType, SupportStatementContextFactory.MakeContext(_container), null, null); }
public void TestIntervalWait() { var factory = new TimerIntervalObserverFactory(); factory.SetObserverParameters(TestViewSupport.ToExprListBean(new Object[] { 1 }), new SupportMatchedEventConvertor(), null); var eventObserver = factory.MakeObserver(_patternContext, null, new SupportObserverEventEvaluator(_patternContext), null, null, false); Assert.IsTrue(eventObserver is TimerIntervalObserver); }
private void TryParameter(Object param, String fieldName) { UniqueByPropertyViewFactory factory = new UniqueByPropertyViewFactory(); factory.SetViewParameters(null, TestViewSupport.ToExprListBean(new Object[] { param })); factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)), SupportStatementContextFactory.MakeContext(), null, null); UniqueByPropertyView view = (UniqueByPropertyView)factory.MakeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()); Assert.AreEqual(fieldName, view.CriteriaExpressions[0].ToExpressionStringMinPrecedenceSafe()); }
private void TryParameter(Object[] parameters, String[] fieldNames) { var factory = new GroupByViewFactory(); factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListBean(parameters)); factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)), SupportStatementContextFactory.MakeContext(_container), null, null); var view = (GroupByView)factory.MakeView( SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(_container)); Assert.AreEqual(fieldNames[0], view.CriteriaExpressions[0].ToExpressionStringMinPrecedenceSafe()); }
public void TestCanReuse() { AgentInstanceContext agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceContext(_container); _factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListBean(new Object[] { "TheString", "LongPrimitive" })); _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)), SupportStatementContextFactory.MakeContext(_container), null, null); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null), agentInstanceContext)); Assert.IsFalse(_factory.CanReuse(new GroupByViewImpl(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(_container), SupportExprNodeFactory.MakeIdentNodesBean("TheString"), null), agentInstanceContext)); Assert.IsTrue(_factory.CanReuse(new GroupByViewImpl(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(_container), SupportExprNodeFactory.MakeIdentNodesBean("TheString", "LongPrimitive"), null), agentInstanceContext)); _factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListBean(new Object[] { SupportExprNodeFactory.MakeIdentNodesBean("TheString", "LongPrimitive") })); Assert.IsFalse(_factory.CanReuse(new GroupByViewImpl(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(_container), SupportExprNodeFactory.MakeIdentNodesBean("TheString"), null), agentInstanceContext)); Assert.IsTrue(_factory.CanReuse(new GroupByViewImpl(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(_container), SupportExprNodeFactory.MakeIdentNodesBean("TheString", "LongPrimitive"), null), agentInstanceContext)); }
private void TryInvalidParameter(Object param) { try { UniqueByPropertyViewFactory factory = new UniqueByPropertyViewFactory(); factory.SetViewParameters(null, TestViewSupport.ToExprListBean(new Object[] { param })); factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)), SupportStatementContextFactory.MakeContext(_container), null, null); Assert.Fail(); } catch (ViewParameterException) { // expected } }
private void TryInvalidParameter(Object[] param) { try { ExternallyTimedWindowViewFactory factory = new ExternallyTimedWindowViewFactory(); factory.SetViewParameters(null, TestViewSupport.ToExprListBean(new Object[] { param })); factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)), SupportStatementContextFactory.MakeContext(), null, null); Assert.Fail(); } catch (ViewParameterException ex) { // expected } }
private void TryInvalidParameter(Object[] parameters) { try { var factory = new GroupByViewFactory(); factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListBean(parameters)); factory.Attach( SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)), SupportStatementContextFactory.MakeContext(_container), null, null); Assert.Fail(); } catch (ViewParameterException) { // expected } }
public void TestCanReuse() { AgentInstanceContext agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceContext(_container); _factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(_container), TestViewSupport.ToExprListBean(new Object[] { 1000 })); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null), agentInstanceContext)); Assert.IsFalse(_factory.CanReuse(new TimeBatchView(null, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(_container), new ExprTimePeriodEvalDeltaConstGivenDelta(1000), null, false, false, null), agentInstanceContext)); Assert.IsTrue(_factory.CanReuse(new TimeWindowView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(_container), _factory, new ExprTimePeriodEvalDeltaConstGivenDelta(1000000), null), agentInstanceContext)); }
private void TryParameter(Object[] @params, String fieldName, long msec) { ExternallyTimedWindowViewFactory factory = new ExternallyTimedWindowViewFactory(); factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(), TestViewSupport.ToExprListBean(@params)); factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)), SupportStatementContextFactory.MakeContext(), null, null); ExternallyTimedWindowView view = (ExternallyTimedWindowView)factory.MakeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()); Assert.AreEqual(fieldName, view.TimestampExpression.ToExpressionStringMinPrecedenceSafe()); Assert.IsTrue(new ExprTimePeriodEvalDeltaConstGivenDelta(msec).EqualsTimePeriod(view.TimeDeltaComputation)); }
public void TestCanReuse() { EventType parentType = SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)); AgentInstanceContext agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceContext(); _factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(), TestViewSupport.ToExprListBean(new Object[] { "LongBoxed", 1000 })); _factory.Attach(parentType, SupportStatementContextFactory.MakeContext(), null, null); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null), agentInstanceContext)); Assert.IsFalse(_factory.CanReuse(new ExternallyTimedWindowView(_factory, SupportExprNodeFactory.MakeIdentNodeBean("LongPrimitive"), null, new ExprTimePeriodEvalDeltaConstGivenDelta(1000), null, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()), agentInstanceContext)); Assert.IsFalse(_factory.CanReuse(new ExternallyTimedWindowView(_factory, SupportExprNodeFactory.MakeIdentNodeBean("LongBoxed"), null, new ExprTimePeriodEvalDeltaConstGivenDelta(999), null, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()), agentInstanceContext)); Assert.IsTrue(_factory.CanReuse(new ExternallyTimedWindowView(_factory, SupportExprNodeFactory.MakeIdentNodeBean("LongBoxed"), null, new ExprTimePeriodEvalDeltaConstGivenDelta(1000000), null, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()), agentInstanceContext)); }
private void TryInvalidParameter(Object param) { try { LastElementViewFactory factory = new LastElementViewFactory(); factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(), TestViewSupport.ToExprListBean(new Object[] { param })); Assert.Fail(); } catch (ViewParameterException ex) { // expected } }
private void TryParameter(Object[] param) { LastElementViewFactory factory = new LastElementViewFactory(); factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(), TestViewSupport.ToExprListBean(param)); Assert.IsTrue(factory.MakeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()) is LastElementView); }
public void TestCanReuse() { AgentInstanceContext agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceContext(); _factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(), TestViewSupport.ToExprListBean(new Object[] { 1000 })); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null), agentInstanceContext)); Assert.IsFalse(_factory.CanReuse(new LengthWindowView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), _factory, 1, null), agentInstanceContext)); Assert.IsTrue(_factory.CanReuse(new LengthWindowView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), _factory, 1000, null), agentInstanceContext)); }
private void TryParameter(Object[] param, int size) { var factory = new LengthWindowViewFactory(); factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(), TestViewSupport.ToExprListBean(param)); var view = (LengthWindowView)factory.MakeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()); Assert.AreEqual(size, view.Size); }
private void TryInvalidParameter(Object param) { try { _factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(_container), TestViewSupport.ToExprListBean(new Object[] { param })); Assert.Fail(); } catch (ViewParameterException) { // expected } }
private void TryParameter(Object param, long msec) { var factory = new TimeWindowViewFactory(); factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(_container), TestViewSupport.ToExprListBean(new Object[] { param })); var view = (TimeWindowView)factory.MakeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(_container)); Assert.AreEqual(msec, view.TimeDeltaComputation.DeltaAdd(0)); }
public void TestCanReuse() { _factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(), TestViewSupport.ToExprListBean(new Object[] { 1000 })); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null))); Assert.IsFalse(_factory.CanReuse(new TimeBatchView(_factory, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), new ExprTimePeriodEvalDeltaConstMsec(1), null, false, false, null))); Assert.IsTrue(_factory.CanReuse(new TimeBatchView(_factory, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), new ExprTimePeriodEvalDeltaConstMsec(1000000), null, false, false, null))); _factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(), TestViewSupport.ToExprListBean(new Object[] { 1000, 2000L })); Assert.IsFalse(_factory.CanReuse(new TimeBatchView(_factory, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), new ExprTimePeriodEvalDeltaConstMsec(1), null, false, false, null))); Assert.IsTrue(_factory.CanReuse(new TimeBatchView(_factory, SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), new ExprTimePeriodEvalDeltaConstMsec(1000000), 2000L, false, false, null))); }
public void TestCanReuse() { _factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(), TestViewSupport.ToExprListBean(new Object[] { 1000 })); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null))); Assert.IsFalse(_factory.CanReuse(new LengthBatchView(null, _factory, 1, null))); Assert.IsTrue(_factory.CanReuse(new LengthBatchView(null, _factory, 1000, null))); }
private void TryParameter(Object[] param, long msec, long?referencePoint) { var factory = new TimeBatchViewFactory(); factory.SetViewParameters(SupportStatementContextFactory.MakeViewContext(), TestViewSupport.ToExprListBean(param)); var view = (TimeBatchView)factory.MakeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext()); Assert.IsTrue(new ExprTimePeriodEvalDeltaConstGivenDelta(msec).EqualsTimePeriod(view.TimeDeltaComputation)); Assert.AreEqual(referencePoint, view.InitialReferencePoint); }