Skip to content

Commit

Permalink
Removed social distancing (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux authored Jul 10, 2023
1 parent 7d664fc commit 93ac64e
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 547 deletions.
74 changes: 0 additions & 74 deletions SeatsioDotNet.Test/Charts/SaveSocialDistancingRulesetsTest.cs

This file was deleted.

1 change: 0 additions & 1 deletion SeatsioDotNet.Test/EventReports/EventReportsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public void ReportItemProperties()
Assert.Null(reportItem.LeftNeighbour);
Assert.Equal("A-2", reportItem.RightNeighbour);
Assert.False(reportItem.IsAvailable);
Assert.False(reportItem.IsDisabledBySocialDistancing);
Assert.Equal("channelKey1", reportItem.Channel);
Assert.Null(reportItem.BookAsAWhole);
Assert.NotNull(reportItem.DistanceToFocalPoint);
Expand Down
21 changes: 0 additions & 21 deletions SeatsioDotNet.Test/Events/BookObjectsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,6 @@ public void IgnoreChannels()

Client.Events.Book(evnt.Key, new[] {"A-1"}, null, null, true, true);

Assert.Equal(EventObjectInfo.Booked, Client.Events.RetrieveObjectInfo(evnt.Key, "A-1").Status);
}

[Fact]
public void IgnoreSocialDistancing()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var ruleset = SocialDistancingRuleset.Fixed("ruleset")
.WithDisabledSeats(new List<string> {"A-1"})
.Build();

var rulesets = new Dictionary<string, SocialDistancingRuleset>
{
{"ruleset", ruleset},
};
Client.Charts.SaveSocialDistancingRulesets(chartKey, rulesets);
Client.Events.Update(evnt.Key, new UpdateEventParams().WithSocialDistancingRulesetKey("ruleset"));

Client.Events.Book(evnt.Key, new[] {"A-1"}, null, null, null, null, null, true);

Assert.Equal(EventObjectInfo.Booked, Client.Events.RetrieveObjectInfo(evnt.Key, "A-1").Status);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,5 @@ public void Release()
Assert.Equal(EventObjectInfo.Free, Client.Events.RetrieveObjectInfo(event2.Key, "A-1").Status);
Assert.Equal(EventObjectInfo.Free, Client.Events.RetrieveObjectInfo(event2.Key, "A-2").Status);
}

[Fact]
public void IgnoreSocialDistancing()
{
var chartKey = CreateTestChart();
var ruleset = SocialDistancingRuleset.Fixed("ruleset")
.WithDisabledSeats(new List<string> {"A-1"})
.Build();
var rulesets = new Dictionary<string, SocialDistancingRuleset>
{
{"ruleset", ruleset},
};
Client.Charts.SaveSocialDistancingRulesets(chartKey, rulesets);
var event1 = Client.Events.Create(chartKey, new CreateEventParams().WithSocialDistancingRulesetKey("ruleset"));
var event2 = Client.Events.Create(chartKey, new CreateEventParams().WithSocialDistancingRulesetKey("ruleset"));

Client.Events.Book(new[] {event1.Key, event2.Key}, new[] {"A-1"}, null, null, null, null, null, true);

Assert.Equal(EventObjectInfo.Booked, Client.Events.RetrieveObjectInfo(event1.Key, "A-1").Status);
Assert.Equal(EventObjectInfo.Booked, Client.Events.RetrieveObjectInfo(event2.Key, "A-1").Status);
}

}
}
23 changes: 2 additions & 21 deletions SeatsioDotNet.Test/Events/ChangeObjectStatusTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,6 @@ public void NoKeepExtraData()
Assert.Null(Client.Events.RetrieveObjectInfo(evnt.Key, "A-1").ExtraData);
}

[Fact]
public void IgnoreSocialDistancing()
{
var chartKey = CreateTestChart();
var ruleset = SocialDistancingRuleset.Fixed("ruleset")
.WithDisabledSeats(new List<string> {"A-1"})
.Build();
var rulesets = new Dictionary<string, SocialDistancingRuleset>
{
{"ruleset", ruleset},
};
Client.Charts.SaveSocialDistancingRulesets(chartKey, rulesets);
var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithSocialDistancingRulesetKey("ruleset"));

