Skip to content

Commit

Permalink
Channels can be passed in when creating an event (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux authored Aug 25, 2023
1 parent b23c00a commit 707ff40
Show file tree
Hide file tree
Showing 15 changed files with 133 additions and 77 deletions.
6 changes: 3 additions & 3 deletions SeatsioDotNet.Test/EventReports/EventReportsSummaryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ public void SummaryByAvailabilityReason()
public void SummaryByChannel()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
var channels = new List<Channel>
{
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
});
};
var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels));

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

Expand Down
25 changes: 12 additions & 13 deletions SeatsioDotNet.Test/EventReports/EventReportsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ public class EventReportsTest : SeatsioClientTest
public void ReportItemProperties()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var extraData = new Dictionary<string, object> {{"foo", "bar"}};
Client.Events.Book(evnt.Key, new[] {new ObjectProperties("A-1", "ticketType1", extraData)}, null, "order1");

Client.Events.Channels.Replace(evnt.Key, new List<Channel>
var channels = new List<Channel>
{
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1"})
});
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
};
var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels));
var extraData = new Dictionary<string, object> {{"foo", "bar"}};
Client.Events.Book(evnt.Key, new[] {new ObjectProperties("A-1", "ticketType1", extraData)}, null, "order1", null, true);

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

Expand Down Expand Up @@ -354,11 +353,11 @@ public void BySpecificAvailabilityReason()
public void ByChannel()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
var channels = new List<Channel>
{
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
});
};
var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels));

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

Expand All @@ -370,11 +369,11 @@ public void ByChannel()
public void BySpecificChannel()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
var channels = new List<Channel>
{
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
});
};
var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels));

var report = Client.EventReports.ByChannel(evnt.Key, "channelKey1");

Expand Down
12 changes: 6 additions & 6 deletions SeatsioDotNet.Test/Events/BookObjectsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ public void KeepExtraData()
public void ChannelKeys()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
var channels = new List<Channel>
{
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
});
};
var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels));

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

Expand All @@ -107,11 +107,11 @@ public void ChannelKeys()
public void IgnoreChannels()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
var channels = new List<Channel>
{
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
});
};
var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels));

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

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

};
var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels));

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

Assert.Equal(new[] {"A-6"}, bestAvailableResult.Objects);
Expand All @@ -164,11 +164,11 @@ public void ChannelKeys()
public void IgnoreChannels()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
var channels = new List<Channel>
{
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-5"})
});
};
var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels));

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

Expand Down
14 changes: 7 additions & 7 deletions SeatsioDotNet.Test/Events/ChangeObjectStatusInBatchTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public void Test()
public void ChannelKeys()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
var channels = new List<Channel>
{
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1"})
});
};
var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels));

var result = Client.Events.ChangeObjectStatus(new[]
{
Expand All @@ -49,12 +49,12 @@ public void ChannelKeys()
public void IgnoreChannels()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
var channels = new List<Channel>
{
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1"})
});

};
var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels));

var result = Client.Events.ChangeObjectStatus(new[]
{
new StatusChangeRequest(evnt.Key, new[] {"A-1"}, "lolzor", ignoreChannels: true),
Expand Down
18 changes: 2 additions & 16 deletions SeatsioDotNet.Test/Events/Channels/ReplaceChannelsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void UpdateChannels()
var chartKey1 = CreateTestChart();
var event1 = Client.Events.Create(chartKey1);

var channels = new List<Channel>()
var channels = new List<Channel>
{
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}),
new("channelKey2", "channel 2", "#00FFFF", 2, new String[] { })
Expand All @@ -22,21 +22,7 @@ public void UpdateChannels()
Client.Events.Channels.Replace(event1.Key, channels);

var retrievedEvent = Client.Events.Retrieve(event1.Key);
Assert.Equal(2, retrievedEvent.Channels.Count);

var channel1 = retrievedEvent.Channels[0];
Assert.Equal("channelKey1", channel1.Key);
Assert.Equal("channel 1", channel1.Name);
Assert.Equal("#FFFF00", channel1.Color);
Assert.Equal(1, channel1.Index);
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(channel2.Objects);
Assert.Equivalent(channels, retrievedEvent.Channels);
}
}
}
35 changes: 26 additions & 9 deletions SeatsioDotNet.Test/Events/CreateEventTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public void TableBookingModeCustomCanBeUsed()
var chartKey = CreateTestChartWithTables();
var tableBookingConfig = TableBookingConfig.Custom(new() {{"T1", "BY_TABLE"}, {"T2", "BY_SEAT"}});

