예제 #1
0
        public void PostFlghtPlanTest(FlightPlan flightPlan, ObjectResult expectedResult)
        {
            // Arrange.
            IDataAccess          demoDataAccess       = new DemoDataAccess();
            IFlightPlanManager   flightPlanManager    = new FlightPlanManager(demoDataAccess);
            FlightPlanController flightPlanController =
                new FlightPlanController(flightPlanManager);

            // Act.
            ActionResult <string> actionResult = flightPlanController.Post(flightPlan);

            // Assert.
            Assert.IsInstanceOfType(actionResult.Result, expectedResult.GetType());
        }
예제 #2
0
        public async void GetFlightPlanTest(string id)
        {
            // Arrange.
            IDataAccess          demoDataAccess       = new DemoDataAccess();
            IFlightPlanManager   flightPlanManager    = new FlightPlanManager(demoDataAccess);
            FlightPlanController flightPlanController = new FlightPlanController(flightPlanManager);

            // Act.
            ActionResult <FlightPlan> actionResult = await flightPlanController.GetItem(id);

            ObjectResult result           = actionResult.Result as ObjectResult;
            FlightPlan   actualFlightPlan = result.Value as FlightPlan;

            // Assert.
            FlightPlan expectedFlightPlan = demoDataAccess.GetFlightPlan(id);

            Assert.AreEqual <FlightPlan>(actualFlightPlan, expectedFlightPlan);
        }
        public void DeleteServerTest(string id)
        {
            // Arrange.
            IDataAccess       demoDataAccess    = new DemoDataAccess();
            IServersManager   serversManager    = new ServersManager(demoDataAccess);
            ServersController serversController = new ServersController(serversManager);

            // Act.
            ActionResult <string> actionResult = serversController.Delete(id);

            // Assert.
            ObjectResult expectedResult;

            if (demoDataAccess.DeleteServer(id))
            {
                expectedResult = new OkObjectResult(id);
            }
            else
            {
                expectedResult = new NotFoundObjectResult(id);
            }
            Assert.IsInstanceOfType(actionResult.Result, expectedResult.GetType());
        }
        public void GetServersTest()
        {
            // Arrange.
            IDataAccess       demoDataAccess    = new DemoDataAccess();
            IServersManager   serversManager    = new ServersManager(demoDataAccess);
            ServersController serversController = new ServersController(serversManager);

            // Act.
            ActionResult <List <Server> > actionResult = serversController.Get();
            ObjectResult  result        = actionResult.Result as ObjectResult;
            List <Server> actualServers = result.Value as List <Server>;

            // Assert.
            List <Server> expectedServers = demoDataAccess.GetServers();
            // Get the minimum length.
            int size = actualServers.Count <= expectedServers.Count ? actualServers.Count : expectedServers.Count;
            int i    = 0;

            for (i = 0; i < size; i++)
            {
                Assert.AreEqual <Server>(expectedServers[i], actualServers[i]);
            }
        }
        public void GetUrlTest(string id)
        {
            // Arrange.
            IDataAccess       demoDataAccess    = new DemoDataAccess();
            IServersManager   serversManager    = new ServersManager(demoDataAccess);
            ServersController serversController = new ServersController(serversManager);

            // Act.
            ActionResult <Server> actionResult = serversController.GetUrl(id);

            // Assert.
            ObjectResult expectedResult;
            Server       server = demoDataAccess.GetServerByIdOfFlight(id);

            if (server != null)
            {
                expectedResult = new OkObjectResult(server);
            }
            else
            {
                expectedResult = new NotFoundObjectResult(id);
            }
            Assert.IsInstanceOfType(actionResult.Result, expectedResult.GetType());
        }