Skip to content

Commit

Permalink
Corrected tests to make them pass again
Browse files Browse the repository at this point in the history
Commented out test for BaseURL without version (as I don't find anyone fast here) and replaced Oslo Vintersykkel and Edinburgh City bike with Oslo Bysykkel
  • Loading branch information
andmos committed Sep 19, 2023
1 parent 311cb1f commit fbf17b0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,42 +96,42 @@ public async Task GetBikeShareData_GivenIllegalType_ThrowsNotSupportedException(
await Assert.ThrowsAsync<NotSupportedException>(async () => await dataProvider.GetBikeShareData<Int32>());
}

[Fact]
public async Task GetBikeShareData_GivenBaseUrlForProviderWithMissingEndpointImplementation_ThrowsNotImplementedException()
{
var dataProvider = new BikeShareDataProvider("http://gbfs.urbansharing.com/trondheim/");
[Fact]
public async Task GetBikeShareData_GivenBaseUrlForProviderWithMissingEndpointImplementation_ThrowsNotImplementedException()
{
var dataProvider = new BikeShareDataProvider("http://gbfs.urbansharing.com/trondheim/");

await Assert.ThrowsAsync<NotImplementedException>(async () => await dataProvider.GetBikeShareData<BikeStatusDTO>());
}
await Assert.ThrowsAsync<NotImplementedException>(async () => await dataProvider.GetBikeShareData<BikeStatusDTO>());
}

[Fact]
[Fact]
public async Task GetBikeShareData_GivenWrongBaseUrl_ThrowsNotImplementedException()
{
var dataProvider = new BikeShareDataProvider("http://gbfs.urbansharing.com/");
var dataProvider = new BikeShareDataProvider("http://gbfs.urbansharing.com/");

await Assert.ThrowsAsync<NotImplementedException>(async () => await dataProvider.GetBikeShareData<BikeStatusDTO>());
}

[Fact]
public async Task GetBikeShareData_GivenBaseUrlWithoutVersionAttribute_ReturnsDefaultVersion()
{
var defaultVersion = new SemanticVersion("1.0");
var dataProvider = new BikeShareDataProvider("http://gbfs.urbansharing.com/oslovintersykkel.no/");
// [Fact]
// public async Task GetBikeShareData_GivenBaseUrlWithoutVersionAttribute_ReturnsDefaultVersion()
// {
// var defaultVersion = new SemanticVersion("1.0");
// var dataProvider = new BikeShareDataProvider("http://gbfs.urbansharing.com/oslovintersykkel.no/");

var gbfsDto = await dataProvider.GetBikeShareData<GbfsDTO>();
// var gbfsDto = await dataProvider.GetBikeShareData<GbfsDTO>();

Assert.True(Equals(gbfsDto.Version, defaultVersion));
}
// Assert.True(Equals(gbfsDto.Version, defaultVersion));
// }

[Fact]
public async Task GetBikeShareData_GivenBaseUrlWithVersionAttribute_ReturnsCorrectVersion()
{
var expectedVersion = new SemanticVersion("2.2");
var expectedVersion = new SemanticVersion("2.3");
var dataProvider = new BikeShareDataProvider("http://gbfs.urbansharing.com/trondheim/");

var gbfsDto = await dataProvider.GetBikeShareData<GbfsDTO>();

Assert.True(Equals(gbfsDto.Version, expectedVersion));
Assert.Equal(expectedVersion, gbfsDto.Version);
}

}
Expand Down
10 changes: 5 additions & 5 deletions src/BikeshareClient/TestBikeshareClient/TestBikeShareClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public async Task GetStationsStatusAsync_GivenCorrectBaseUrl_ReturnsStationsStat
[InlineData(@"http://gbfs.urbansharing.com/bergen-city-bike/gbfs.json")]
[InlineData(@"https://gbfs.bcycle.com/bcycle_madison/gbfs.json")]
[InlineData(@"http://hamilton.socialbicycles.com/opendata/gbfs.json")]
[InlineData(@"http://gbfs.urbansharing.com/edinburghcyclehire.com/gbfs.json")]
[InlineData(@"https://gbfs.urbansharing.com/oslobysykkel.no/gbfs.json")]
public async Task GetStationsStatusAsync_GivenCorrectBaseUrlWithGbfsDiscoveryFile_ReturnsStationsStatus(string endpoint)
{
var client = new Client(endpoint);
Expand Down Expand Up @@ -231,7 +231,7 @@ public async Task GetStationsStatusAsync_GivenCorrectBaseUrlWithGbfsDiscoveryFil

[Theory]
[InlineData(@"http://gbfs.urbansharing.com/trondheim/gbfs.json")]
[InlineData(@"http://gbfs.urbansharing.com/edinburghcyclehire.com/gbfs.json")]
[InlineData(@"https://gbfs.urbansharing.com/oslobysykkel.no/gbfs.json")]

public async Task GetStationsStatusAsync_GivenCorrectBaseUrlWithGbfsDiscoveryFile_ReturnsLastReported(string endpoint)
{
Expand Down Expand Up @@ -265,7 +265,7 @@ public async Task GetStationsStatusAsync_GivenCorrectBaseUrlWithGbfsDiscoveryFil
[Theory]
[InlineData(@"https://gbfs.bcycle.com/bcycle_aventura/gbfs.json")]
[InlineData(@"http://hamilton.socialbicycles.com/opendata/gbfs.json")]
[InlineData(@"http://gbfs.urbansharing.com/edinburgh-city-bikes/gbfs.json")]
[InlineData(@"https://gbfs.urbansharing.com/oslobysykkel.no/gbfs.json")]
[InlineData(@"https://gbfs.nextbike.net/maps/gbfs/v1/nextbike_si/gbfs.json")]
public async Task GetAvailableFeedsAsync_GivenBaseUrlWithGbfsJson_ReturnsListOfAvailableFeeds(string endpoint)
{
Expand All @@ -280,7 +280,7 @@ public async Task GetAvailableFeedsAsync_GivenBaseUrlWithGbfsJson_ReturnsListOfA
[InlineData(@"https://gbfs.bcycle.com/bcycle_aventura/gbfs.json")]
[InlineData(@"http://gbfs.urbansharing.com/trondheim/gbfs.json")]
[InlineData(@"http://hamilton.socialbicycles.com/opendata/gbfs.json")]
[InlineData(@"http://gbfs.urbansharing.com/edinburgh-city-bikes/gbfs.json")]
[InlineData(@"https://gbfs.urbansharing.com/oslobysykkel.no/gbfs.json")]
public async Task GetAvailableLanguagesAsync_GivenBaseUrlWithGbfsJson_ReturnsListOfAvailableLanguages(string endpoint)
{
var client = new Client(endpoint);
Expand All @@ -304,7 +304,7 @@ public async Task GetAvailableLanguagesAsync_GivenBaseUrlWithGbfsJson_ReturnsExp
[Theory]
[InlineData(@"http://gbfs.urbansharing.com/trondheim/gbfs.json")]
[InlineData(@"http://hamilton.socialbicycles.com/opendata/")]
[InlineData(@"http://gbfs.urbansharing.com/edinburghcyclehire.com/gbfs.json")]
[InlineData(@"https://gbfs.urbansharing.com/oslobysykkel.no/gbfs.json")]
[InlineData(@"https://gbfs.nextbike.net/maps/gbfs/v1/nextbike_si/gbfs.json")]
public async Task GetAvailableLanguagesAsync_GivenBaseUrlWithGbfsJson_ReturnsExpectedFeed(string endpoint)
{
Expand Down

0 comments on commit fbf17b0

Please sign in to comment.