Esempio n. 1
0
        public void when_event_is_fired_twice_then_the_second_time_the_event_is_not_recieved()
        {
            var testScheduler = new CurrentThreadTaskScheduler();

            var stub = new StubClassWithEvent();

            var count = 0;

            EventAsync.FromEvent(eh => stub.NoPayload += eh, eh => stub.NoPayload -= eh)
            .Do(() => count++, testScheduler);

            stub.FireNoPayloadEvent();
            stub.FireNoPayloadEvent();

            Assert.That(count, Is.EqualTo(1));
        }
Esempio n. 2
0
        public void when_event_is_fired_twice_then_the_second_time_the_event_is_not_recieved()
        {
            var testScheduler = new CurrentThreadTaskScheduler();

            var stub = new StubClassWithEvent();

            var count = 0;

            EventAsync.FromEvent(eh => stub.NoPayload += eh, eh => stub.NoPayload -= eh)
                      .Do(() => count++, testScheduler);

            stub.FireNoPayloadEvent();
            stub.FireNoPayloadEvent();

            Assert.That(count, Is.EqualTo(1));
        }
Esempio n. 3
0
        public void when_event_fires_then_the_action_is_executed()
        {
            var testScheduler = new CurrentThreadTaskScheduler();

            var stub = new StubClassWithEvent();

            var result = false;

            EventAsync.FromEvent(eh => stub.NoPayload += eh, eh => stub.NoPayload -= eh)
            .Do(() => result = true, testScheduler);

            stub.FireNoPayloadEvent();

            Assert.That(result, Is.True);
        }
Esempio n. 4
0
        public void when_event_fires_then_the_action_is_executed()
        {
            var testScheduler = new CurrentThreadTaskScheduler();

            var stub = new StubClassWithEvent();

            var result = false;

            EventAsync.FromEvent(eh => stub.NoPayload += eh, eh => stub.NoPayload -= eh)
                      .Do(() => result = true, testScheduler);

            stub.FireNoPayloadEvent();

            Assert.That(result, Is.True);
        }