Skip to content

Commit

Permalink
Added call to completely replace channels (including objects) (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux authored May 30, 2023
1 parent c6d3a40 commit 3f10873
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 198 deletions.
37 changes: 16 additions & 21 deletions SeatsioDotNet.Test/EventReports/EventReportsSummaryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public void SummaryByStatus()
Assert.Equal(new() {{"Cat1", 115}, {"Cat2", 116}}, report[Free].byCategoryLabel);
Assert.Equal(new() {{Available, 231}}, report[Free].byAvailability);
Assert.Equal(new() {{NoChannel, 231}}, report[Free].byChannel);
}
}

[Fact]
public void SummaryByObjectType()
{
Expand All @@ -52,8 +52,8 @@ public void SummaryByObjectType()
Assert.Equal(new() {{"Cat1", 100}, {"Cat2", 100}}, report["generalAdmission"].byCategoryLabel);
Assert.Equal(new() {{Available, 200}}, report["generalAdmission"].byAvailability);
Assert.Equal(new() {{NoChannel, 200}}, report["generalAdmission"].byChannel);
}
}

[Fact]
public void SummaryByCategoryKey()
{
Expand All @@ -74,10 +74,10 @@ public void SummaryByCategoryKey()
Assert.Equal(new() {{Free, 116}}, report["10"].byStatus);
Assert.Equal(new() {{Available, 116}}, report["10"].byAvailability);
Assert.Equal(new() {{NoChannel, 116}}, report["10"].byChannel);

Assert.Equal(0, report["NO_CATEGORY"].Count);
}
}

[Fact]
public void SummaryByCategoryLabel()
{
Expand All @@ -99,7 +99,7 @@ public void SummaryByCategoryLabel()
Assert.Equal(new() {{Free, 116}}, report["Cat2"].byStatus);
Assert.Equal(new() {{Available, 116}}, report["Cat2"].byAvailability);
Assert.Equal(new() {{NoChannel, 116}}, report["Cat2"].byChannel);

Assert.Equal(0, report["NO_CATEGORY"].Count);
}

Expand All @@ -119,7 +119,7 @@ public void SummaryBySection()
Assert.Equal(new() {{Available, 231}, {NotAvailable, 1}}, report[NoSection].byAvailability);
Assert.Equal(new() {{NoChannel, 232}}, report[NoSection].byChannel);
}

[Fact]
public void SummaryByAvailability()
{
Expand All @@ -140,8 +140,8 @@ public void SummaryByAvailability()
Assert.Equal(new() {{Booked, 1}}, report[NotAvailable].byStatus);
Assert.Equal(new() {{"9", 1}}, report[NotAvailable].byCategoryKey);
Assert.Equal(new() {{NoChannel, 1}}, report[NotAvailable].byChannel);
}
}

[Fact]
public void SummaryByAvailabilityReason()
{
Expand All @@ -162,23 +162,18 @@ public void SummaryByAvailabilityReason()
Assert.Equal(new() {{Booked, 1}}, report[Booked].byStatus);
Assert.Equal(new() {{"9", 1}}, report[Booked].byCategoryKey);
Assert.Equal(new() {{NoChannel, 1}}, report[Booked].byChannel);
}
}

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

var report = Client.EventReports.SummaryByChannel(evnt.Key);

Assert.Equal(230, report[NoChannel].Count);
Expand Down
27 changes: 6 additions & 21 deletions SeatsioDotNet.Test/EventReports/EventReportsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@ public void ReportItemProperties()
var extraData = new Dictionary<string, object> {{"foo", "bar"}};
Client.Events.Book(evnt.Key, new[] {new ObjectProperties("A-1", "ticketType1", extraData)}, null, "order1");

var channels = new Dictionary<string, Channel>()
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
{
{"channelKey1", new Channel("channel 1", "#FFFF00", 1)}
};
Client.Events.Channels.Replace(evnt.Key, channels);
Client.Events.Channels.SetObjects(evnt.Key, new
{
channelKey1 = new[] {"A-1"}
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1"})
});

