コード例 #1
0
        public async Task Arrange_ReturnsAsyncWithOneArgument_InvokesGetResult()
        {
            var mockContext = new MockContext <IFoo>();
            var fooMock     = new FooMock(mockContext);

            mockContext.Arrange(f => f.ExecuteAsync(The <string> .IsAnyValue)).ReturnsAsync((string a) => "This" + a);
            var result = await fooMock.ExecuteAsync(" is");

            Assert.Equal("This is", result);
        }
コード例 #2
0
        public async Task Arrange_ReturnsAsyncWithNoArguments_InvokesGetResult()
        {
            var mockContext = new MockContext <IFoo>();
            var fooMock     = new FooMock(mockContext);

            mockContext.Arrange(f => f.ExecuteAsync()).ReturnsAsync(() => "This");
            var result = await fooMock.ExecuteAsync();

            Assert.Equal("This", result);
        }
コード例 #3
0
        public async Task Arrange_ReturnsAsyncWithThreeArguments_InvokesGetResult()
        {
            var mockContext = new MockContext <IFoo>();
            var fooMock     = new FooMock(mockContext);

            mockContext.Arrange(f => f.ExecuteAsync(The <string> .IsAnyValue, The <string> .IsAnyValue, The <string> .IsAnyValue))
            .ReturnsAsync((string a, string b, string c) => "This" + a + b + c);

            var result = await fooMock.ExecuteAsync(" is", " really", " cool");

            Assert.Equal("This is really cool", result);
        }