Example #1
0
        public async Task <IActionResult> GetById(int id)
        {
            var result = await _routeService.GetRouteById(new IdModel()
            {
                Id = id
            });

            return(WrapResponse(result, HttpStatusCode.OK));
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }