コード例 #1
0
        static void thatCanPerformFurtherAssertionsOnCapturedArgumentValue()
        {
            // Given
            fflib_ApexMocks mocks    = new fflib_ApexMocks();
            fflib_MyList    mockList = (fflib_MyList)mocks.mock(typeof(fflib_MyList));

            //When
            TestInnerClass testValue = new TestInnerClass();

            testValue.i = 4;
            testValue.s = "5";
            mockList.set(1, testValue);

            //Then
            fflib_ArgumentCaptor argument = fflib_ArgumentCaptor.forClass(typeof(TestInnerClass));

            ((fflib_MyList.IList)mocks.verify(mockList)).set(fflib_Match.anyInteger(), argument.capture());
            object capturedArg = argument.getValue();

            System.assertNotEquals(null, capturedArg, "CapturedArg should not be null");
            System.assert(capturedArg is TestInnerClass, "CapturedArg should be SObject, instead was " + capturedArg);
            TestInnerClass testValueCaptured = (TestInnerClass)capturedArg;

            System.assertEquals(4, testValueCaptured.i, "the values inside the argument captured should be the same of the original one");
            System.assertEquals("5", testValueCaptured.s, "the values inside the argument captured should be the same of the original one");
        }
コード例 #2
0
        private static void verifySingleMethodCallWithMultipleArguments()
        {
            // Given
            fflib_ApexMocks mocks    = new fflib_ApexMocks();
            fflib_MyList    mockList = (fflib_MyList)mocks.mock(typeof(fflib_MyList));

            // When
            mockList.set(0, "bob");

            // Then
            ((fflib_MyList.IList)mocks.verify(mockList)).set(0, "bob");
            ((fflib_MyList.IList)mocks.verify(mockList, mocks.never())).set(0, "fred");
        }