Пример #1
0
        public void Given_Null_When_AddHandlerSpec_Then_Exception()
        {
            var eventHandlerFactory = A.Fake <IEventHandlerFactory>();

            var spec = new TestEventSpecification(eventHandlerFactory);

            Assert.That(() => spec.AddHandlerSpecification(null), Throws.ArgumentNullException.With.Property("ParamName").EqualTo("spec"));
        }
Пример #2
0
        public void Given_HandlerSpec_When_AddHandlerSpec_Then_AddedToEventSpec()
        {
            var eventHandlerFactory = A.Fake <IEventHandlerFactory>();

            var spec = new TestEventSpecification(eventHandlerFactory);

            var handlerSpec = A.Dummy <IEventHandlerSpecification <Object> >();

            spec.AddHandlerSpecification(handlerSpec);

            Assert.That(spec.HandlerSpecifications, Does.Contain(handlerSpec));
        }
Пример #3
0
        public void Given_EventSpec_When_CreateHandler_Then_CallsHandlerFactory()
        {
            var eventHandler = A.Fake <IEventHandler <Object> >();

            var eventHandlerFactory = A.Fake <IEventHandlerFactory>();

            A.CallTo(() => eventHandlerFactory.Create <Object>(A <List <IEventHandlerSpecification <Object> > > ._)).Returns(eventHandler);

            var spec        = new TestEventSpecification(eventHandlerFactory);
            var handlerSpec = A.Dummy <IEventHandlerSpecification <Object> >();

            spec.AddHandlerSpecification(handlerSpec);

            var handler = spec.TestBuild();

            Assert.That(handler, Is.SameAs(eventHandler));
            A.CallTo(() => eventHandlerFactory.Create <Object>(A <List <IEventHandlerSpecification <Object> > > .That.NullCheckedMatches(
                                                                   h => h.Contains(handlerSpec),
                                                                   w => w.Write("HandlerSpecList")))).MustHaveHappened();
        }