Skip to content

Commit

Permalink
Added oneGroupPerTable social distancing rule
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux committed Oct 19, 2020
1 parent 0636f3e commit 31dde13
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
7 changes: 5 additions & 2 deletions SeatsioDotNet.Test/Charts/SaveSocialDistancingRulesetsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void SaveRulesets()
var chartKey = CreateTestChart();
var rulesets = new Dictionary<string, SocialDistancingRuleset>()
{
{"ruleset1", new SocialDistancingRuleset(0, "My first ruleset", 1, true, 2, 1, 10, 0, false, new List<string> {"A-1"}, new List<string> {"A-2"})},
{"ruleset1", new SocialDistancingRuleset(0, "My first ruleset", 1, true, 2, 1, 10, 0, true, false, new List<string> {"A-1"}, new List<string> {"A-2"})},
{"ruleset2", new SocialDistancingRuleset(1, "My second ruleset")}
};

Expand All @@ -31,6 +31,7 @@ public void SaveRulesets()
Assert.Equal(1, ruleset1.MaxGroupSize);
Assert.Equal(10, ruleset1.MaxOccupancyAbsolute);
Assert.Equal(0, ruleset1.MaxOccupancyPercentage);
Assert.True(ruleset1.OneGroupPerTable);
Assert.False(ruleset1.FixedGroupLayout);
Assert.Equal(new List<string> {"A-1"}, ruleset1.DisabledSeats);
Assert.Equal(new List<string> {"A-2"}, ruleset1.EnabledSeats);
Expand All @@ -44,6 +45,7 @@ public void SaveRulesets()
Assert.Equal(0, ruleset2.MaxGroupSize);
Assert.Equal(0, ruleset2.MaxOccupancyAbsolute);
Assert.Equal(0, ruleset2.MaxOccupancyPercentage);
Assert.False(ruleset2.OneGroupPerTable);
Assert.False(ruleset2.FixedGroupLayout);
Assert.Empty(ruleset2.DisabledSeats);
Assert.Empty(ruleset2.EnabledSeats);
Expand All @@ -55,7 +57,7 @@ public void RuleBased()
var chartKey = CreateTestChart();
var rulesets = new Dictionary<string, SocialDistancingRuleset>()
{
{ "ruleset1", SocialDistancingRuleset.RuleBased(0, "My first ruleset", 1, true, 2, 1, 10, 0, new List<string> {"A-1"}, new List<string> {"A-2"})},
{ "ruleset1", SocialDistancingRuleset.RuleBased(0, "My first ruleset", 1, true, 2, 1, 10, 0, true, new List<string> {"A-1"}, new List<string> {"A-2"})},
};

Client.Charts.SaveSocialDistancingRulesets(chartKey, rulesets);
Expand All @@ -72,6 +74,7 @@ public void RuleBased()
Assert.Equal(1, ruleset1.MaxGroupSize);
Assert.Equal(10, ruleset1.MaxOccupancyAbsolute);
Assert.Equal(0, ruleset1.MaxOccupancyPercentage);
Assert.True(ruleset1.OneGroupPerTable);
Assert.False(ruleset1.FixedGroupLayout);
Assert.Equal(new List<string> {"A-1"}, ruleset1.DisabledSeats);
Assert.Equal(new List<string> {"A-2"}, ruleset1.EnabledSeats);
Expand Down
11 changes: 7 additions & 4 deletions SeatsioDotNet/Charts/SocialDistancingRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class SocialDistancingRuleset
public int MaxGroupSize { get; set; }
public int MaxOccupancyAbsolute { get; set; }
public int MaxOccupancyPercentage { get; set; }
public bool OneGroupPerTable { get; set; }
public bool FixedGroupLayout { get; set; }
public List<string> DisabledSeats { get; set; }
public List<string> EnabledSeats { get; set; }
Expand All @@ -22,7 +23,7 @@ public SocialDistancingRuleset()

public SocialDistancingRuleset(int index = 0, string name = null, int numberOfDisabledSeatsToTheSides = 0,
bool disableSeatsInFrontAndBehind = false, int numberOfDisabledAisleSeats = 0, int maxGroupSize = 0,
int maxOccupancyAbsolute = 0, int maxOccupancyPercentage = 0, bool fixedGroupLayout = false,
int maxOccupancyAbsolute = 0, int maxOccupancyPercentage = 0, bool oneGroupPerTable = false, bool fixedGroupLayout = false,
List<string> disabledSeats = null, List<string> enabledSeats = null)
{
Index = index;
Expand All @@ -33,23 +34,24 @@ public SocialDistancingRuleset(int index = 0, string name = null, int numberOfDi
MaxGroupSize = maxGroupSize;
MaxOccupancyAbsolute = maxOccupancyAbsolute;
MaxOccupancyPercentage = maxOccupancyPercentage;
OneGroupPerTable = oneGroupPerTable;
FixedGroupLayout = fixedGroupLayout;
DisabledSeats = disabledSeats ?? new List<string>();
EnabledSeats = enabledSeats ?? new List<string>();
}

public static SocialDistancingRuleset Fixed(int index = 0, string name = null, List<string> disabledSeats = null)
{
return new SocialDistancingRuleset(index, name, 0, false, 0, 0, 0, 0, true, disabledSeats, null);
return new SocialDistancingRuleset(index, name, 0, false, 0, 0, 0, 0, false, true, disabledSeats, null);
}

public static SocialDistancingRuleset RuleBased(int index = 0, string name = null, int numberOfDisabledSeatsToTheSides = 0,
bool disableSeatsInFrontAndBehind = false, int numberOfDisabledAisleSeats = 0, int maxGroupSize = 0,
int maxOccupancyAbsolute = 0, int maxOccupancyPercentage = 0,
int maxOccupancyAbsolute = 0, int maxOccupancyPercentage = 0, bool oneGroupPerTable = false,
List<string> disabledSeats = null, List<string> enabledSeats = null)
{
return new SocialDistancingRuleset(index, name, numberOfDisabledSeatsToTheSides, disableSeatsInFrontAndBehind,
numberOfDisabledAisleSeats, maxGroupSize, maxOccupancyAbsolute, maxOccupancyPercentage,
numberOfDisabledAisleSeats, maxGroupSize, maxOccupancyAbsolute, maxOccupancyPercentage, oneGroupPerTable,
false, disabledSeats, enabledSeats);
}

Expand All @@ -65,6 +67,7 @@ public object AsJsonObject()
maxGroupSize = MaxGroupSize,
maxOccupancyAbsolute = MaxOccupancyAbsolute,
maxOccupancyPercentage = MaxOccupancyPercentage,
oneGroupPerTable = OneGroupPerTable,
fixedGroupLayout = FixedGroupLayout,
disabledSeats = DisabledSeats,
enabledSeats = EnabledSeats
Expand Down
2 changes: 1 addition & 1 deletion SeatsioDotNet/SeatsioDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<IsPackable>true</IsPackable>
<Version>72.0.0</Version>
<Version>73.0.0</Version>
<Authors>mroloux;bverbeken</Authors>
<Title>Official Seats.io .NET API client</Title>
<Description>Official Seats.io .NET API client</Description>
Expand Down

0 comments on commit 31dde13

Please sign in to comment.