コード例 #1
0
        public async Task If_PreviousBlock_ThenLastBlockHasCorrectObjectValue()
        {
            // ARRANGE
            // Create previous blocks
            using (var executionContext = CreateTaskExecutionContext())
            {
                var startedOk = await executionContext.TryStartAsync();

                if (startedOk)
                {
                    var blocks = await executionContext.GetObjectBlocksAsync <string>(x => x.WithObject("Testing123"));

                    foreach (var block in blocks)
                    {
                        await block.StartAsync();

                        await block.CompleteAsync();
                    }
                }
            }

            var expectedLastBlock = new ObjectBlock <string>()
            {
                Object = "Testing123"
            };

            // ACT
            IObjectBlock <string> lastBlock = null;

            using (var executionContext = CreateTaskExecutionContext())
            {
                var startedOk = await executionContext.TryStartAsync();

                if (startedOk)
                {
                    lastBlock = await executionContext.GetLastObjectBlockAsync <string>();
                }
            }

            // ASSERT
            Assert.Equal(expectedLastBlock.Object, lastBlock.Object);
        }
        public void If_NoPreviousBlock_ThenLastBlockIsNull()
        {
            // ARRANGE
            // all previous blocks were deleted in TestInitialize

            // ACT
            IObjectBlock <string> lastBlock = null;

            using (var executionContext = CreateTaskExecutionContext())
            {
                var startedOk = executionContext.TryStart();
                if (startedOk)
                {
                    lastBlock = executionContext.GetLastObjectBlock <string>();
                }
            }

            // ASSERT
            Assert.IsNull(lastBlock);
        }
コード例 #3
0
        public async Task If_PreviousBlockIsPhantom_ThenLastBlockIsNotThePhantom()
        {
            // ARRANGE
            // Create previous blocks
            using (var executionContext = CreateTaskExecutionContext())
            {
                var startedOk = await executionContext.TryStartAsync();

                if (startedOk)
                {
                    var blocks = await executionContext.GetObjectBlocksAsync <string>(x => x.WithObject("Testing987"));

                    foreach (var block in blocks)
                    {
                        await block.StartAsync();

                        await block.CompleteAsync();
                    }
                }
            }

            _blocksHelper.InsertPhantomObjectBlock(TestConstants.ApplicationName, TestConstants.TaskName);

            // ACT
            IObjectBlock <string> lastBlock = null;

            using (var executionContext = CreateTaskExecutionContext())
            {
                var startedOk = await executionContext.TryStartAsync();

                if (startedOk)
                {
                    lastBlock = await executionContext.GetLastObjectBlockAsync <string>();
                }
            }

            // ASSERT
            Assert.Equal("Testing987", lastBlock.Object);
        }