Skip to content

Commit

Permalink
Best available calls support channels + Added ignoreChannels flag to …
Browse files Browse the repository at this point in the history
…status change calls
  • Loading branch information
mroloux committed Jul 23, 2020
1 parent dda052a commit 9bbe816
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 57 deletions.
22 changes: 21 additions & 1 deletion SeatsioDotNet.Test/Events/BookObjectsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,27 @@ public void ChannelKeys()
channelKey1 = new [] {"A-1", "A-2"}
});

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

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

[Fact]
public void IgnoreChannels()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var channels = new Dictionary<string, Channel>()
{
{ "channelKey1", new Channel("channel 1", "#FFFF00", 1) }
};
Client.Events.UpdateChannels(evnt.Key, channels);
Client.Events.AssignObjectsToChannel(evnt.Key, new
{
channelKey1 = new [] {"A-1", "A-2"}
});

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

Assert.Equal(ObjectStatus.Booked, Client.Events.RetrieveObjectStatus(evnt.Key, "A-1").Status);
}
Expand Down
63 changes: 53 additions & 10 deletions SeatsioDotNet.Test/Events/ChangeBestAvailableObjectStatusTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ public void Number()

Assert.True(bestAvailableResult.NextToEachOther);
Assert.Equal(new[] {"B-4", "B-5", "B-6"}, bestAvailableResult.Objects);
}
}

[Fact]
public void ObjectDetails()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);

var bestAvailableResult = Client.Events.ChangeObjectStatus(evnt.Key, new BestAvailable(2), "foo");

var reportItem = bestAvailableResult.ObjectDetails["B-4"];
Assert.Equal("B-4", reportItem.Label);
reportItem.Labels.Should().BeEquivalentTo(new Labels("4", "seat", "B", "row"));
Expand Down Expand Up @@ -62,19 +62,22 @@ public void ExtraData()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var extraData = new []
var extraData = new[]
{
new Dictionary<string, object> {{"foo", "bar"}},
new Dictionary<string, object> {{"foo", "baz"}}
new Dictionary<string, object> {{"foo", "bar"}},
new Dictionary<string, object> {{"foo", "baz"}}
};

var bestAvailableResult = Client.Events.ChangeObjectStatus(evnt.Key, new BestAvailable(2, null, extraData), "foo");
var bestAvailableResult =
Client.Events.ChangeObjectStatus(evnt.Key, new BestAvailable(2, null, extraData), "foo");

Assert.Equal(new[] {"B-4", "B-5"}, bestAvailableResult.Objects);
Assert.Equal(new Dictionary<string, object> {{"foo", "bar"}}, Client.Events.RetrieveObjectStatus(evnt.Key, "B-4").ExtraData);
Assert.Equal(new Dictionary<string, object> {{"foo", "baz"}}, Client.Events.RetrieveObjectStatus(evnt.Key, "B-5").ExtraData);
Assert.Equal(new Dictionary<string, object> {{"foo", "bar"}},
Client.Events.RetrieveObjectStatus(evnt.Key, "B-4").ExtraData);
Assert.Equal(new Dictionary<string, object> {{"foo", "baz"}},
Client.Events.RetrieveObjectStatus(evnt.Key, "B-5").ExtraData);
}

[Fact]
public void KeepExtraDataTrue()
{
Expand Down Expand Up @@ -113,5 +116,45 @@ public void NoKeepExtraData()

Assert.Null(Client.Events.RetrieveObjectStatus(evnt.Key, "B-5").ExtraData);
}

[Fact]
public void ChannelKeys()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var channels = new Dictionary<string, Channel>()
{
{"channelKey1", new Channel("channel 1", "#FFFF00", 1)}
};
Client.Events.UpdateChannels(evnt.Key, channels);
Client.Events.AssignObjectsToChannel(evnt.Key, new
{
channelKey1 = new[] {"B-6"}
});

var bestAvailableResult = Client.Events.ChangeObjectStatus(evnt.Key, new BestAvailable(1), "someStatus", channelKeys: new[] {"channelKey1"});

Assert.Equal(new[] {"B-6"}, bestAvailableResult.Objects);
}

[Fact]
public void IgnoreChannels()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var channels = new Dictionary<string, Channel>()
{
{"channelKey1", new Channel("channel 1", "#FFFF00", 1)}
};
Client.Events.UpdateChannels(evnt.Key, channels);
Client.Events.AssignObjectsToChannel(evnt.Key, new
{
channelKey1 = new[] {"B-5"}
});

var bestAvailableResult = Client.Events.ChangeObjectStatus(evnt.Key, new BestAvailable(1), "someStatus", ignoreChannels: true);

Assert.Equal(new[] {"B-5"}, bestAvailableResult.Objects);
}
}
}
23 changes: 22 additions & 1 deletion SeatsioDotNet.Test/Events/HoldObjectsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,28 @@ public void ChannelKeys()
channelKey1 = new [] {"A-1", "A-2"}
});

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

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

[Fact]
public void IgnoreChannels()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
HoldToken holdToken = Client.HoldTokens.Create();
var channels = new Dictionary<string, Channel>()
{
{ "channelKey1", new Channel("channel 1", "#FFFF00", 1) }
};
Client.Events.UpdateChannels(evnt.Key, channels);
Client.Events.AssignObjectsToChannel(evnt.Key, new
{
channelKey1 = new [] {"A-1", "A-2"}
});

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

Assert.Equal(ObjectStatus.Held, Client.Events.RetrieveObjectStatus(evnt.Key, "A-1").Status);
}
Expand Down
26 changes: 24 additions & 2 deletions SeatsioDotNet.Test/Events/ReleaseObjectsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,31 @@ public void ChannelKeys()
channelKey1 = new [] {"A-1", "A-2"}
});

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

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

Assert.Equal(ObjectStatus.Free, Client.Events.RetrieveObjectStatus(evnt.Key, "A-1").Status);
}

[Fact]
public void IgnoreChannels()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var channels = new Dictionary<string, Channel>()
{
{ "channelKey1", new Channel("channel 1", "#FFFF00", 1) }
};
Client.Events.UpdateChannels(evnt.Key, channels);
Client.Events.AssignObjectsToChannel(evnt.Key, new
{
channelKey1 = new [] {"A-1", "A-2"}
});

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

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

Assert.Equal(ObjectStatus.Free, Client.Events.RetrieveObjectStatus(evnt.Key, "A-1").Status);
}
Expand Down
Loading

0 comments on commit 9bbe816

Please sign in to comment.