Ejemplo n.º 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);
        }
Ejemplo n.º 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 }
     }));
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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 } }));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }