Exemple #1
0
        public async Task DispatcherShouldRegisterPipelineForMultipleEventsAsync()
        {
            var actWrapper = ActWrapper <Event> .From(nopAct);

            var eventTypes = new List <Type> {
                typeof(Event1), typeof(Event2)
            };
            var acts = new ActList {
                actWrapper.Act
            };

            dispatcher.RegisterPipeline(eventTypes, acts);

            Event1 event1 = new Event1 {
                Property = "event1"
            };

            dispatcher.Dispatch(event1);
            await actWrapper.ActTask;

            (actWrapper.Event as Event1).Property.ShouldBeEquivalentTo(event1.Property);

            actWrapper.Rearm();
            Event2 event2 = new Event2 {
                Property = "event2"
            };

            dispatcher.Dispatch(event2);
            await actWrapper.ActTask;

            (actWrapper.Event as Event2).Property.ShouldBeEquivalentTo(event2.Property);
        }
Exemple #2
0
        public async Task DispatcherShouldRegisterMultiplePipelinesPerEventAsync()
        {
            var actWrapperForPipe1 = ActWrapper <Event> .From(nopAct);

            var actWrapperForPipe2 = ActWrapper <Event> .From(nopAct);

            var eventTypes = new List <Type> {
                typeof(Event1)
            };
            var actsForPipe1 = new ActList {
                actWrapperForPipe1.Act
            };
            var actsForPipe2 = new ActList {
                actWrapperForPipe2.Act
            };

            dispatcher.RegisterPipeline(eventTypes, actsForPipe1);
            dispatcher.RegisterPipeline(eventTypes, actsForPipe2);

            dispatcher.Dispatch(new Event1());
            await Task.WhenAll(new Task[] { actWrapperForPipe1.ActTask, actWrapperForPipe2.ActTask });

            actWrapperForPipe1.HasBeenCalled.Should().BeTrue();
            actWrapperForPipe2.HasBeenCalled.Should().BeTrue();
        }
Exemple #3
0
        public async Task DispatcherShoulDispatchWithReconciliation()
        {
            var resolvedEvent = new ReconciliationEvent {
                Id = Guid.NewGuid()
            };
            var actWrapper = ActWrapper <Event>
                             .From((e, context) =>
            {
                resolvedEvent.ReconciliationId = (e as ReconciliationEvent).ReconciliationId;
                context.ReconciliationService.ResolveTask(resolvedEvent);
            });

            var eventTypes = new List <Type> {
                typeof(TestReconciliationEvent)
            };
            var acts = new ActList {
                actWrapper.Act
            };

            dispatcher.RegisterPipeline(eventTypes, acts);

            var originalEvent       = new TestReconciliationEvent();
            var reconciliationEvent = await dispatcher.DispatchWithReconciliation(originalEvent);

            reconciliationEvent.ShouldBeEquivalentTo(resolvedEvent);
        }
Exemple #4
0
 /// <summary>
 /// データ配列の初期化
 /// </summary>
 internal void Init()
 {
     this._value       = new List <Act>();
     this._barrageList = new ActList <Barrage>();
     this._commandList = new ActList <Command>();
     this._toggleList  = new ActList <Toggle>();
     this._mouseList   = new ActList <Action.Mouse>();
 }
Exemple #5
0
        public void DispatcherShouldRegisterPipeline()
        {
            var eventTypes = new List <Type>
            {
                typeof(Event1)
            };
            var actions = new ActList {
                nopAct
            };
            Action action = () => dispatcher.RegisterPipeline(eventTypes, actions);

            action.ShouldNotThrow();
        }
Exemple #6
0
        public Gene()
        {
            Size      = Program.Rand.Next(254) + 10;
            HP        = 1 + Program.Rand.Next(255) * 64;
            Nutrition = new Nutrition(Size * 7200, Size * 7200, Size * 7200);

            /*
             * ActList.Add(Program.Rand.Next(6));
             * ActList.Add(Program.Rand.Next(6));
             * ActList.Add(Program.Rand.Next(6));
             */
            ActList.Add(0, 1);
            //ActList.Add(1);
            //ActList.Add(2,1);
            ActList.Add(7, 1);
            //ActList.Add(8);
        }
Exemple #7
0
        public async Task DispatcherShouldDispatchEventToPipelineAsync()
        {
            var actWrapper = ActWrapper <Event> .From(nopAct);

            var actions = new ActList {
                actWrapper.Act
            };
            var eventTypes = new List <Type>
            {
                typeof(Event1)
            };

            dispatcher.RegisterPipeline(eventTypes, actions);
            dispatcher.Dispatch(new Event1());
            await actWrapper.ActTask;

            actWrapper.HasBeenCalled.Should().BeTrue();
        }
Exemple #8
0
        public async Task DispatcherShouldSaveEventAsync()
        {
            var actWrapper = ActWrapper <Event> .From(nopAct);

            var eventTypes = new List <Type> {
                typeof(Event1)
            };
            var acts = new ActList {
                actWrapper.Act
            };

            dispatcher.RegisterPipeline(eventTypes, acts);

            var originalEvent = new Event1();

            dispatcher.Dispatch(originalEvent);
            await actWrapper.ActTask;

            var savedEvent = await eventStore.Get <Event1>(actWrapper.Event.Id);

            savedEvent.Should().NotBeNull();
        }
Exemple #9
0
 /// <summary>
 /// データ配列の初期化
 /// </summary>
 internal void Init()
 {
     this._value = new List<Act>();
     this._barrageList = new ActList<Barrage>();
     this._commandList = new ActList<Command>();
     this._toggleList = new ActList<Toggle>();
     this._mouseList = new ActList<Action.Mouse>();
 }