Ejemplo n.º 1
0
        public void QuadrupleParameterDoWillInvokeMethodWithCorrectParameters(
            int expectedNumber,
            string expectedText,
            Type expectedType,
            bool expectedBool)
        {
            // Fixture setup
            var fixture = new Fixture();

            fixture.Inject(expectedNumber);
            fixture.Inject(expectedText);
            fixture.Inject(expectedType);
            fixture.Inject(expectedBool);

            var verified = false;
            var mock     = new CommandMock <int, string, Type, bool>();

            mock.OnCommand = (x, y, z, æ) => verified =
                expectedNumber == x &&
                expectedText == y &&
                expectedType == z &&
                expectedBool == æ;
            // Exercise system
            fixture.Do(
                (int x, string y, Type z, bool æ) => mock.Command(x, y, z, æ));
            // Verify outcome
            Assert.True(verified, "Mock wasn't verified.");
            // Teardown
        }
Ejemplo n.º 2
0
        public void TripleParameterDoWillInvokeMethodWithCorrectParameters(
            string expectedText,
            int expectedNumber,
            bool expectedBool)
        {
            // Fixture setup
            var fixture = new Fixture();

            fixture.Inject(expectedText);
            fixture.Inject(expectedNumber);
            fixture.Inject(expectedBool);

            var verified = false;
            var mock     = new CommandMock <string, int, bool>();

            mock.OnCommand = (x, y, z) => verified =
                expectedText == x &&
                expectedNumber == y &&
                expectedBool == z;
            // Exercise system
            fixture.Do((string x, int y, bool z) => mock.Command(x, y, z));
            // Verify outcome
            Assert.True(verified, "Mock wasn't verified.");
            // Teardown
        }
Ejemplo n.º 3
0
        public void SingleParameterDoWillInvokeMethodWithCorrectParameter(
            int expected)
        {
            // Arrange
            var builder = new DelegatingSpecimenBuilder();

            builder.OnCreate = (r, c) => expected;

            var verified = false;
            var mock     = new CommandMock <int>();

            mock.OnCommand = x => verified = expected == x;
            // Act
            builder.Do((int i) => mock.Command(i));
            // Assert
            Assert.True(verified, "Mock wasn't verified.");
        }
Ejemplo n.º 4
0
        public void SingleParameterDoWillInvokeMethodWithCorrectParameter(
            int expected)
        {
            // Fixture setup
            var builder = new DelegatingSpecimenBuilder();

            builder.OnCreate = (r, c) => expected;

            var verified = false;
            var mock     = new CommandMock <int>();

            mock.OnCommand = x => verified = expected == x;
            // Exercise system
            builder.Do((int i) => mock.Command(i));
            // Verify outcome
            Assert.True(verified, "Mock wasn't verified.");
            // Teardown
        }
Ejemplo n.º 5
0
        public void DoubleParameterDoWillInvokeMethodWithCorrectParameters(
            int expectedNumber,
            string expectedText)
        {
            // Arrange
            var fixture = new Fixture();

            fixture.Inject(expectedNumber);
            fixture.Inject(expectedText);

            var verified = false;
            var mock     = new CommandMock <int, string>();

            mock.OnCommand = (x, y) => verified =
                expectedNumber == x &&
                expectedText == y;
            // Act
            fixture.Do((int x, string y) => mock.Command(x, y));
            // Assert
            Assert.True(verified, "Mock wasn't verified.");
        }
Ejemplo n.º 6
0
        public void DoubleParameterDoWillInvokeMethodWithCorrectParameters(
            int expectedNumber,
            string expectedText)
        {
            // Fixture setup
            var fixture = new Fixture();

            fixture.Inject(expectedNumber);
            fixture.Inject(expectedText);

            var verified = false;
            var mock     = new CommandMock <int, string>();

            mock.OnCommand = (x, y) => verified =
                expectedNumber == x &&
                expectedText == y;
            // Exercise system
            fixture.Do((int x, string y) => mock.Command(x, y));
            // Verify outcome
            Assert.True(verified, "Mock wasn't verified.");
            // Teardown
        }