public void Add_ValidObjectPassed_ReturnsCreatedResponse() { // Arrange Route testRoute = new Route() { RequestedStopId = 1, RequestedDateTime = DateTime.Now }; // Act var createdResponse = _controller.Post(testRoute); // Assert Assert.IsType <OkObjectResult>(createdResponse); }
public void SyncRouteTest() { //Arrange var routeState = getFakeRouteState(); _routeSevice.Setup(x => x.ReportDelivery(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <Coordinate>(), It.IsAny <int>(), It.IsAny <short>(), It.IsAny <string>(), DateTime.UtcNow)).Returns(0); // Act IHttpActionResult actionResult = _controller.Post(routeState); var createdResult = actionResult as CreatedAtRouteNegotiatedContentResult <RouteState>; // Assert Assert.IsNotNull(createdResult); Assert.AreEqual("DefaultApi", createdResult.RouteName); Assert.AreEqual(1, createdResult.RouteValues["id"]); Assert.AreEqual(1, createdResult.Content.RouteStatus); }
public void CreateRoute() { var target = new RoutesController(this._EFRouteRepository, this._EFRouteBusStopRepository, this._EFBusStopRepository, this._EFRouteBusRepository, this._MockMapper); var newRoute = new CreateRouteDto { Label = "Test-Route", Description = "Against Test Route" }; var result = target.Post(newRoute); var okResult = result as OkObjectResult; Assert.Equal(200, okResult.StatusCode); Assert.Equal(7, this._EFRouteRepository.Routes.Count()); Assert.Equal("Test-Route", this._EFRouteRepository.Routes .Where(o => o.ID == 7).FirstOrDefault().Label); }