Beispiel #1
0
        MockEventHandler <EventArgs> SetUpMockCanExecuteChangedEventHandler()
        {
            var mockEventHandler = new MockEventHandler <EventArgs>(SystemUnderTest, EventArgs.Empty);

            SystemUnderTest.CanExecuteChanged += mockEventHandler.HandleEvent;
            return(mockEventHandler);
        }
 public void SetUp()
 {
     _invokeCount    = 10;
     _dehService     = new NuGenDEHService(new MockTimer(_invokeCount));
     _eventHandler   = new MockEventHandler();
     _eventInitiator = new MockEventInitiator();
 }
		public void SetUp()
		{
			_invokeCount = 10;
			_dehService = new NuGenDEHService(new MockTimer(_invokeCount));
			_eventHandler = new MockEventHandler();
			_eventInitiator = new MockEventInitiator();
		}
Beispiel #4
0
        public void test_eventhandler_handleEvent()
        {
            MockEventHandler handler = new MockEventHandler();

            MockSender sender = new MockSender();

            Assert.IsTrue(handler.handleEvent(new MockEvent_Test01(sender)));
            Assert.IsFalse(handler.handleEvent(new MockEvent_Test02(sender)));
        }
Beispiel #5
0
        public void GetEventTypes_GetsSingleGenericHandlerEventType()
        {
            var handler = new MockEventHandler();

            var types = handler.GetEventTypes();

            Assert.NotNull(types);
            var item = Assert.Single(types);

            Assert.Equal(typeof(MockEvent), item);
        }
        public async Task AddEventHandlerSubscriptionForAnyEvent()
        {
            var testEventHandler = new MockEventHandler <EventResultInfo>();
            var subscriber       = new MockEventSubscriber();

            testEventHandler.Event += subscriber.Handle;
            var result = await this.hassWSApi.AddEventHandlerSubscriptionAsync(testEventHandler.EventHandler);

            Assert.IsTrue(result);

            await this.ForceStateChangedAndGetEventData(subscriber);

            Assert.NotZero(subscriber.HitCount);
        }
Beispiel #7
0
        public void GroupByEvent_GroupsSingleHandlerBySingleEventType()
        {
            var handler  = new MockEventHandler();
            var handlers = new[] { handler };

            var grouped = handlers.GroupByEvent();

            Assert.NotNull(grouped);
            var item = Assert.Single(grouped);

            Assert.Equal(typeof(MockEvent), item !.Key);
            var value = Assert.Single(item);

            Assert.Same(handler, value);
        }
        public async Task AddEventHandlerSubscriptionForStateChangedEvents()
        {
            var testEventHandler = new MockEventHandler <EventResultInfo>();
            var subscriber       = new MockEventSubscriber();

            testEventHandler.Event += subscriber.Handle;
            var result = await this.hassWSApi.AddEventHandlerSubscriptionAsync(testEventHandler.EventHandler, KnownEventTypes.StateChanged);

            Assert.IsTrue(result);

            var eventData = await this.ForceStateChangedAndGetEventData(subscriber);

            Assert.NotZero(subscriber.HitCount);
            Assert.IsTrue(eventData.EntityId == testEntitytId);
            Assert.NotNull(eventData.NewState.State);
        }
        public async Task AddMultipleEventHandlerSubscriptionForAnyEvent()
        {
            var testEventHandler1 = new MockEventHandler <EventResultInfo>();
            var testEventHandler2 = new MockEventHandler <EventResultInfo>();
            var subscriber1       = new MockEventSubscriber();
            var subscriber2       = new MockEventSubscriber();

            testEventHandler1.Event += subscriber1.Handle;
            testEventHandler2.Event += subscriber2.Handle;
            var result1 = await this.hassWSApi.AddEventHandlerSubscriptionAsync(testEventHandler1.EventHandler);

            var result2 = await this.hassWSApi.AddEventHandlerSubscriptionAsync(testEventHandler2.EventHandler);

            Assert.IsTrue(result1);
            Assert.IsTrue(result2);

            var eventData = await this.ForceStateChangedAndGetEventData(subscriber1);

            Assert.NotZero(subscriber1.HitCount);
            Assert.AreEqual(subscriber1.HitCount, subscriber2.HitCount);
            Assert.IsTrue(eventData.EntityId == testEntitytId);
        }
Beispiel #10
0
 protected override void SetupMocksAfterConstruction()
 {
     base.SetupMocksAfterConstruction();
     MockCanExecuteChangedEventHandler = SetUpMockCanExecuteChangedEventHandler();
 }