示例#1
0
        public void CreateAndExecute()
        {
            Counter counter = new Counter();

            ActionTask <Counter> action = new ActionTask <Counter>(counter, c => { c.Increment(); });

            Assert.AreEqual(0, counter.Count);
            action.Execute();
            Assert.AreEqual(1, counter.Count);
        }
示例#2
0
        public void CreateAndExecute()
        {
            Counter counter = new Counter();

            ActionTask<Counter> action = new ActionTask<Counter>(counter, c => { c.Increment(); });

            Assert.AreEqual(0, counter.Count);
            action.Execute();
            Assert.AreEqual(1, counter.Count);
        }
示例#3
0
            public void Should_Only_Aggregate_Exceptions_When_There_Are_Many()
            {
                // Given
                var task    = new ActionTask("task");
                var context = new CakeContextFixture().CreateContext();

                // When
                task.Actions.Add((c) => throw new NotImplementedException());
                task.SetDeferExceptions(true);
                var result = Record.Exception(() => task.Execute(context));

                // Then
                Assert.IsType <NotImplementedException>(result);
            }
示例#4
0
            public void Should_Throw_On_First_Failed_Action()
            {
                // Given
                var task    = new ActionTask("task");
                var context = new CakeContextFixture().CreateContext();

                // When
                task.Actions.Add((c) => throw new NotImplementedException());
                task.Actions.Add((c) => throw new NotSupportedException());
                task.Actions.Add((c) => throw new OutOfMemoryException());
                var result = Record.Exception(() => task.Execute(context));

                // Then
                Assert.IsType <NotImplementedException>(result);
            }
示例#5
0
        public virtual void Update()
        {
            if (_task == null ||
                _task.Execute() == Status.Success)
            {
                Finish();
            }

            if (Status == Status.Running)
            {
                OnUpdate();
            }
            else
            {
                CheckConditions();
            }
        }
示例#6
0
            public void Should_Aggregate_Exceptions_From_Actions()
            {
                // Given
                var task    = new ActionTask("task");
                var context = new CakeContextFixture().CreateContext();

                // When
                task.Actions.Add((c) => throw new NotImplementedException());
                task.Actions.Add((c) => throw new NotSupportedException());
                task.Actions.Add((c) => throw new OutOfMemoryException());
                task.SetDeferExceptions(true);
                var result = Record.Exception(() => task.Execute(context));

                // Then
                Assert.IsType <AggregateException>(result);
                var ex = result as AggregateException;

                Assert.Contains(ex.InnerExceptions, x => x.GetType() == typeof(NotImplementedException));
                Assert.Contains(ex.InnerExceptions, x => x.GetType() == typeof(NotSupportedException));
                Assert.Contains(ex.InnerExceptions, x => x.GetType() == typeof(OutOfMemoryException));
            }