-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added seasons * Version bump
- Loading branch information
Showing
16 changed files
with
512 additions
and
15 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
SeatsioDotNet.Test/Seasons/AddEventsToPartialSeasonTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace SeatsioDotNet.Test.Seasons | ||
{ | ||
public class AddEventsToPartialSeasonTest : SeatsioClientTest | ||
{ | ||
[Fact] | ||
public void Test() | ||
{ | ||
var chartKey = CreateTestChart(); | ||
var topLevelSeason = Client.Seasons.Create(chartKey, eventKeys: new[] {"event1", "event2"}); | ||
var partialSeason = Client.Seasons.CreatePartialSeason(topLevelSeason.Key, partialSeasonKey: "aPartialSeason"); | ||
|
||
var updatedPartialSeason = Client.Seasons.AddEventsToPartialSeason(topLevelSeason.Key, partialSeason.Key, new[] {"event1", "event2"}); | ||
|
||
Assert.Equal(new[] {"event1", "event2"}, updatedPartialSeason.Events.Select(e => e.Key)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace SeatsioDotNet.Test.Seasons | ||
{ | ||
public class CreateEventsInSeasonTest : SeatsioClientTest | ||
{ | ||
[Fact] | ||
public void EventsKeysCanBePassedIn() | ||
{ | ||
var chartKey = CreateTestChart(); | ||
var season = Client.Seasons.Create(chartKey); | ||
|
||
var updatedSeason = Client.Seasons.CreateEvents(season.Key, eventKeys: new[] {"event1", "event2"}); | ||
|
||
Assert.Equal(new[] {"event1", "event2"}, updatedSeason.Events.Select(e => e.Key)); | ||
} | ||
|
||
[Fact] | ||
public void NumberOfEventsCanBePassedIn() | ||
{ | ||
var chartKey = CreateTestChart(); | ||
var season = Client.Seasons.Create(chartKey); | ||
|
||
var updatedSeason = Client.Seasons.CreateEvents(season.Key, numberOfEvents: 2); | ||
|
||
Assert.Equal(2, updatedSeason.Events.Count); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace SeatsioDotNet.Test.Seasons | ||
{ | ||
public class CreatePartialSeasonTest : SeatsioClientTest | ||
{ | ||
[Fact] | ||
public void KeyCanBePassedIn() | ||
{ | ||
var chartKey = CreateTestChart(); | ||
var topLevelSeason = Client.Seasons.Create(chartKey); | ||
|
||
var partialSeason = Client.Seasons.CreatePartialSeason(topLevelSeason.Key, partialSeasonKey: "aPartialSeason"); | ||
|
||
Assert.Equal("aPartialSeason", partialSeason.Key); | ||
} | ||
|
||
[Fact] | ||
public void EventKeysCanBePassedIn() | ||
{ | ||
var chartKey = CreateTestChart(); | ||
var topLevelSeason = Client.Seasons.Create(chartKey, eventKeys: new[] {"event1", "event2"}); | ||
|
||
var partialSeason = Client.Seasons.CreatePartialSeason(topLevelSeason.Key, eventKeys: new[] {"event1", "event2"}); | ||
|
||
Assert.Equal(new[] {"event1", "event2"}, partialSeason.Events.Select(e => e.Key)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using SeatsioDotNet.Charts; | ||
using SeatsioDotNet.Events; | ||
using Xunit; | ||
|
||
namespace SeatsioDotNet.Test.Seasons | ||
{ | ||
public class CreateSeasonTest : SeatsioClientTest | ||
{ | ||
[Fact] | ||
public void ChartKeyIsMandatory() | ||
{ | ||
var chartKey = CreateTestChart(); | ||
|
||
var season = Client.Seasons.Create(chartKey); | ||
|
||
Assert.NotNull(season.Key); | ||
Assert.NotEqual(0, season.Id); | ||
Assert.Empty(season.PartialSeasonKeys); | ||
Assert.Empty(season.Events); | ||
|
||
var seasonEvent = season.SeasonEvent; | ||
Assert.Equal(season.Key, seasonEvent.Key); | ||
Assert.NotEqual(0, seasonEvent.Id); | ||
Assert.Equal(chartKey, seasonEvent.ChartKey); | ||
Assert.Equal("INHERIT", seasonEvent.TableBookingConfig.Mode); | ||
Assert.True(seasonEvent.SupportsBestAvailable); | ||
Assert.Null(seasonEvent.ForSaleConfig); | ||
CustomAssert.CloseTo(DateTimeOffset.Now, seasonEvent.CreatedOn.Value); | ||
Assert.Null(seasonEvent.UpdatedOn); | ||
} | ||
|
||
[Fact] | ||
public void KeyCanBePassedIn() | ||
{ | ||
var chartKey = CreateTestChart(); | ||
|
||
var season = Client.Seasons.Create(chartKey, key: "aSeason"); | ||
|
||
Assert.Equal("aSeason", season.Key); | ||
} | ||
|
||
[Fact] | ||
public void NumberOfEventsCanBePassedIn() | ||
{ | ||
var chartKey = CreateTestChart(); | ||
|
||
var season = Client.Seasons.Create(chartKey, numberOfEvents: 2); | ||
|
||
Assert.Equal(2, season.Events.Count); | ||
} | ||
|
||
[Fact] | ||
public void EventKeysCanBePassedIn() | ||
{ | ||
var chartKey = CreateTestChart(); | ||
|
||
var season = Client.Seasons.Create(chartKey, eventKeys: new[] {"event1", "event2"}); | ||
|
||
Assert.Equal(new[] {"event1", "event2"}, season.Events.Select(e => e.Key)); | ||
} | ||
|
||
[Fact] | ||
public void TableBookingConfigCanBePassedIn() | ||
{ | ||
var chartKey = CreateTestChart(); | ||
|
||
var season = Client.Seasons.Create(chartKey, tableBookingConfig: TableBookingConfig.AllBySeat()); | ||
|
||
Assert.Equal(TableBookingConfig.AllBySeat().Mode, season.SeasonEvent.TableBookingConfig.Mode); | ||
} | ||
|
||
[Fact] | ||
public void SocialDistancingRulesetKeyCanBePassedIn() | ||
{ | ||
var chartKey = CreateTestChart(); | ||
var rulesets = new Dictionary<string, SocialDistancingRuleset>() | ||
{ | ||
{ "ruleset1", SocialDistancingRuleset.RuleBased("My first ruleset").Build() }, | ||
}; | ||
Client.Charts.SaveSocialDistancingRulesets(chartKey, rulesets); | ||
|
||
var season = Client.Seasons.Create(chartKey, socialDistancingRulesetKey: "ruleset1"); | ||
|
||
Assert.Equal("ruleset1", season.SeasonEvent.SocialDistancingRulesetKey); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Xunit; | ||
|
||
namespace SeatsioDotNet.Test.Seasons | ||
{ | ||
public class DeletePartialSeasonTest : SeatsioClientTest | ||
{ | ||
[Fact] | ||
public void Test() | ||
{ | ||
var chartKey = CreateTestChart(); | ||
var season = Client.Seasons.Create(chartKey); | ||
var partialSeason = Client.Seasons.CreatePartialSeason(season.Key); | ||
|
||
Client.Seasons.DeletePartialSeason(season.Key, partialSeason.Key); | ||
|
||
Assert.Throws<SeatsioException>(() => Client.Seasons.RetrievePartialSeason(season.Key, partialSeason.Key)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Xunit; | ||
|
||
namespace SeatsioDotNet.Test.Seasons | ||
{ | ||
public class DeleteSeasonTest : SeatsioClientTest | ||
{ | ||
[Fact] | ||
public void Test() | ||
{ | ||
var chartKey = CreateTestChart(); | ||
var season = Client.Seasons.Create(chartKey); | ||
|
||
Client.Seasons.Delete(season.Key); | ||
|
||
Assert.Throws<SeatsioException>(() => Client.Seasons.Retrieve(season.Key)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace SeatsioDotNet.Test.Seasons | ||
{ | ||
public class ListSeasonsTest : SeatsioClientTest | ||
{ | ||
[Fact] | ||
public void Test() | ||
{ | ||
var chartKey = CreateTestChart(); | ||
var season1 = Client.Seasons.Create(chartKey); | ||
var season2 = Client.Seasons.Create(chartKey); | ||
var season3 = Client.Seasons.Create(chartKey); | ||
|
||
var seasons = Client.Seasons.ListAll(); | ||
|
||
Assert.Equal(new[] {season3.Key, season2.Key, season1.Key}, seasons.Select(s => s.Key)); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
SeatsioDotNet.Test/Seasons/RemoveEventFromPartialSeasonTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace SeatsioDotNet.Test.Seasons | ||
{ | ||
public class RemoveEventFromPartialSeasonTest : SeatsioClientTest | ||
{ | ||
[Fact] | ||
public void Test() | ||
{ | ||
var chartKey = CreateTestChart(); | ||
var topLevelSeason = Client.Seasons.Create(chartKey, eventKeys: new[] {"event1", "event2"}); | ||
var partialSeason = Client.Seasons.CreatePartialSeason(topLevelSeason.Key, eventKeys: new[] {"event1", "event2"}); | ||
|
||
var updatedPartialSeason = Client.Seasons.RemoveEventFromPartialSeason(topLevelSeason.Key, partialSeason.Key, "event2"); | ||
|
||
Assert.Equal(new[] {"event1"}, updatedPartialSeason.Events.Select(e => e.Key)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using Xunit; | ||
|
||
namespace SeatsioDotNet.Test.Seasons | ||
{ | ||
public class RetrievePartialSeasonTest : SeatsioClientTest | ||
{ | ||
[Fact] | ||
public void Test() | ||
{ | ||
var chartKey = CreateTestChart(); | ||
|
||
var season = Client.Seasons.Create(chartKey); | ||
var partialSeason = Client.Seasons.CreatePartialSeason(season.Key); | ||
|
||
var retrievedPartialSeason = Client.Seasons.RetrievePartialSeason(season.Key, partialSeason.Key); | ||
|
||
Assert.NotNull(retrievedPartialSeason.Key); | ||
Assert.NotEqual(0, retrievedPartialSeason.Id); | ||
|
||
var seasonEvent = retrievedPartialSeason.SeasonEvent; | ||
Assert.Equal(retrievedPartialSeason.Key, seasonEvent.Key); | ||
Assert.NotEqual(0, seasonEvent.Id); | ||
Assert.Equal(chartKey, seasonEvent.ChartKey); | ||
Assert.Equal("INHERIT", seasonEvent.TableBookingConfig.Mode); | ||
Assert.True(seasonEvent.SupportsBestAvailable); | ||
Assert.Null(seasonEvent.ForSaleConfig); | ||
CustomAssert.CloseTo(DateTimeOffset.Now, seasonEvent.CreatedOn.Value); | ||
Assert.Null(seasonEvent.UpdatedOn); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using Xunit; | ||
|
||
namespace SeatsioDotNet.Test.Seasons | ||
{ | ||
public class RetrieveSeasonTest : SeatsioClientTest | ||
{ | ||
[Fact] | ||
public void Test() | ||
{ | ||
var chartKey = CreateTestChart(); | ||
|
||
var season = Client.Seasons.Create(chartKey); | ||
var partialSeason1 = Client.Seasons.CreatePartialSeason(season.Key); | ||
var partialSeason2 = Client.Seasons.CreatePartialSeason(season.Key); | ||
|
||
var retrievedSeason = Client.Seasons.Retrieve(season.Key); | ||
|
||
Assert.NotNull(retrievedSeason.Key); | ||
Assert.NotEqual(0, retrievedSeason.Id); | ||
Assert.Equal(new[] {partialSeason1.Key, partialSeason2.Key}, retrievedSeason.PartialSeasonKeys); | ||
Assert.Empty(retrievedSeason.Events); | ||
|
||
var seasonEvent = retrievedSeason.SeasonEvent; | ||
Assert.Equal(season.Key, seasonEvent.Key); | ||
Assert.NotEqual(0, seasonEvent.Id); | ||
Assert.Equal(chartKey, seasonEvent.ChartKey); | ||
Assert.Equal("INHERIT", seasonEvent.TableBookingConfig.Mode); | ||
Assert.True(seasonEvent.SupportsBestAvailable); | ||
Assert.Null(seasonEvent.ForSaleConfig); | ||
CustomAssert.CloseTo(DateTimeOffset.Now, seasonEvent.CreatedOn.Value); | ||
Assert.Null(seasonEvent.UpdatedOn); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<PropertyGroup> | ||
<TargetFrameworks>netcoreapp2.0</TargetFrameworks> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="5.10.3" /> | ||
<ProjectReference Include="..\SeatsioDotNet\SeatsioDotNet.csproj" /> | ||
<ProjectReference Include="..\SeatsioDotNet\SeatsioDotNet.csproj" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="RestSharp" Version="106.15.0" /> | ||
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="resources\*"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="resources\*"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Collections.Generic; | ||
using SeatsioDotNet.Events; | ||
|
||
namespace SeatsioDotNet.Seasons | ||
{ | ||
public class Season | ||
{ | ||
public long Id { get; set; } | ||
public string Key { get; set; } | ||
public List<string> PartialSeasonKeys { get; set; } | ||
public Event SeasonEvent { get; set; } | ||
public List<Event> Events { get; set; } | ||
} | ||
} |
Oops, something went wrong.