Пример #1
0
        public async Task SyncAction()
        {
            string inputString = "hello";
            var    syncMethod  = new SyncMethod(_controller.Echo);
            var    result      = await ControllerActionExecutor.ExecuteAsync(
                syncMethod.GetMethodInfo(),
                _controller,
                new Dictionary <string, object>() { { "input", inputString } });

            Assert.Equal(inputString, result);
        }
Пример #2
0
 public async Task SyncAction_WithException()
 {
     string inputString = "hello";
     var    syncMethod  = new SyncMethod(_controller.EchoWithException);
     await Assert.ThrowsAsync <NotImplementedException>(
         () => ControllerActionExecutor.ExecuteAsync(
             syncMethod.GetMethodInfo(),
             _controller,
             new Dictionary <string, object>()
     {
         { "input", inputString }
     }));
 }
Пример #3
0
        public async Task ExecuteAsync_WithArgumentDictionary_AnyValue_HasPrecedenceOverDefaults()
        {
            // Arrange
            var syncMethod = new SyncMethod(_controller.EchoWithDefaultValueAndAttribute);

            // Act
            var result = await ControllerActionExecutor.ExecuteAsync(
                syncMethod.GetMethodInfo(),
                _controller,
                new Dictionary <string, object>() { { "input", null } });

            // Assert
            Assert.Null(result);
        }
Пример #4
0
        public async Task ExecuteAsync_WithArgumentDictionary_DefaultParameterValueUsed()
        {
            // Arrange
            var syncMethod = new SyncMethod(_controller.EchoWithDefaultValueAndAttribute);

            // Act
            var result = await ControllerActionExecutor.ExecuteAsync(
                syncMethod.GetMethodInfo(),
                _controller,
                new Dictionary <string, object>());

            // Assert
            Assert.Equal("world", result);
        }
Пример #5
0
        public async Task ExecuteAsync_WithArgumentArray_DefaultValueAttributeIgnored()
        {
            // Arrange
            var syncMethod = new SyncMethod(_controller.EchoWithDefaultValue);

            // Act
            var result = await ControllerActionExecutor.ExecuteAsync(
                syncMethod.GetMethodInfo(),
                _controller,
                new object[] { null, });

            // Assert
            Assert.Null(result);
        }
Пример #6
0
        public async Task SyncAction_WithException()
        {
            string inputString       = "hello";
            var    syncMethod        = new SyncMethod(_controller.EchoWithException);
            var    expectedException = "The method or operation is not implemented.";

            await AssertThrowsAsync <NotImplementedException>(
                async() =>
                await ReflectedActionExecutor.ExecuteAsync(
                    syncMethod.GetMethodInfo(),
                    _controller,
                    new Dictionary <string, object>()
            {
                { "input", inputString }
            }),
                expectedException);
        }
Пример #7
0
        public async Task SyncAction_WithException()
        {
            // Arrange
            var inputString = "hello";
            var syncMethod = new SyncMethod(_controller.EchoWithException);

            // Act & Assert
            await Assert.ThrowsAsync<NotImplementedException>(
                        () => ControllerActionExecutor.ExecuteAsync(
                                                syncMethod.GetMethodInfo(),
                                                _controller,
                                                new Dictionary<string, object>() { { "input", inputString } }));
        }
Пример #8
0
        public async Task SyncAction()
        {
            // Arrange
            var inputString = "hello";
            var syncMethod = new SyncMethod(_controller.Echo);

            // Act
            var result = await ControllerActionExecutor.ExecuteAsync(
                                                syncMethod.GetMethodInfo(),
                                                _controller,
                                                new Dictionary<string, object>() { { "input", inputString } });

            // Assert
            Assert.Equal(inputString, result);
        }
Пример #9
0
        public async Task ExecuteAsync_WithArgumentDictionary_AnyValue_HasPrecedenceOverDefaults()
        {
            // Arrange
            var syncMethod = new SyncMethod(_controller.EchoWithDefaultValueAndAttribute);

            // Act
            var result = await ControllerActionExecutor.ExecuteAsync(
                syncMethod.GetMethodInfo(),
                _controller,
                new Dictionary<string, object>() { { "input", null } });

            // Assert
            Assert.Null(result);
        }
Пример #10
0
        public async Task ExecuteAsync_WithArgumentDictionary_DefaultParameterValueUsed()
        {
            // Arrange
            var syncMethod = new SyncMethod(_controller.EchoWithDefaultValueAndAttribute);

            // Act
            var result = await ControllerActionExecutor.ExecuteAsync(
                syncMethod.GetMethodInfo(),
                _controller,
                new Dictionary<string, object>());

            // Assert
            Assert.Equal("world", result);
        }
Пример #11
0
        public async Task ExecuteAsync_WithArgumentArray_DefaultValueAttributeIgnored()
        {
            // Arrange
            var syncMethod = new SyncMethod(_controller.EchoWithDefaultValue);

            // Act
            var result = await ControllerActionExecutor.ExecuteAsync(
                syncMethod.GetMethodInfo(),
                _controller,
                new object[] { null, });

            // Assert
            Assert.Null(result);
        }