var report = Client.EventReports.ByLabel(evnt.Key);
Expand Down Expand Up @@ -356,14 +351,9 @@ public void ByChannel()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var channels = new Dictionary<string, Channel>()
{
{"channelKey1", new Channel("channel 1", "#FFFF00", 1)}
};
Client.Events.Channels.Replace(evnt.Key, channels);
Client.Events.Channels.SetObjects(evnt.Key, new
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
{
channelKey1 = new[] {"A-1", "A-2"}
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
});

var report = Client.EventReports.ByChannel(evnt.Key);
Expand All @@ -377,14 +367,9 @@ public void BySpecificChannel()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var channels = new Dictionary<string, Channel>()
{
{"channelKey1", new Channel("channel 1", "#FFFF00", 1)}
};
Client.Events.Channels.Replace(evnt.Key, channels);
Client.Events.Channels.SetObjects(evnt.Key, new
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
{
channelKey1 = new[] {"A-1", "A-2"}
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
});

var report = Client.EventReports.ByChannel(evnt.Key, "channelKey1");
Expand Down
18 changes: 4 additions & 14 deletions SeatsioDotNet.Test/Events/BookObjectsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,9 @@ public void ChannelKeys()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var channels = new Dictionary<string, Channel>()
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
{
{ "channelKey1", new Channel("channel 1", "#FFFF00", 1) }
};
Client.Events.Channels.Replace(evnt.Key, channels);
Client.Events.Channels.SetObjects(evnt.Key, new
{
channelKey1 = new [] {"A-1", "A-2"}
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
});

Client.Events.Book(evnt.Key, new[] {"A-1"}, null, null, true, null, new[] {"channelKey1"});
Expand All @@ -113,14 +108,9 @@ 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.Channels.Replace(evnt.Key, channels);
Client.Events.Channels.SetObjects(evnt.Key, new
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
{
channelKey1 = new [] {"A-1", "A-2"}
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
});

Client.Events.Book(evnt.Key, new[] {"A-1"}, null, null, true, true);
Expand Down
18 changes: 4 additions & 14 deletions SeatsioDotNet.Test/Events/ChangeBestAvailableObjectStatusTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,9 @@ public void ChannelKeys()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var channels = new Dictionary<string, Channel>()
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
{
{"channelKey1", new Channel("channel 1", "#FFFF00", 1)}
};
Client.Events.Channels.Replace(evnt.Key, channels);
Client.Events.Channels.SetObjects(evnt.Key, new
{
channelKey1 = new[] {"A-6"}
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-6"})
});

var bestAvailableResult = Client.Events.ChangeObjectStatus(evnt.Key, new BestAvailable(1), "someStatus", channelKeys: new[] {"channelKey1"});
Expand All @@ -170,14 +165,9 @@ 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.Channels.Replace(evnt.Key, channels);
Client.Events.Channels.SetObjects(evnt.Key, new
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
{
channelKey1 = new[] {"A-5"}
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-5"})
});

var bestAvailableResult = Client.Events.ChangeObjectStatus(evnt.Key, new BestAvailable(1), "someStatus", ignoreChannels: true);
Expand Down
18 changes: 4 additions & 14 deletions SeatsioDotNet.Test/Events/ChangeObjectStatusInBatchTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,9 @@ public void ChannelKeys()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var channels = new Dictionary<string, Channel>()
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
{
{"channelKey1", new Channel("channel 1", "#FFFF00", 1)}
};
Client.Events.Channels.Replace(evnt.Key, channels);
Client.Events.Channels.SetObjects(evnt.Key, new
{
channelKey1 = new[] {"A-1"}
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1"})
});

