public async Task ActionSimpleExportTest()
        {
            var collection = new ActionCollection <IActionTracingContainer>();

            collection.AddAction <DummyActionTwo>();
            collection.AddAction <DummyActionOne>();

            var exportProvider = new ActionExportProvider();
            var sequence       = new ActionSequence <IActionTracingContainer>(collection, exportProvider);

            var result = await sequence.ExecuteAsync(null);

            Assert.Equal(ActionSequenceExecutionResult.Full, result);
            Assert.NotNull(exportProvider.GetExport(typeof(DummyActionTwoExport), null));
        }
Exemple #2
0
        public async Task ActionSequenceNoneExecutionTest()
        {
            var collection = new ActionCollection <IActionTracingContainer>();

            collection.AddAction <DummyActionThree>();
            collection.AddAction <DummyActionOne>();

            var sequence = new ActionSequence <IActionTracingContainer>(collection);

            var container = this.GetMockedTracingContainer();
            var result    = await sequence.ExecuteAsync(container);

            Assert.Equal(ActionSequenceExecutionResult.None, result);
            Assert.True(this.MatchTraceEntry(container, 0, ActionTraceEvent.Begin, "ActionSequence (2)"));
            Assert.True(this.MatchTraceEntry(container, 1, ActionTraceEvent.End, "ActionSequence (2)"));
        }
Exemple #3
0
        public async Task ActionSequencePartialExecutionTest()
        {
            var collection = new ActionCollection <IActionTracingContainer>();

            collection.AddAction <DummyActionTwo>();
            collection.AddAction <DummyActionFour>();

            var sequence = new ActionSequence <IActionTracingContainer>(collection);

            var container = this.GetMockedTracingContainer();
            var result    = await sequence.ExecuteAsync(container);

            Assert.Equal(ActionSequenceExecutionResult.Partial, result);
            Assert.True(this.MatchTraceEntry(container, 0, ActionTraceEvent.Begin, "ActionSequence (2)"));
            Assert.True(this.MatchTraceEntry(container, 1, ActionTraceEvent.Begin, "ActionBundle (1)"));
            Assert.True(this.MatchTraceEntry(container, 2, ActionTraceEvent.Begin, nameof(DummyActionTwo)));
            Assert.True(this.MatchTraceEntry(container, 3, ActionTraceEvent.End, nameof(DummyActionTwo)));
            Assert.True(this.MatchTraceEntry(container, 4, ActionTraceEvent.End, "ActionBundle (1)"));
            Assert.True(this.MatchTraceEntry(container, 5, ActionTraceEvent.End, "ActionSequence (2)"));
        }
Exemple #4
0
        public async Task ThrowsForActionExceptionTest()
        {
            var collection = new ActionCollection <IActionTracingContainer>();

            collection.AddAction <ActionWhichThrowsActionException>();

            var sequence = new ActionSequence <IActionTracingContainer>(collection);

            var container = this.GetMockedTracingContainer();
            var exception = await Assert.ThrowsAsync <ActionException>(
                async() => await sequence.ExecuteAsync(container));

            Assert.Equal("TEST", exception.Message);

            Assert.True(this.MatchTraceEntry(container, 0, ActionTraceEvent.Begin, "ActionSequence (1)"));
            Assert.True(this.MatchTraceEntry(container, 1, ActionTraceEvent.Begin, "ActionBundle (1)"));
            Assert.True(this.MatchTraceEntry(container, 2, ActionTraceEvent.Begin, nameof(ActionWhichThrowsActionException)));
            Assert.True(this.MatchTraceEntry(container, 3, ActionTraceEvent.UnexpectedEnd, nameof(ActionWhichThrowsActionException)));
            Assert.True(this.MatchTraceEntry(container, 4, ActionTraceEvent.UnexpectedEnd, "ActionBundle (1)"));
            Assert.True(this.MatchTraceEntry(container, 5, ActionTraceEvent.UnexpectedEnd, "ActionSequence (1)"));
        }