Skip to content

Commit

Permalink
Seasons are events + removed legacy calls (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux authored Feb 15, 2022
1 parent 449be03 commit 3004dcb
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 195 deletions.
17 changes: 15 additions & 2 deletions SeatsioDotNet.Test/Events/ListEventsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,21 @@ public void Test()
var event3 = Client.Events.Create(chartKey);

var events = Client.Events.ListAll();

Assert.Equal(new [] {event3.Key, event2.Key, event1.Key}, events.Select(e => e.Key));

Assert.Equal(new[] {event3.Key, event2.Key, event1.Key}, events.Select(e => e.Key));
}

[Fact]
public void ListSeasons()
{
var chartKey = CreateTestChart();
var season1 = Client.Seasons.Create(chartKey);
var season2 = Client.Seasons.Create(chartKey);
var season3 = Client.Seasons.Create(chartKey);

var seasons = Client.Events.ListAll();

Assert.Equal(new[] {true, true, true}, seasons.Select(s => s.IsSeason));
}
}
}
26 changes: 25 additions & 1 deletion SeatsioDotNet.Test/Events/RetrieveEventTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using SeatsioDotNet.Events;
using SeatsioDotNet.Seasons;
using Xunit;

namespace SeatsioDotNet.Test.Events
Expand All @@ -13,7 +14,7 @@ public void Test()
var evnt = Client.Events.Create(chartKey);

var retrievedEvent = Client.Events.Retrieve(evnt.Key);

Assert.NotNull(retrievedEvent.Key);
Assert.NotEqual(0, retrievedEvent.Id);
Assert.Equal(chartKey, retrievedEvent.ChartKey);
Expand All @@ -23,5 +24,28 @@ public void Test()
CustomAssert.CloseTo(DateTimeOffset.Now, retrievedEvent.CreatedOn.Value);
Assert.Null(retrievedEvent.UpdatedOn);
}

[Fact]
public void RetrieveSeason()
{
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.Events.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);
Assert.Equal(chartKey, season.ChartKey);
Assert.Equal("INHERIT", season.TableBookingConfig.Mode);
Assert.True(season.SupportsBestAvailable);
Assert.Null(season.ForSaleConfig);
CustomAssert.CloseTo(DateTimeOffset.Now, season.CreatedOn.Value);
Assert.Null(season.UpdatedOn);
}
}
}
20 changes: 8 additions & 12 deletions SeatsioDotNet.Test/Seasons/CreateSeasonTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,12 @@ public void ChartKeyIsMandatory()
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);
Assert.Equal(chartKey, season.ChartKey);
Assert.Equal("INHERIT", season.TableBookingConfig.Mode);
Assert.True(season.SupportsBestAvailable);
Assert.Null(season.ForSaleConfig);
CustomAssert.CloseTo(DateTimeOffset.Now, season.CreatedOn.Value);
Assert.Null(season.UpdatedOn);
}

[Fact]
Expand Down Expand Up @@ -69,7 +65,7 @@ public void TableBookingConfigCanBePassedIn()

var season = Client.Seasons.Create(chartKey, tableBookingConfig: TableBookingConfig.AllBySeat());

Assert.Equal(TableBookingConfig.AllBySeat().Mode, season.SeasonEvent.TableBookingConfig.Mode);
Assert.Equal(TableBookingConfig.AllBySeat().Mode, season.TableBookingConfig.Mode);
}

[Fact]
Expand All @@ -84,7 +80,7 @@ public void SocialDistancingRulesetKeyCanBePassedIn()

var season = Client.Seasons.Create(chartKey, socialDistancingRulesetKey: "ruleset1");

Assert.Equal("ruleset1", season.SeasonEvent.SocialDistancingRulesetKey);
Assert.Equal("ruleset1", season.SocialDistancingRulesetKey);
}
}
}
19 changes: 0 additions & 19 deletions SeatsioDotNet.Test/Seasons/DeletePartialSeasonTest.cs

This file was deleted.

18 changes: 0 additions & 18 deletions SeatsioDotNet.Test/Seasons/DeleteSeasonTest.cs

This file was deleted.

21 changes: 0 additions & 21 deletions SeatsioDotNet.Test/Seasons/ListSeasonsTest.cs

This file was deleted.

32 changes: 0 additions & 32 deletions SeatsioDotNet.Test/Seasons/RetrievePartialSeasonTest.cs

This file was deleted.

16 changes: 6 additions & 10 deletions SeatsioDotNet.Test/Seasons/RetrieveSeasonTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,12 @@ public void Test()
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);
Assert.Equal(chartKey, season.ChartKey);
Assert.Equal("INHERIT", season.TableBookingConfig.Mode);
Assert.True(season.SupportsBestAvailable);
Assert.Null(season.ForSaleConfig);
CustomAssert.CloseTo(DateTimeOffset.Now, season.CreatedOn.Value);
Assert.Null(season.UpdatedOn);
}
}
}
5 changes: 4 additions & 1 deletion SeatsioDotNet/Events/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ public class Event
public DateTimeOffset? UpdatedOn { get; set; }
public List<Channel> Channels { get; set; }
public string SocialDistancingRulesetKey { get; set; }
public List<string> PartialSeasonKeys { get; set; }
public List<Event> Events { get; set; }
public bool IsSeason { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion SeatsioDotNet/Events/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public Event Retrieve(string eventKey)

public EventObjectInfo RetrieveObjectInfo(string eventKey, string objectLabel)
{
var result = RetrieveObjectInfos(eventKey, new string[] {objectLabel});
var result = RetrieveObjectInfos(eventKey, new[] {objectLabel});
return result[objectLabel];
}

Expand Down
14 changes: 0 additions & 14 deletions SeatsioDotNet/Seasons/Season.cs

This file was deleted.

Loading

0 comments on commit 3004dcb

Please sign in to comment.