var result = Client.Events.ChangeObjectStatus(new[]
Expand All @@ -55,14 +50,9 @@ 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.Channels.Replace(evnt.Key, channels);
Client.Events.Channels.SetObjects(evnt.Key, new
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
{
channelKey1 = new[] {"A-1"}
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1"})
});

var result = Client.Events.ChangeObjectStatus(new[]
Expand Down
19 changes: 8 additions & 11 deletions SeatsioDotNet.Test/Events/Channels/ReplaceChannelsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@
using SeatsioDotNet.Events;
using Xunit;


namespace SeatsioDotNet.Test.Events
{
public class ReplaceChannelsTest : SeatsioClientTest
{

[Fact]
public void UpdateChannels() {
public void UpdateChannels()
{
var chartKey1 = CreateTestChart();
var event1 = Client.Events.Create(chartKey1);

var channels = new Dictionary<string, Channel>()
var channels = new List<Channel>()
{
{ "channelKey1", new Channel("channel 1", "#FFFF00", 1) },
{ "channelKey2", new Channel("channel 2", "#00FFFF", 2) }
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}),
new("channelKey2", "channel 2", "#00FFFF", 2, new String[] { })
};

Client.Events.Channels.Replace(event1.Key, channels);
Expand All @@ -30,16 +29,14 @@ public void UpdateChannels() {
Assert.Equal("channel 1", channel1.Name);
Assert.Equal("#FFFF00", channel1.Color);
Assert.Equal(1, channel1.Index);
Assert.Empty(channel1.Objects);

Assert.Equal(new List<string>() {"A-1", "A-2"}, channel1.Objects);

var channel2 = retrievedEvent.Channels[1];
Assert.Equal("channelKey2", channel2.Key);
Assert.Equal("channel 2", channel2.Name);
Assert.Equal("#00FFFF", channel2.Color);
Assert.Equal(2, channel2.Index);
Assert.Empty(channel1.Objects);
Assert.Empty(channel2.Objects);
}

}
}
}
34 changes: 0 additions & 34 deletions SeatsioDotNet.Test/Events/Channels/SetObjectsForChannelTest.cs

This file was deleted.

18 changes: 4 additions & 14 deletions SeatsioDotNet.Test/Events/HoldObjectsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,9 @@ public void ChannelKeys()
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
HoldToken holdToken = Client.HoldTokens.Create();
var channels = new Dictionary<string, Channel>()
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
{
{ "channelKey1", new Channel("channel 1", "#FFFF00", 1) }
};
Client.Events.Channels.Replace(evnt.Key, channels);
Client.Events.Channels.SetObjects(evnt.Key, new
{
channelKey1 = new [] {"A-1", "A-2"}
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
});

Client.Events.Hold(evnt.Key, new[] {"A-1"}, holdToken.Token, null, true, null, new[] {"channelKey1"});
Expand All @@ -97,14 +92,9 @@ 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.Channels.Replace(evnt.Key, channels);
Client.Events.Channels.SetObjects(evnt.Key, new
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
{
channelKey1 = new [] {"A-1", "A-2"}
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
});

Client.Events.Hold(evnt.Key, new[] {"A-1"}, holdToken.Token, null, true, true);
Expand Down
18 changes: 4 additions & 14 deletions SeatsioDotNet.Test/Events/ReleaseObjectsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,9 @@ public void ChannelKeys()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var channels = new Dictionary<string, Channel>()
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
{
{ "channelKey1", new Channel("channel 1", "#FFFF00", 1) }
};
Client.Events.Channels.Replace(evnt.Key, channels);
Client.Events.Channels.SetObjects(evnt.Key, new
{
channelKey1 = new [] {"A-1", "A-2"}
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
});

Client.Events.Book(evnt.Key, new[] {"A-1"}, null, null, true, null, new[] {"channelKey1"});
Expand All @@ -94,14 +89,9 @@ 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.Channels.Replace(evnt.Key, channels);
Client.Events.Channels.SetObjects(evnt.Key, new
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
{
channelKey1 = new [] {"A-1", "A-2"}
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
});

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

0 comments on commit 3f10873

Please sign in to comment.