private async Task IsModulus(object modulusOf, string modulusAsString, object isAModulus, object notAModulus)
        {
            var config = new EventRuleDto
            {
                Type   = EventRuleType.Modulus,
                Source = EventRuleSource.EventParameter,
                EventParameterNumber = 1,
                Value = modulusAsString
            };

            var rule = new EventRule(_mockEventSubscription.Object, 1, config);

            var decodedEvent = _sampleTransferLog.ToDecodedEvent(_transferEventAbi);

            decodedEvent.Event.First(p => p.Parameter.Order == config.EventParameterNumber).Result = modulusOf;
            Assert.True(await rule.HandleAsync(decodedEvent));

            decodedEvent.Event.First(p => p.Parameter.Order == config.EventParameterNumber).Result = isAModulus;
            Assert.True(await rule.HandleAsync(decodedEvent));

            decodedEvent.Event.First(p => p.Parameter.Order == config.EventParameterNumber).Result = null;
            Assert.False(await rule.HandleAsync(decodedEvent));

            decodedEvent.Event.First(p => p.Parameter.Order == config.EventParameterNumber).Result = notAModulus;
            Assert.False(await rule.HandleAsync(decodedEvent));
        }
        private async Task IsLessOrEqual(object maxValue, string maxValueAsString, object higherValue, object lesserValue)
        {
            var config = new EventRuleDto
            {
                Type   = EventRuleType.LessThanOrEqualTo,
                Source = EventRuleSource.EventParameter,
                EventParameterNumber = 1,
                Value = maxValueAsString
            };

            var rule = new EventRule(_mockEventSubscription.Object, 1, config);

            var decodedEvent = _sampleTransferLog.ToDecodedEvent(_transferEventAbi);

            decodedEvent.Event.First(p => p.Parameter.Order == config.EventParameterNumber).Result = maxValue;
            Assert.True(await rule.HandleAsync(decodedEvent));

            decodedEvent.Event.First(p => p.Parameter.Order == config.EventParameterNumber).Result = lesserValue;
            Assert.True(await rule.HandleAsync(decodedEvent));

            decodedEvent.Event.First(p => p.Parameter.Order == config.EventParameterNumber).Result = null;
            Assert.False(await rule.HandleAsync(decodedEvent));

            decodedEvent.Event.First(p => p.Parameter.Order == config.EventParameterNumber).Result = higherValue;
            Assert.False(await rule.HandleAsync(decodedEvent));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a new event parsing rule.
        /// </summary>
        public EventRule AddEvent(string inId)
        {
            CheckLocked();

            EventRule rule = FindOrCreateEventRule(inId);

            return(rule);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds a new event parsing rule processed with the given delegate.
        /// </summary>
        public EventRule AddEvent(string inId, StringHash32 inEventId, EventDelegate inDelegate)
        {
            CheckLocked();

            EventRule rule = new EventRule(inId);

            rule.ProcessWith(inEventId, inDelegate);
            return(rule);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Adds a new event parsing rule.
        /// </summary>
        public EventRule AddEvent(string inId, StringHash32 inEventId)
        {
            CheckLocked();

            EventRule rule = FindOrCreateEventRule(inId);

            rule.ProcessWith(inEventId);
            return(rule);
        }
Exemplo n.º 6
0
 public int getframeshift(EventRule e)
 {
     ButtonPressDelay();
     if (e.YourID)
     {
         Advance(10);
         time_delay();
     }
     return(index);
 }
Exemplo n.º 7
0
        public void TestSerialization()
        {
            EventRule toSeralize = new EventRule();

            toSeralize.EventName   = "attribute";
            toSeralize.EventSource = ActiveConfig.DB.GetAttribute("supervisor");
            UniqueIDCache.ClearIdCache();

            EventRule deserialized = (EventRule)UnitTestControl.XmlSerializeRoundTrip <EventRule>(toSeralize);

            Assert.AreEqual(toSeralize.EventName, deserialized.EventName);
            Assert.AreEqual(toSeralize.EventSource, deserialized.EventSource);
        }
Exemplo n.º 8
0
        private EventRule FindOrCreateEventRule(string inPattern)
        {
            foreach (var rule in m_EventRules)
            {
                if (rule.Id() == inPattern)
                {
                    return(rule);
                }
            }

            EventRule newRule = new EventRule(inPattern);

            m_EventRules.Add(newRule);
            return(newRule);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FakeManager"/> class.
        /// </summary>
        /// <param name="fakeObjectType">The faked type.</param>
        /// <param name="proxy">The faked proxy object.</param>
        /// <param name="fakeObjectName">The name of the fake object.</param>
        internal FakeManager(Type fakeObjectType, object proxy, string?fakeObjectName)
        {
            Guard.AgainstNull(fakeObjectType, nameof(fakeObjectType));
            Guard.AgainstNull(proxy, nameof(proxy));

            this.objectReference = new WeakReference(proxy);
            this.FakeObjectType  = fakeObjectType;
            this.FakeObjectName  = fakeObjectName;

            this.eventRule    = new EventRule(this);
            this.allUserRules = new LinkedList <CallRuleMetadata>();

            this.recordedCalls         = new ConcurrentQueue <CompletedFakeObjectCall>();
            this.interceptionListeners = new LinkedList <IInterceptionListener>();
        }
Exemplo n.º 10
0
        public bool TryProcess(TagData inData, object inContext, out TagEventData outEvent)
        {
            EventRule rule = m_EventRules.FindMatch(inData.Id);

            if (rule != null)
            {
                return(rule.Evaluate(inData, inContext, out outEvent));
            }

            if (m_EventInheritFrom != null)
            {
                return(m_EventInheritFrom.TryProcess(inData, inContext, out outEvent));
            }

            outEvent = default(TagEventData);
            return(false);
        }
Exemplo n.º 11
0
        public void EvaluateOnSimpleEvent()
        {
            Guid newId = Guid.NewGuid();

            try
            {
                MAObjectHologram maObject = ActiveConfig.DB.CreateMAObject(newId, "person");

                AcmaEvent maevent = GetAccountNameChangedEvent();

                RaisedEvent exitEvent = new RaisedEvent(maevent, maObject);
                maObject.IncomingEvents = new List <RaisedEvent>()
                {
                    exitEvent
                };

                // Positive Tests
                EventRule target = new EventRule();
                target.EventName = "accountNameChanged";
                Assert.IsTrue(target.Evaluate(maObject));

                // Negative Tests

                maevent   = GetSupervisorChangedEvent();
                exitEvent = new RaisedEvent(maevent, maObject);
                maObject.IncomingEvents = new List <RaisedEvent>()
                {
                    exitEvent
                };

                target.EventName = "accountNameChanged";
                Assert.IsFalse(target.Evaluate(maObject));

                target.EventName   = "accountNameChanged";
                target.EventSource = ActiveConfig.DB.GetAttribute("supervisor");
                Assert.IsFalse(target.Evaluate(maObject));
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(newId);
            }
        }
        public async Task IsEmpty()
        {
            var config = new EventRuleDto
            {
                Type   = EventRuleType.Empty,
                Source = EventRuleSource.EventParameter,
                EventParameterNumber = 1
            };

            var rule = new EventRule(_mockEventSubscription.Object, 1, config);

            var decodedEvent = _sampleTransferLog.ToDecodedEvent(_transferEventAbi);

            Assert.False(await rule.HandleAsync(decodedEvent));

            decodedEvent.Event.First(p => p.Parameter.Order == config.EventParameterNumber).Result = null;
            Assert.True(await rule.HandleAsync(decodedEvent));

            decodedEvent.Event.First(p => p.Parameter.Order == config.EventParameterNumber).Result = string.Empty;
            Assert.True(await rule.HandleAsync(decodedEvent));
        }
Exemplo n.º 13
0
        public void EvaluateOnSourceEvent()
        {
            Guid supervisorId = Guid.NewGuid();
            Guid targetId     = Guid.NewGuid();

            try
            {
                MAObjectHologram supervisorObject = ActiveConfig.DB.CreateMAObject(supervisorId, "person");
                MAObjectHologram targetObject     = ActiveConfig.DB.CreateMAObject(targetId, "person");

                AcmaSchemaAttribute supervisorAttribute = ActiveConfig.DB.GetAttribute("supervisor");
                targetObject.SetAttributeValue(supervisorAttribute, supervisorObject.ObjectID);
                targetObject.CommitCSEntryChange();

                AcmaEvent   maevent   = GetAccountNameChangedEvent();
                RaisedEvent exitEvent = new RaisedEvent(maevent, supervisorObject);
                targetObject.IncomingEvents = new List <RaisedEvent>()
                {
                    exitEvent
                };

                // Positive Tests
                EventRule target = new EventRule();
                target.EventName   = "accountNameChanged";
                target.EventSource = ActiveConfig.DB.GetAttribute("supervisor");
                Assert.IsTrue(target.Evaluate(targetObject));

                // Negative Tests
                target             = new EventRule();
                target.EventName   = "accountNameChanged";
                target.EventSource = ActiveConfig.DB.GetAttribute("directReports");
                Assert.IsFalse(target.Evaluate(targetObject));
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(targetId);
                ActiveConfig.DB.DeleteMAObjectPermanent(supervisorId);
            }
        }
        private async Task IsEqual(object val, string valAsString, object differentValue)
        {
            var config = new EventRuleDto
            {
                Type   = EventRuleType.Equals,
                Source = EventRuleSource.EventParameter,
                EventParameterNumber = 1,
                Value = valAsString
            };

            var rule = new EventRule(_mockEventSubscription.Object, 1, config);

            var decodedEvent = _sampleTransferLog.ToDecodedEvent(_transferEventAbi);

            decodedEvent.Event.First(p => p.Parameter.Order == config.EventParameterNumber).Result = val;
            Assert.True(await rule.HandleAsync(decodedEvent));

            decodedEvent.Event.First(p => p.Parameter.Order == config.EventParameterNumber).Result = null;
            Assert.False(await rule.HandleAsync(decodedEvent));

            decodedEvent.Event.First(p => p.Parameter.Order == config.EventParameterNumber).Result = differentValue;
            Assert.False(await rule.HandleAsync(decodedEvent));
        }
Exemplo n.º 15
0
        public RNGResult GenerateEvent(EventRule e)
        {
            RNGResult st = new RNGResult();

            index = 0;

            st.row_r = Rand[0];
            st.Clock = (int)(st.row_r % 17);
            st.Blink = ((int)(st.row_r & 0x7F)) > 0 ? 0 : 1;

            // Reset NPC Status
            if (!createtimeline)
            {
                ResetNPCStatus();
            }

            // ---Start here when press A button---

            if (Considerdelay)
            {
                st.frameshift = getframeshift(e);
            }

            //Encryption Constant & PID
            switch (e.PIDType)
            {
            case 0:
                st.EC  = (uint)(getrand() & 0xFFFFFFFF); st.PID = (uint)(getrand() & 0xFFFFFFFF);
                st.PSV = ((st.PID >> 16) ^ (st.PID & 0xFFFF)) >> 4; if (st.PSV == TSV)
                {
                    st.Shiny = true;
                }
                break;

            case 1:
                Advance(2); st.Shiny = true;
                break;

            case 2:
                Advance(2); st.Shiny = false;
                break;

            case 3:
                break;
            }

            //IV
            st.IVs = (int[])e.IVs.Clone();
            int cnt = e.IVsCount;

            while (cnt > 0)
            {
                int ran = (int)(getrand() % 6);
                if (st.IVs[ran] < 0)
                {
                    st.IVs[ran] = 31;
                    cnt--;
                }
            }
            for (int i = 0; i < 6; i++)
            {
                if (st.IVs[i] < 0)
                {
                    st.IVs[i] = (int)(getrand() & 0x1F);
                }
            }

            //Ability
            if (!e.AbilityLocked)
            {
                st.Ability = (int)(getrand() & 1) + 1;
            }

            //Nature
            if (!e.NatureLocked)
            {
                st.Nature = (int)(currentrand() % 25);
            }

            //Gender
            if (nogender || e.GenderLocked)
            {
                st.Gender = 0;
            }
            else
            {
                st.Gender = ((int)(getrand() % 252) >= gender_ratio) ? 1 : 2;
            }

            return(st);
        }
Exemplo n.º 16
0
 public EventRuleViewModel(EventRule model, bool canUseProposedValues)
     : base(model, canUseProposedValues)
 {
     this.typedModel = model;
     this.AnySender  = this.typedModel.EventSource == null;
 }