Example #1
0
        public async Task RunsThroughUnhappyPath_IfAnyHappyStepIndicatesUnsuccesful()
        {
            // Arrange
            var   spyReceiver = new SpyReceiver();
            Agent sut         = AgentWithUnsuccesfulStep(spyReceiver);

            // Act
            await sut.Start(CancellationToken.None);

            // Assert
            Assert.True(spyReceiver.IsCalled);
            Assert.IsType <UnHappyContext>(spyReceiver.Context);
        }
Example #2
0
        public async Task ReceiverGetsExpectedContext_IfHappyPath()
        {
            // Arrange
            var spyReceiver = new SpyReceiver();
            var sut         = new Agent(
                new AgentConfig(name: "Agent with Normal Pipeline"),
                spyReceiver,
                Transformer <StubSubmitTransformer>(),
                exceptionHandler: new SpyAgentExceptionHandler(),
                stepConfiguration: new StepConfiguration
            {
                NormalPipeline = AS4MessageSteps(),
                ErrorPipeline  = null
            });

            // Act
            await sut.Start(CancellationToken.None);

            // Assert
            Assert.True(spyReceiver.IsCalled);
            Assert.Equal(AS4Message.Empty, spyReceiver.Context.AS4Message);
        }
Example #3
0
        public async Task NoStepsAreExecuted_IfNoStepsAreDefined()
        {
            // Arrange
            var spyReceiver = new SpyReceiver();
            var sut         = new Agent(
                new AgentConfig("Agent with non-defined Normal Steps"),
                spyReceiver,
                Transformer <StubSubmitTransformer>(),
                exceptionHandler: new SpyAgentExceptionHandler(),
                stepConfiguration: new StepConfiguration
            {
                NormalPipeline = new Step[] { null },
                ErrorPipeline  = null
            });

            // Act
            await sut.Start(CancellationToken.None);

            // Assert
            Assert.True(spyReceiver.IsCalled);
            Assert.NotNull(spyReceiver.Context.SubmitMessage);
        }