public async Task InactiveAirlinesAirportTest() { JourneyBuilder journeyBuilder = new JourneyBuilder(_airlineStub.Object, _airportStub.Object, _routeStub.Object, "SVO", "IAA"); var journey = await journeyBuilder.Build(); Assert.IsNull(journey); }
public async Task CaseSensivityTest(string src, string dest) { JourneyBuilder journeyBuilder = new JourneyBuilder(_airlineStub.Object, _airportStub.Object, _routeStub.Object, src, dest); var journey = await journeyBuilder.Build(); Assert.IsNotNull(journey); }
public async Task ExistingRoutesTest(string src, string dest) { JourneyBuilder journeyBuilder = new JourneyBuilder(_airlineStub.Object, _airportStub.Object, _routeStub.Object, src, dest); var journey = await journeyBuilder.Build(); VerifyRoute(src, dest, journey); }
public async Task EmptyRouteOnSameSrcAndDesc() { JourneyBuilder journeyBuilder = new JourneyBuilder(_airlineStub.Object, _airportStub.Object, _routeStub.Object, "ABC", "ABC"); var journey = await journeyBuilder.Build(); Assert.AreEqual(journey.Routes.Length, 0); }
public async Task <IActionResult> Get([FromQuery] string sourceAirport, [FromQuery] string destinationAirport, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(sourceAirport)) { return(BadRequest("sourceAirport is empty")); } if (string.IsNullOrEmpty(destinationAirport)) { return(BadRequest("destinationAirport is empty")); } Journey journey = null; try { JourneyBuilder journeyBuilder = new JourneyBuilder(_airlineProvider, _airportProvider, _routeProvider, sourceAirport, destinationAirport, cancellationToken); journey = await journeyBuilder.Build(); } catch (AirportNotFoundException exc) { return(BadRequest(exc.Message)); } if (journey == null) { return(NotFound()); } return(Ok(journey)); }
public void OperationCancelledExceptionTest(string src, string dest) { CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); JourneyBuilder journeyBuilder = new JourneyBuilder(_airlineStub.Object, _airportStub.Object, _routeStub.Object, src, dest, cancellationTokenSource.Token); cancellationTokenSource.Cancel(); Assert.ThrowsAsync <TaskCanceledException>(async() => { await journeyBuilder.Build(); }); }
public void DestAirportNotFoundExceptionTest() { JourneyBuilder journeyBuilder = new JourneyBuilder(_airlineStub.Object, _airportStub.Object, _routeStub.Object, "LED", "___"); Assert.ThrowsAsync <AirportNotFoundException>(async() => { await journeyBuilder.Build(); }); }