public async Task <IActionResult> GetById(int id) { var result = await _routeService.GetRouteById(new IdModel() { Id = id }); return(WrapResponse(result, HttpStatusCode.OK)); }
public void GetRouteByIdInvalidId() { var request = new CollectionRequestModel(); var mocker = new RouteServiceMocker(); RouteInfoEntity entity = new RouteInfoEntity(); mocker.RepoMock.Setup(r => r.GetSingleWithDependencies(It.IsAny <int>())).Returns((() => Task.FromResult((RouteInfoEntity)null))); IRouteBLService service = mocker.GetService(); var result = service.GetRouteById(new IdModel() { Id = 1 }); Assert.Equal(ErrorStatus.ObjectNotFound, result.Result.Error.Status); Assert.Equal("Route not found", result.Result.Error.Message); }
public void GetRouteByIdUnhandledException() { var request = new CollectionRequestModel(); var mocker = new RouteServiceMocker(); RouteInfoEntity entity = new RouteInfoEntity(); mocker.RepoMock.Setup(r => r.GetSingleWithDependencies(It.IsAny <int>())).Throws(new Exception("testexception")); IRouteBLService service = mocker.GetService(); var result = service.GetRouteById(new IdModel() { Id = 1 }); Assert.Equal(ErrorStatus.InternalServer, result.Result.Error.Status); Assert.Equal("testexception", result.Result.Error.Message); }