コード例 #1
0
        public void RunExecutesPublishersWhenConditionIsMet()
        {
            var result = GenerateResultMock();
            var logger = mocks.DynamicMock<ILogger>();
            var childPublisher = mocks.StrictMock<ITask>();
            Expect.Call(result.Clone()).Return(null);
            Expect.Call(() => result.Merge(Arg<IIntegrationResult>.Is.Anything));
            Expect.Call(() => { childPublisher.Run(null); });
            var publisher = new ConditionalPublisher
            {
                Logger = logger,
                Tasks = new ITask[] {
                    childPublisher
                },
                Conditions = new IntegrationStatus[] {
                    IntegrationStatus.Success
                }
            };
            mocks.ReplayAll();

            result.Status = IntegrationStatus.Success;
            publisher.Run(result);

            mocks.VerifyAll();
        }
コード例 #2
0
        public void RunDoesNotExecutePublishersWhenConditionIsNotMet()
        {
            var result = GenerateResultMock();
            var logger = mocks.DynamicMock<ILogger>();
            var childPublisher = mocks.StrictMock<ITask>();
            var publisher = new ConditionalPublisher
            {
                Logger = logger,
                Tasks = new ITask[] {
                    childPublisher
                },
                Conditions = new IntegrationStatus[] {
                    IntegrationStatus.Success
                }
            };
            mocks.ReplayAll();

            result.Status = IntegrationStatus.Failure;
            publisher.Run(result);

            mocks.VerifyAll();
        }