Beispiel #1
0
        public void SendRequestAreEqual()
        {
            //Arrange
            var mockCrew    = new Mock <ICrewMemberMethods>();
            var mockFlight  = new Mock <IFlightMethods>();
            var mockRequest = new Mock <IRequestMethods>();
            DispatcherController controller = new DispatcherController(mockCrew.Object, mockFlight.Object, mockRequest.Object);
            //Act
            ViewResult result = controller.SendRequest() as ViewResult;

            //Assert
            Assert.AreEqual("SendRequest", result.ViewName);
        }
        public void ExecuteWithStaticActionMethod()
        {
            // Arrange
            DispatcherController controller = new DispatcherController();
            object[] parameters = new object[0];
            MethodInfo methodInfo = typeof(DispatcherController).GetMethod("StaticAction");
            ActionMethodDispatcher dispatcher = new ActionMethodDispatcher(methodInfo);

            // Act
            object returnValue = dispatcher.Execute(controller, parameters);

            // Assert
            var intResult = Assert.IsType<int>(returnValue);
            Assert.Equal(89, intResult);
        }
        public void ExecuteWithStaticActionMethod() {
            // Arrange
            DispatcherController controller = new DispatcherController();
            object[] parameters = new object[0];
            MethodInfo methodInfo = typeof(DispatcherController).GetMethod("StaticAction");
            ActionMethodDispatcher dispatcher = new ActionMethodDispatcher(methodInfo);

            // Act
            object returnValue = dispatcher.Execute(controller, parameters);

            // Assert
            Assert.IsInstanceOfType(returnValue, typeof(int));
            int intResult = (int)returnValue;
            Assert.AreEqual(89, intResult);
        }
        public void ExecuteWithVoidActionMethod() {
            // Arrange
            DispatcherController controller = new DispatcherController();
            object[] parameters = new object[] { 5, "some string", new DateTime(2001, 1, 1) };
            MethodInfo methodInfo = typeof(DispatcherController).GetMethod("VoidAction");
            ActionMethodDispatcher dispatcher = new ActionMethodDispatcher(methodInfo);

            // Act
            object returnValue = dispatcher.Execute(controller, parameters);

            // Assert
            Assert.IsNull(returnValue);
            Assert.AreEqual(5, controller._i);
            Assert.AreEqual("some string", controller._s);
            Assert.AreEqual(new DateTime(2001, 1, 1), controller._dt);
        }
Beispiel #5
0
        public void ExecuteWithStaticActionMethod()
        {
            // Arrange
            DispatcherController controller = new DispatcherController();

            object[]               parameters = new object[0];
            MethodInfo             methodInfo = typeof(DispatcherController).GetMethod("StaticAction");
            ActionMethodDispatcher dispatcher = new ActionMethodDispatcher(methodInfo);

            // Act
            object returnValue = dispatcher.Execute(controller, parameters);

            // Assert
            var intResult = Assert.IsType <int>(returnValue);

            Assert.Equal(89, intResult);
        }
Beispiel #6
0
        public void SendRequesRedirection()
        {
            //Arrange
            var mockCrew    = new Mock <ICrewMemberMethods>();
            var mockFlight  = new Mock <IFlightMethods>();
            var mockRequest = new Mock <IRequestMethods>();
            DispatcherController controller = new DispatcherController(mockCrew.Object, mockFlight.Object, mockRequest.Object);
            SendRequestViewModel request    = new SendRequestViewModel()
            {
                Text = ""
            };
            //Act
            RedirectToRouteResult result = controller.SendRequest(request) as RedirectToRouteResult;

            //Assert
            Assert.AreEqual("DispatcherPanel", result.RouteValues["action"]);
        }
Beispiel #7
0
        public void ExecuteWithVoidActionMethod()
        {
            // Arrange
            DispatcherController controller = new DispatcherController();

            object[]               parameters = new object[] { 5, "some string", new DateTime(2001, 1, 1) };
            MethodInfo             methodInfo = typeof(DispatcherController).GetMethod("VoidAction");
            ActionMethodDispatcher dispatcher = new ActionMethodDispatcher(methodInfo);

            // Act
            object returnValue = dispatcher.Execute(controller, parameters);

            // Assert
            Assert.Null(returnValue);
            Assert.Equal(5, controller._i);
            Assert.Equal("some string", controller._s);
            Assert.Equal(new DateTime(2001, 1, 1), controller._dt);
        }
        public void ExecuteWithStaticActionMethod()
        {
            // Arrange
            DispatcherController controller = new DispatcherController();

            object[]               parameters = new object[0];
            MethodInfo             methodInfo = typeof(DispatcherController).GetMethod("StaticAction");
            ActionMethodDispatcher dispatcher = new ActionMethodDispatcher(methodInfo);

            // Act
            object returnValue = dispatcher.Execute(controller, parameters);

            // Assert
            Assert.IsInstanceOfType(returnValue, typeof(int));
            int intResult = (int)returnValue;

            Assert.AreEqual(89, intResult);
        }
        public void ExecuteWithNormalActionMethod()
        {
            // Arrange
            DispatcherController controller = new DispatcherController();
            object[] parameters = new object[] { 5, "some string", new DateTime(2001, 1, 1) };
            MethodInfo methodInfo = typeof(DispatcherController).GetMethod("NormalAction");
            ActionMethodDispatcher dispatcher = new ActionMethodDispatcher(methodInfo);

            // Act
            object returnValue = dispatcher.Execute(controller, parameters);

            // Assert
            var stringResult = Assert.IsType<string>(returnValue);
            Assert.Equal("Hello from NormalAction!", stringResult);

            Assert.Equal(5, controller._i);
            Assert.Equal("some string", controller._s);
            Assert.Equal(new DateTime(2001, 1, 1), controller._dt);
        }
Beispiel #10
0
        public void ExecuteWithNormalActionMethod()
        {
            // Arrange
            DispatcherController controller = new DispatcherController();

            object[]               parameters = new object[] { 5, "some string", new DateTime(2001, 1, 1) };
            MethodInfo             methodInfo = typeof(DispatcherController).GetMethod("NormalAction");
            ActionMethodDispatcher dispatcher = new ActionMethodDispatcher(methodInfo);

            // Act
            object returnValue = dispatcher.Execute(controller, parameters);

            // Assert
            var stringResult = Assert.IsType <string>(returnValue);

            Assert.Equal("Hello from NormalAction!", stringResult);

            Assert.Equal(5, controller._i);
            Assert.Equal("some string", controller._s);
            Assert.Equal(new DateTime(2001, 1, 1), controller._dt);
        }