예제 #1
0
 public MockFoozzing <T> Build()
 {
     return(new MockFoozzing <T>
     {
         _voidVoid = _voidVoid,
         _responseTaskVoid = _responseTaskVoid,
         _paramType = _paramType,
         _paramGeneric = _paramGeneric,
         _paramTypeResponseTask = _paramTypeResponseTask,
         _paramTuple = _paramTuple,
         _paramTypeGeneric = _paramTypeGeneric,
         _responseGeneric = _responseGeneric,
         _responseType = _responseType,
         _responseTaskGeneric = _responseTaskGeneric,
         _responseTaskType = _responseTaskType,
         _paramTypeResponseTaskType = _paramTypeResponseTaskType,
         _paramTupleResponseType = _paramTupleResponseType,
         _funcTaskGeneric = _funcTaskGeneric,
         _funcTaskGenericResponseTaskGeneric = _funcTaskGenericResponseTaskGeneric,
         _sameNameDifParamsInt = _sameNameDifParamsInt,
         _sameNameDifParamsDouble = _sameNameDifParamsDouble,
         _actionGenericResponseActionGeneric = _actionGenericResponseActionGeneric,
         _actionTypeResponseActionType = _actionTypeResponseActionType,
         ,
     });
예제 #2
0
        public void Invoke_ShouldThrowExceptionWithMethodNameIfInvocationNotUpdated()
        {
            // Arrange
            MockMethodWithResponse <string> subject = new MockMethodWithResponse <string>("methodName");

            // Act
            Action actual = () => subject.Invoke();

            // Assert
            actual.Should().ThrowExactly <TestException>().WithMessage("If you want to use methodName, configure via Builder.");
        }
예제 #3
0
        public void Invoke_ShouldThrowExceptionWhenUpdateInvocationSetUpForThat()
        {
            // Arrange
            MockMethodWithResponse <string> subject = new MockMethodWithResponse <string>("methodName");


            subject.UpdateInvocation(() => throw new Exception("I throw this"));

            // Act
            Action actual = () => subject.Invoke();

            // Assert
            actual.Should().ThrowExactly <Exception>().WithMessage("I throw this");
        }
예제 #4
0
        public void Invoke_ShouldReturnValuePassedIntoUpdateInvocation()
        {
            // Arrange
            string expected = "result";
            MockMethodWithResponse <string> subject = new MockMethodWithResponse <string>("methodName");

            subject.UpdateInvocation(expected);

            // Act
            string actual = subject.Invoke();

            // Assert
            actual.Should().Be(expected);
        }
예제 #5
0
        public void InvokeTask_ShouldTrackInvocationWithExceptionThrown()
        {
            // Arrange
            MockMethodWithResponse <string> subject = new MockMethodWithResponse <string>("methodName");

            subject.UpdateInvocation(() => throw new Exception("Second Invocation"));

            // Act
            Func <Task> actual = async() => await subject.InvokeTask();

            // Assert
            actual.Should().Throw <Exception>();
            subject.AssertInvokedCountMatches(1);
        }
예제 #6
0
        public void Invoke_ShouldReturnSameValueWhenInvokedMultipleTimesAndSetupWithOneResponse()
        {
            // Arrange
            string expected = "result";
            MockMethodWithResponse <string> subject = new MockMethodWithResponse <string>("methodName");

            subject.UpdateInvocation(expected);

            // Act
            string actual1 = subject.Invoke();
            string actual2 = subject.Invoke();
            string actual3 = subject.Invoke();


            // Assert
            actual1.Should().Be(expected);
            actual2.Should().Be(expected);
            actual3.Should().Be(expected);
        }
예제 #7
0
        public void Invoke_ShouldReturnValuesInOrderPassedIntoUpdateInvocationWhenInvokedMultipleTimes()
        {
            // Arrange
            string expected1 = "result1";
            string expected2 = "result2";
            string expected3 = "result3";
            MockMethodWithResponse <string> subject = new MockMethodWithResponse <string>("methodName");

            subject.UpdateInvocation(expected1, expected2, expected3);

            // Act
            string actual1 = subject.Invoke();
            string actual2 = subject.Invoke();
            string actual3 = subject.Invoke();

            // Assert
            actual1.Should().Be(expected1);
            actual2.Should().Be(expected2);
            actual3.Should().Be(expected3);
        }