Ejemplo n.º 1
0
        public async Task ReturnsLocations()
        {
            var controller = new ReferenceController(TestData(), _config.CreateMapper(), Substitute.For <ILogger>());
            var response   = await controller.LocationAsync() as ObjectResult;;

            Assert.Equal(200, response.StatusCode);
            Assert.NotEmpty(response.Value as Model.Station[]);
        }
Ejemplo n.º 2
0
        public async Task ReturnsNotFoundWhenTocRunsNoServices()
        {
            var controller = new ReferenceController(TestData(), _config.CreateMapper(), Substitute.For <ILogger>());
            var response   = await controller.LocationAsync("XC") as ObjectResult;

            Assert.IsType <NotFoundObjectResult>(response);
            Assert.IsType <ReferenceError>(response.Value);
        }
Ejemplo n.º 3
0
        public async Task ReturnsServiceOperatorFilteredLocations(string serviceOperator, int expected)
        {
            var controller = new ReferenceController(TestData(), _config.CreateMapper(), Substitute.For <ILogger>());
            var response   = await controller.LocationAsync(serviceOperator) as ObjectResult;

            var stations = response.Value as Model.Station[];

            Assert.Equal(expected, stations.Length);
        }
Ejemplo n.º 4
0
        public async Task Returns400WhenInvalidToc()
        {
            var controller = new ReferenceController(TestData(), _config.CreateMapper(), Substitute.For <ILogger>());
            var response   = await controller.LocationAsync(toc : new [] { "SWR", "VT" }) as ObjectResult;

            Assert.Equal(400, response.StatusCode);
            var error = response.Value as ReferenceError;

            Assert.Equal("Invalid tocs provided in request SWR|VT", error.Reason);
        }