示例#1
0
        public void should_set_sub_task_property_to_null_that_is_included_in_list_of_injected_property_names()
        {
            // Arrange
            var mockParentTask = new MockParentTask { MockSubTask = new MockSubTask<DateTime>() };
            var task = new DisposeTasks { In = { Owner = mockParentTask, InjectedTaskNames = new[] { typeof(MockSubTask<DateTime>).FullName } } };

            // Act
            task.Execute();

            // Assert
            Assert.That(mockParentTask.MockSubTask, Is.Null);
        }
        public void should_return_a_list_of_all_sub_tasks_that_were_injected()
        {
            // Arrange
            var mockParentTask = new MockParentTask();
            var task = new InjectTasks { In = { TaskContainingSubTasks = mockParentTask } };

            // Act
            task.Execute();

            // Assert
            Assert.That(task.Out.InjectedSubTaskPropertyNames[0], Is.EqualTo(typeof(MockSubTask<DateTime>).FullName));
        }
        public void should_inject_sub_task_if_null()
        {
            // Arrange
            var mockParentTask = new MockParentTask();
            var task = new InjectTasks { In = { TaskContainingSubTasks = mockParentTask } };

            // Act
            task.Execute();

            // Assert
            Assert.That(mockParentTask.MockSubClass, Is.Not.Null);
        }
示例#4
0
        public void should_not_dispose_sub_task_property_that_is_not_included_in_list_of_injected_property_names()
        {
            // Arrange
            var mockSubTask = new MockSubTask<DateTime>();
            var mockParentTask = new MockParentTask { MockSubTask = mockSubTask };
            var task = new DisposeTasks { In = { Owner = mockParentTask, InjectedTaskNames = new[] { "bogus" } } };

            // Act
            task.Execute();

            // Assert
            Assert.That(mockSubTask.DisposeWasCalled, Is.False);
        }
        public void should_not_inject_sub_task_if_not_null()
        {
            // Arrange
            var mockDifferentSubTask = new MockSubTask<DateTime>();
            var mockParentTask = new MockParentTask { MockSubClass = mockDifferentSubTask };
            var task = new InjectTasks { In = { TaskContainingSubTasks = mockParentTask } };

            // Act
            task.Execute();

            // Assert
            Assert.That(task.Out.InjectedSubTaskPropertyNames.Length, Is.EqualTo(0));
        }