Client.Events.ChangeObjectStatus(evnt.Key, new[] {"A-1"}, "someStatus", null, null, null, null, null, true);

Assert.Null(Client.Events.RetrieveObjectInfo(evnt.Key, "A-1").ExtraData);
}

[Fact]
public void AllowedPreviousStatuses()
{
Expand All @@ -191,7 +172,7 @@ public void AllowedPreviousStatuses()
Assert.Throws<SeatsioException>(() =>
{
Client.Events.ChangeObjectStatus(evnt.Key, new[] {"A-1"}, "someStatus",
null, null, null, null, null, true,
null, null, null, null, null,
new []{"somePreviousStatus"}
);
});
Expand All @@ -206,7 +187,7 @@ public void RejectedPreviousStatuses()
Assert.Throws<SeatsioException>(() =>
{
Client.Events.ChangeObjectStatus(evnt.Key, new[] {"A-1"}, "someStatus",
null, null, null, null, null, true,
null, null, null, null, null,
null, new []{"free"}
);
});
Expand Down
16 changes: 0 additions & 16 deletions SeatsioDotNet.Test/Events/CreateEventTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,6 @@ public void TableBookingModeInheritCanBeUsed()
Assert.Equal("INHERIT", evnt.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 evnt = Client.Events.Create(chartKey, new CreateEventParams().WithSocialDistancingRulesetKey("ruleset1"));

Assert.Equal("ruleset1", evnt.SocialDistancingRulesetKey);
}


[Fact]
public void ObjectCategoriesCanBePassedIn()
{
Expand Down
23 changes: 1 addition & 22 deletions SeatsioDotNet.Test/Events/CreateEventsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,7 @@ public void TableBookingModesCanBePassedIn()
Assert.Equal("CUSTOM", events[1].TableBookingConfig.Mode);
Assert.Equal(new() {{"T1", "BY_SEAT"}, {"T2", "BY_TABLE"}}, events[1].TableBookingConfig.Tables);
}

[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 eventCreationParams = new[]
{
new CreateEventParams().WithSocialDistancingRulesetKey("ruleset1"),
new CreateEventParams().WithSocialDistancingRulesetKey("ruleset1")
};

var events = Client.Events.Create(chartKey, eventCreationParams);

Assert.Equal("ruleset1", events[0].SocialDistancingRulesetKey);
Assert.Equal("ruleset1", events[1].SocialDistancingRulesetKey);
}


[Fact]
public void ObjectCategoriesCanBePassedIn()
{
Expand Down
22 changes: 0 additions & 22 deletions SeatsioDotNet.Test/Events/HoldObjectsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,5 @@ public void IgnoreChannels()

Assert.Equal(EventObjectInfo.Held, Client.Events.RetrieveObjectInfo(evnt.Key, "A-1").Status);
}

[Fact]
public void IgnoreSocialDistancing()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var ruleset = SocialDistancingRuleset.Fixed("ruleset")
.WithDisabledSeats(new List<string> {"A-1"})
.Build();

var rulesets = new Dictionary<string, SocialDistancingRuleset>
{
{"ruleset", ruleset},
};
Client.Charts.SaveSocialDistancingRulesets(chartKey, rulesets);
Client.Events.Update(evnt.Key, new UpdateEventParams().WithSocialDistancingRulesetKey("ruleset"));
HoldToken holdToken = Client.HoldTokens.Create();

Client.Events.Hold(evnt.Key, new[] {"A-1"}, holdToken.Token, null, null, null, null, true);

Assert.Equal(EventObjectInfo.Held, Client.Events.RetrieveObjectInfo(evnt.Key, "A-1").Status);
}
}
}
39 changes: 1 addition & 38 deletions SeatsioDotNet.Test/Events/UpdateEventTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,44 +51,7 @@ public void UpdateTableBookingConfig()
Assert.Equal("CUSTOM", retrievedEvent.TableBookingConfig.Mode);
Assert.Equal(new() {{"T1", "BY_SEAT"}}, retrievedEvent.TableBookingConfig.Tables);
}

