public void TestGetPredictionsInvalidApiToken() { // Arrange const string InvalidApiToken = "INVALID_API_TOKEN"; var client = new BusTrackerClient(UrlBase, InvalidApiToken); var expectedModel = this.repository.GetAs <GetPredictionsResponse>(ResourceFiles.GetPredictionsResponseInvalidApiAccess); Exception exception = null; // Act StartOwinTest( () => { try { var predictions = client.GetPredictions(Enumerable.Empty <int>(), Enumerable.Empty <string>(), Enumerable.Empty <string>(), null); Assert.Fail("Exception thrown exception"); } catch (Exception ex) { exception = ex; } return(Task.FromResult(true)); }); // Assert Assert.IsNotNull(exception); Assert.AreEqual(expectedModel.Errors.Select(e => e.Message).First(), exception.Message); }
public void TestGetPredictionsInvalidApiToken() { // Arrange const string InvalidApiToken = "INVALID_API_TOKEN"; var client = new BusTrackerClient(UrlBase, InvalidApiToken); var expectedModel = this.repository.GetAs<GetPredictionsResponse>(ResourceFiles.GetPredictionsResponseInvalidApiAccess); Exception exception = null; // Act StartOwinTest( () => { try { var predictions = client.GetPredictions(Enumerable.Empty<int>(), Enumerable.Empty<string>(), Enumerable.Empty<string>(), null); Assert.Fail("Exception thrown exception"); } catch (Exception ex) { exception = ex; } return Task.FromResult(true); }); // Assert Assert.IsNotNull(exception); Assert.AreEqual(expectedModel.Errors.Select(e => e.Message).First(), exception.Message); }
public void TestGetPredictions() { // Arrange var client = new BusTrackerClient(UrlBase, WebAppConfig.ApiKey); var expectedModel = this.repository.GetAs <GetPredictionsResponse>(ResourceFiles.GetPredictionsResponse); IEnumerable <Prediction> predictions = null; // Act StartOwinTest( () => { predictions = client.GetPredictions(Enumerable.Empty <int>(), Enumerable.Empty <string>(), Enumerable.Empty <string>(), null); return(Task.FromResult(true)); }); // Assert var expectedPredictionTimes = expectedModel.Predictions.Select(x => x.Timestamp).ToList(); var actualPredictionTimes = predictions.Select(v => v.Timestamp).ToList(); CollectionAssert.AreEqual(expectedPredictionTimes, actualPredictionTimes); }
public void TestGetPredictions() { // Arrange var client = new BusTrackerClient(UrlBase, WebAppConfig.ApiKey); var expectedModel = this.repository.GetAs<GetPredictionsResponse>(ResourceFiles.GetPredictionsResponse); IEnumerable<Prediction> predictions = null; // Act StartOwinTest( () => { predictions = client.GetPredictions(Enumerable.Empty<int>(), Enumerable.Empty<string>(), Enumerable.Empty<string>(), null); return Task.FromResult(true); }); // Assert var expectedPredictionTimes = expectedModel.Predictions.Select(x => x.Timestamp).ToList(); var actualPredictionTimes = predictions.Select(v => v.Timestamp).ToList(); CollectionAssert.AreEqual(expectedPredictionTimes, actualPredictionTimes); }