Ejemplo n.º 1
0
        public void Arrange_returns_result_of_call_setupFunction()
        {
            // Arrange
            var valueToReturn = new ClassToTest(666);
            Func<ClassToTest> setupFunction = () => valueToReturn;
            var sut = MakeSut(setup:setupFunction);

            // Act
            var actual = sut.Arrange();

            // Assert
            Assert.Same(valueToReturn, actual);
        }
Ejemplo n.º 2
0
        public void Apply_calls_mutationToApply_on_argument()
        {
            // Arrange
            var initialValue = 4;
            var initial = new ClassToTest(initialValue);
            var sut = new Mutation<ClassToTest>("some string", d => d.IntProperty += 2);

            // Act
               sut.Apply(initial);

            // Assert
            Assert.Equal(initialValue + 2, initial.IntProperty);
        }
Ejemplo n.º 3
0
        public void Arrange_with_ConditionToTest_calls_TestCase_Arrange()
        {
            // Arrange
            var toReturn = new ClassToTest(666);
            var testCase = new DummyTestCase<ClassToTest>("whatever");
            testCase.StubbedArrange = () => toReturn;
            var sut = MakeSut(testCase: testCase);

            // Act
            var actual = sut.Arrange();

            // Assert
            Assert.Same(toReturn, actual);
        }
Ejemplo n.º 4
0
        public void Arrange_returns_result_of_applying_mutation_to_parent_Arrange()
        {
            // Arrange
            var parentArrangement = new ClassToTest(4);
            var theParent = new DummyTestComposite<ClassToTest>();
            theParent.StubbedArrange = () => parentArrangement;
            var theMutation = new DummyMutation<ClassToTest>();
            ClassToTest itemPassedToMutationApply = null;
            theMutation.StubbedApply = d => itemPassedToMutationApply = d;
            var sut = MakeSut(theParent, theMutation);

            // Act
            var actual = sut.Arrange();

            // Assert
            Assert.Same(parentArrangement, actual);
            Assert.Same(parentArrangement, itemPassedToMutationApply);
        }
        public void Leaf_with_ConditionToTest_returns_a_TestLeaf_with_Arrange_from_parent_Arrange_AND_its_own()
        {
            // Arrange
            var sut = MakeSut();
            var arrangeReturn = new ClassToTest(5);
            var parent = new DummyTestComposite<ClassToTest>();
            parent.StubbedArrange = () => arrangeReturn;
            var mutationNewIntProperty = 666;
            var mutation = new DummyMutation<ClassToTest>();
            mutation.StubbedApply = c => c.IntProperty = mutationNewIntProperty;
            var leaf = sut.Leaf(parent, mutation);

            // Act
            var actual = leaf.Arrange();

            // Assert
            Assert.Same(arrangeReturn, actual);
            Assert.Equal(actual.IntProperty, mutationNewIntProperty);
        }
        public void Root_returns_TestRoot_with_Arrange_calling_setupFunction()
        {
            // Arrange
            var arrangeReturn = new ClassToTest(3);
            Func<ClassToTest> setUpFunction = () => arrangeReturn;
            var sut = MakeSut();
            var root = sut.Root("whatever", setUpFunction);

            // Act
            var actual = root.Arrange();

            // Assert
            Assert.Same(arrangeReturn, actual);
        }
        public void Mutation_returns_a_Mutation_with_Apply_calling_mutationAction()
        {
            // Arrange
            var instanceToMutate = new ClassToTest(initialValue:5);
            ClassToTest mutatedInstance = null;
            Action<ClassToTest> mutationAction = (c) => { mutatedInstance = c; };
            var sut = MakeSut();
            var actual = sut.Mutation("whatever", mutationAction);

            // Act
            actual.Apply(instanceToMutate);

            // Assert
            Assert.Same(instanceToMutate, mutatedInstance);
        }