var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithTableBookingConfig(tableBookingConfig));
var evnt = Client.Events.Create(chartKey,
new CreateEventParams().WithTableBookingConfig(tableBookingConfig));

Assert.NotNull(evnt.Key);
Assert.Equal("CUSTOM", evnt.TableBookingConfig.Mode);
Expand All @@ -55,7 +56,8 @@ public void TableBookingModeInheritCanBeUsed()
{
var chartKey = CreateTestChartWithTables();

var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithTableBookingConfig(TableBookingConfig.Inherit()));
var evnt = Client.Events.Create(chartKey,
new CreateEventParams().WithTableBookingConfig(TableBookingConfig.Inherit()));

Assert.NotNull(evnt.Key);
Assert.Equal("INHERIT", evnt.TableBookingConfig.Mode);
Expand All @@ -82,29 +84,44 @@ public void CategoriesCanBePassedIn()
var categories = new[] {eventCategory};

var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithCategories(categories));

Assert.Equal(TestChartCategories.Count + categories.Length, evnt.Categories.Count);
Assert.Contains(eventCategory, evnt.Categories);
}
}

[Fact]
public void NameCanBePassedIn()
{
var chartKey = CreateTestChart();

var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithName("My event"));

Assert.Equal("My event", evnt.Name);
}
}

[Fact]
public void DateCanBePassedIn()
{
var chartKey = CreateTestChart();

var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithDate(new DateOnly(2022, 1, 10)));

Assert.Equal(new DateOnly(2022, 1, 10), evnt.Date);
}

[Fact]
public void ChannelsCanBePassedIn()
{
var chartKey = CreateTestChart();
var channels = new List<Channel>
{
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}),
new("channelKey2", "channel 2", "#00FFFF", 2, new String[] {})
};

var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels));

Assert.Equivalent(channels, evnt.Channels);
}
}
}
18 changes: 18 additions & 0 deletions SeatsioDotNet.Test/Events/CreateEventsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,24 @@ public void DateCanBePassedIn()
var events = Client.Events.Create(chartKey, eventCreationParams);

Assert.Equal(new DateOnly(2022, 1, 10), events[0].Date);
}

[Fact]
public void ChannelsCanBePassedIn()
{
var chartKey = CreateTestChart();
var channels = new List<Channel>
{
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}),
new("channelKey2", "channel 2", "#00FFFF", 2, new String[] {})
};

var events = Client.Events.Create(chartKey, new[]
{
new CreateEventParams().WithChannels(channels)
});

Assert.Equivalent(channels, events[0].Channels);
}
}
}
16 changes: 8 additions & 8 deletions SeatsioDotNet.Test/Events/HoldObjectsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ public void KeepExtraData()
public void ChannelKeys()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
HoldToken holdToken = Client.HoldTokens.Create();
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
var channels = new List<Channel>
{
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
});
};
var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels));
HoldToken holdToken = Client.HoldTokens.Create();

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

Expand All @@ -90,12 +90,12 @@ public void ChannelKeys()
public void IgnoreChannels()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
HoldToken holdToken = Client.HoldTokens.Create();
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
var channels = new List<Channel>
{
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
});
};
var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels));
HoldToken holdToken = Client.HoldTokens.Create();

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

Expand Down
12 changes: 6 additions & 6 deletions SeatsioDotNet.Test/Events/ReleaseObjectsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ public void KeepExtraData()
public void ChannelKeys()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
var channels = new List<Channel>
{
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
});
};
var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels));

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

Expand All @@ -88,11 +88,11 @@ public void ChannelKeys()
public void IgnoreChannels()
{
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
Client.Events.Channels.Replace(evnt.Key, new List<Channel>
var channels = new List<Channel>
{
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"})
});
};
var evnt = Client.Events.Create(chartKey, new CreateEventParams().WithChannels(channels));

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

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

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

[Fact]
public void ChannelsCanBePassedIn()
{
var chartKey = CreateTestChart();
var channels = new List<Channel>
{
new("channelKey1", "channel 1", "#FFFF00", 1, new[] {"A-1", "A-2"}),
new("channelKey2", "channel 2", "#00FFFF", 2, new String[] {})
};

var season = Client.Seasons.Create(chartKey, channels: channels);

Assert.Equivalent(channels, season.Channels);
}
}
}
1 change: 0 additions & 1 deletion SeatsioDotNet/Events/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public class Channel
public string Color { get; set; }
public int Index { get; set; }
public IEnumerable<string> Objects { get; set; }

public Channel()
{
}
Expand Down
Loading

0 comments on commit 707ff40

Please sign in to comment.