コード例 #1
0
ファイル: RouteController.cs プロジェクト: m1lwoj/SnowAPI
        public async Task <IActionResult> GetById(int id)
        {
            var result = await _routeService.GetRouteById(new IdModel()
            {
                Id = id
            });

            return(WrapResponse(result, HttpStatusCode.OK));
        }
コード例 #2
0
ファイル: RouteServiceTests.cs プロジェクト: m1lwoj/SnowAPI
        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);
        }
コード例 #3
0
ファイル: RouteServiceTests.cs プロジェクト: m1lwoj/SnowAPI
        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);
        }