Example #1
0
            public void a_disposable_should_dispose()
            {
                var provider = new TestProviderWithDisposable();
                var factory  = new TestProvidersFactory(provider);
                var handler  = new TestHandler(factory);

                handler.Handle(new TestMessage());
                handler.Handle(new TestMessage());

                Assert.AreEqual(2, handler.Strategy.Counter);
            }
        public void Handle_called_twice_has_right_correct_properties()
        {
            var handler = new TestHandler<int>();

            handler.Handle(10);
            handler.Handle(15);

            handler.Satisfy(h =>
                h.CalledTimes == 2 &&
                h.WasCalledAtLeastOnce &&
                h.WasCalledOnce == false &&
                h.Messages[0] == 10 &&
                h.Messages[1] == 15 &&
                h.LastMessage == 15);
        }
        public void Handle_CalledTwice_HasRightCorrectProperties()
        {
            var handler = new TestHandler<int>();

            handler.Handle(10);
            handler.Handle(15);

            handler.Satisfy(h =>
                h.WasCalled == 2 &&
                h.WasCalledAtLeastOnce &&
                h.WasCalledOnce == false &&
                h.Messages[0] == 10 &&
                h.Messages[1] == 15 &&
                h.LastMessage == 15);
        }
        public void Skip_waiting_when_call_performed()
        {
            var handler = new TestHandler<int>();

            handler.Handle(10);

            Assert.DoesNotThrow(() => handler.WaitUntilCalled());
        }
Example #5
0
        public void NotInvokeHandler()
        {
            var handler = new TestHandler();
            var context = new MessageContext(Guid.NewGuid(), 123, "ABC", 123);
            var message = new TestEvent2();

            handler.Handle(context, message).Wait();
            Assert.AreEqual(0, handler.InvokeCount);
        }
        public void Handle_called_once_has_right_correct_properties()
        {
            var handler = new TestHandler<int>();

            handler.Handle(10);

            handler.Satisfy(h =>
                h.CalledTimes == 1 &&
                h.WasCalledOnce &&
                h.WasCalledAtLeastOnce  &&
                h.LastMessage == 10);
        }
        public void Handle_CalledOnce_HasRightCorrectProperties()
        {
            var handler = new TestHandler<int>();

            handler.Handle(10);

            handler.Satisfy(h => 
                h.WasCalled == 1 &&
                h.WasCalledOnce &&
                h.WasCalledAtLeastOnce  &&
                h.LastMessage == 10);
        }
        public void TestMethod1()
        {
            TestHandler.Handle(() =>
            {
                //Calls base class method which calls FindAndWait from ITestFrameworkSerice
                FindAndWait();

                //Creates a random class which has ITestFrameworkSerice injected into constructor, RunCode calls FindAndWait
                var randomClass = DependencyInjector.Retrieve <RandomClass>();
                randomClass.RunCode();
            });
        }