[Fact]
public void UpdateSocialDistancingRulesetKey()
{
var chartKey = CreateTestChart();
var rulesets = new Dictionary<string, SocialDistancingRuleset>()
{
{"ruleset1", SocialDistancingRuleset.RuleBased("My first ruleset").Build()},
{"ruleset2", SocialDistancingRuleset.RuleBased("My second ruleset").Build()}
};
Client.Charts.SaveSocialDistancingRulesets(chartKey, rulesets);
var evnt = Client.Events.Create(chartKey,
new CreateEventParams().WithSocialDistancingRulesetKey("ruleset1"));

Client.Events.Update(evnt.Key, new UpdateEventParams().WithSocialDistancingRulesetKey("ruleset2"));

var retrievedEvent = Client.Events.Retrieve(evnt.Key);
Assert.Equal(retrievedEvent.SocialDistancingRulesetKey, "ruleset2");
}

[Fact]
public void RemoveSocialDistancingRulesetKey()
{
var chartKey = CreateTestChart();
var rulesets = new Dictionary<string, SocialDistancingRuleset>()
{
{"ruleset1", SocialDistancingRuleset.RuleBased("My first ruleset").Build()}
};
Client.Charts.SaveSocialDistancingRulesets(chartKey, rulesets);
var evnt = Client.Events.Create(chartKey,
new CreateEventParams().WithSocialDistancingRulesetKey("ruleset1"));

Client.Events.Update(evnt.Key, new UpdateEventParams().WithSocialDistancingRulesetKey(""));

var retrievedEvent = Client.Events.Retrieve(evnt.Key);
Assert.Null(retrievedEvent.SocialDistancingRulesetKey);
}


[Fact]
public void UpdateObjectCategories()
{
Expand Down
15 changes: 0 additions & 15 deletions SeatsioDotNet.Test/Seasons/CreateSeasonTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,6 @@ public void TableBookingConfigCanBePassedIn()
var season = Client.Seasons.Create(chartKey, tableBookingConfig: TableBookingConfig.AllBySeat());

Assert.Equal(TableBookingConfig.AllBySeat().Mode, season.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.SocialDistancingRulesetKey);
}
}
}
1 change: 0 additions & 1 deletion SeatsioDotNet/Charts/Chart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ public class Chart
public string DraftVersionThumbnailUrl { get; set; }
public IEnumerable<Event> Events { get; set; }
public ChartValidationResult Validation { get; set; }
public Dictionary<string, SocialDistancingRuleset> SocialDistancingRulesets { get; set; }
}
}
20 changes: 0 additions & 20 deletions SeatsioDotNet/Charts/Charts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,26 +137,6 @@ public void RemoveTag(string chartKey, string tag)
AssertOk(_restClient.Execute<object>(restRequest));
}

public void SaveSocialDistancingRulesets(string chartKey, Dictionary<string, SocialDistancingRuleset> rulesets)
{
var restRequest = new RestRequest("/charts/{key}/social-distancing-rulesets", Method.Post)
.AddUrlSegment("key", chartKey)
.AddJsonBody(SaveSocialDistancingRulesetsRequest(rulesets));
AssertOk(_restClient.Execute<object>(restRequest));
}

private Dictionary<string, object> SaveSocialDistancingRulesetsRequest(Dictionary<string, SocialDistancingRuleset> rulesets)
{
var json = new Dictionary<string, object>();
foreach(KeyValuePair<string, SocialDistancingRuleset> entry in rulesets)
{
json.Add(entry.Key, entry.Value.AsJsonObject());
}
var request = new Dictionary<string, object>();
request.Add("socialDistancingRulesets", json);
return request;
}

public Chart Retrieve(string chartKey, bool? expandEvents = null)
{
var restRequest = new RestRequest("/charts/{key}", Method.Get)
Expand Down
Loading

0 comments on commit 93ac64e

Please sign in to comment.