public void Should_Throw_If_Builder_Is_Null()
            {
                // Given, When
                var result = Record.Exception(() => CakeTaskBuilderExtensions.DoesForEach(null, new string[0], exception => { }));

                // Then
                AssertEx.IsArgumentNullException(result, "builder");
            }
                        public void Should_Throw_If_Builder_Is_Null()
                        {
                            // Given, When
                            var result = Record.Exception(() =>
                                                          CakeTaskBuilderExtensions.DoesForEach(null, new[] { "a", "b", "c" }, (item, context) => { }));

                            // Then
                            AssertEx.IsArgumentNullException(result, "builder");
                        }
                        public void Should_Throw_If_Builder_Is_Null()
                        {
                            // Given, When
                            var result = Record.Exception(() =>
                                                          CakeTaskBuilderExtensions.DoesForEach <string, int>(null, new[] { 1, 2, 3 }, (data, item) => { }));

                            // Then
                            AssertEx.IsArgumentNullException(result, "builder");
                        }
            public void Should_Support_Item_And_Context_Action()
            {
                // Given
                var task    = new ActionTask("task");
                var builder = new CakeTaskBuilder <ActionTask>(task);

                // When
                CakeTaskBuilderExtensions.DoesForEach(builder, new[] { "a", "b", "c" }, (item, context) => { });

                // Then
                Assert.Equal(3, builder.Task.Actions.Count);
            }
            public void Should_Add_Actions_Foreach_Item()
            {
                // Given
                var task    = new ActionTask("task");
                var builder = new CakeTaskBuilder <ActionTask>(task);

                // When
                CakeTaskBuilderExtensions.DoesForEach(builder, new[] { "a", "b", "c" }, item => { });

                // Then
                Assert.Equal(3, builder.Task.Actions.Count);
            }
                        public void Should_Add_Actions_To_Task()
                        {
                            // Given
                            var task    = new CakeTask("task");
                            var builder = new CakeTaskBuilder(task);

                            // When
                            CakeTaskBuilderExtensions.DoesForEach(builder, new[] { "a", "b", "c" }, (item, context) => { });

                            // Then
                            Assert.Equal(3, builder.Target.Actions.Count);
                        }
                        public void Should_Add_Actions_Foreach_Item()
                        {
                            // Given
                            var task    = new CakeTask("task");
                            var builder = new CakeTaskBuilder(task);

                            // When
                            CakeTaskBuilderExtensions.DoesForEach <string, int>(builder, new[] { 1, 2, 3 }, (data, item) => { });

                            // Then
                            Assert.Equal(3, builder.Target.Actions.Count);
                        }
                        public void Should_Throw_If_Action_Is_Null()
                        {
                            // Given
                            var task    = new CakeTask("task");
                            var builder = new CakeTaskBuilder(task);

                            // When
                            var result = Record.Exception(() =>
                                                          CakeTaskBuilderExtensions.DoesForEach(builder, new[] { 1, 2, 3 }, (Action <int, ICakeContext>)null));

                            // Then
                            AssertEx.IsArgumentNullException(result, "action");
                        }
            public void Should_Throw_On_First_Failed_Action()
            {
                // Given
                var task    = new ActionTask("task");
                var builder = new CakeTaskBuilder <ActionTask>(task);
                var context = new CakeContextFixture().CreateContext();

                // When
                CakeTaskBuilderExtensions.DoesForEach(builder, () => new[] { "a", "b", "c" }, (item, c) => throw new NotImplementedException());
                var result = Record.Exception(() => builder.Task.Execute(context));

                // Then
                Assert.IsType <NotImplementedException>(result);
            }
                        public async Task Should_Throw_On_First_Failed_Action()
                        {
                            // Given
                            var task    = new CakeTask("task");
                            var builder = new CakeTaskBuilder(task);
                            var context = new CakeContextFixture().CreateContext();

                            // When
                            CakeTaskBuilderExtensions.DoesForEach <string, int>(builder, () => new[] { 1, 2, 3 }, (data, item) => throw new NotImplementedException());
                            var result = await Record.ExceptionAsync(() => builder.Target.Execute(context));

                            // Then
                            Assert.IsType <NotImplementedException>(result);
                        }
            public void Should_Support_Defered_Item_And_Context_Action()
            {
                // Given
                var task    = new ActionTask("task");
                var builder = new CakeTaskBuilder <ActionTask>(task);
                var context = new CakeContextFixture().CreateContext();

                // When
                CakeTaskBuilderExtensions.DoesForEach(builder, () => new[] { "a", "b", "c" }, (item, c) => { });

                // Then
                Assert.Empty(builder.Task.Actions);
                Assert.Single(builder.Task.DelayedActions);

                // When
                builder.Task.Execute(context);

                // Then
                Assert.Empty(builder.Task.DelayedActions);
                Assert.Equal(3, builder.Task.Actions.Count);
            }
                        public async Task Should_Add_Actions_To_Task_After_Execution()
                        {
                            // Given
                            var task    = new CakeTask("task");
                            var builder = new CakeTaskBuilder(task);
                            var context = new CakeContextFixture().CreateContext();

                            // When
                            CakeTaskBuilderExtensions.DoesForEach(builder, () => new[] { "a", "b", "c" }, item => { });

                            // Then
                            Assert.Empty(builder.Target.Actions);
                            Assert.Single(builder.Target.DelayedActions);

                            // When
                            await builder.Target.Execute(context);

                            // Then
                            Assert.Empty(builder.Target.DelayedActions);
                            Assert.Equal(3, builder.Target.Actions.Count);
                        }
Esempio n. 13
0
            public void Should_Defer_Delegate_Items_Until_Execution()
            {
                // Given
                var task    = new ActionTask("task");
                var builder = new CakeTaskBuilder <ActionTask>(task);
                var context = new CakeContextFixture().CreateContext();

                // When
                CakeTaskBuilderExtensions.DoesForEach(builder, () => new[] { "a", "b", "c" }, (item) => { });

                // Then
                Assert.Equal(0, builder.Task.Actions.Count);
                Assert.Equal(1, builder.Task.DelayedActions.Count);

                // When
                builder.Task.Execute(context);

                // Then
                Assert.Equal(0, builder.Task.DelayedActions.Count);
                Assert.Equal(3, builder.Task.Actions.Count);
            }