Skip to content

Commit

Permalink
Added statusChange.IsPresentOnChart and statusChange.NotPresentOnChar…
Browse files Browse the repository at this point in the history
…tReason (#50)

* Added statusChange.isPresentOnChart and statusChange.notPresentOnChartReason

* Fixed build

* Version bump
  • Loading branch information
mroloux authored Feb 24, 2022
1 parent dcad83e commit 2e13381
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
41 changes: 30 additions & 11 deletions SeatsioDotNet.Test/Events/ListStatusChangesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public void PropertiesOfStatusChange()
var chartKey = CreateTestChart();
var evnt = Client.Events.Create(chartKey);
var extraData = new Dictionary<string, object> {{"foo", "bar"}};
Client.Events.ChangeObjectStatus(evnt.Key, new[] {new ObjectProperties("A-1", extraData)}, "s1", null, "order1");
Client.Events.ChangeObjectStatus(evnt.Key, new[] {new ObjectProperties("A-1", extraData)}, "s1", null,
"order1");

var statusChanges = Client.Events.StatusChanges(evnt.Key).All();
var statusChange = statusChanges.First();
Expand All @@ -42,8 +43,25 @@ public void PropertiesOfStatusChange()
Assert.Equal(extraData, statusChange.ExtraData);
Assert.Equal("API_CALL", statusChange.Origin.Type);
Assert.NotNull(statusChange.Origin.Ip);
Assert.True(statusChange.IsPresentOnChart);
Assert.Null(statusChange.NotPresentOnChartReason);
}


[Fact]
public void NotPresentOnChartAnymore()
{
var chartKey = CreateTestChartWithTables();
var evnt = Client.Events.Create(chartKey, null, TableBookingConfig.AllByTable());
Client.Events.Book(evnt.Key, new[] {"T1"});
Client.Events.Update(evnt.Key, null, null, TableBookingConfig.AllBySeat());

var statusChanges = Client.Events.StatusChanges(evnt.Key).All();
var statusChange = statusChanges.First();

Assert.False(statusChange.IsPresentOnChart);
Assert.Equal("SWITCHED_TO_BOOK_BY_SEAT", statusChange.NotPresentOnChartReason);
}

[Fact]
public void Filter()
{
Expand All @@ -57,8 +75,8 @@ public void Filter()
var statusChanges = Client.Events.StatusChanges(evnt.Key, filter: "A-").All();

Assert.Equal(new[] {"A-3", "A-2", "A-1"}, statusChanges.Select(s => s.ObjectLabel));
}
}

[Fact]
public void SortAsc()
{
Expand All @@ -72,8 +90,8 @@ public void SortAsc()
var statusChanges = Client.Events.StatusChanges(evnt.Key, sortField: "objectLabel").All();

Assert.Equal(new[] {"A-1", "A-2", "A-3", "B-1"}, statusChanges.Select(s => s.ObjectLabel));
}
}

[Fact]
public void SortAscPageBefore()
{
Expand All @@ -89,8 +107,8 @@ public void SortAscPageBefore()
var statusChanges = statusChangeLister.PageBefore(statusChangeA3.Id, 2).Items;

Assert.Equal(new[] {"A-1", "A-2"}, statusChanges.Select(s => s.ObjectLabel));
}
}

[Fact]
public void SortAscPageAfter()
{
Expand All @@ -106,8 +124,8 @@ public void SortAscPageAfter()
var statusChanges = statusChangeLister.PageAfter(statusChangeA1.Id, 2).Items;

Assert.Equal(new[] {"A-2", "A-3"}, statusChanges.Select(s => s.ObjectLabel));
}
}

[Fact]
public void SortDesc()
{
Expand All @@ -118,7 +136,8 @@ public void SortDesc()
Client.Events.Book(evnt.Key, new[] {"B-1"});
Client.Events.Book(evnt.Key, new[] {"A-3"});

var statusChanges = Client.Events.StatusChanges(evnt.Key, sortField: "objectLabel", sortDirection: "DESC").All();
var statusChanges = Client.Events.StatusChanges(evnt.Key, sortField: "objectLabel", sortDirection: "DESC")
.All();

Assert.Equal(new[] {"B-1", "A-3", "A-2", "A-1"}, statusChanges.Select(s => s.ObjectLabel));
}
Expand Down
2 changes: 2 additions & 0 deletions SeatsioDotNet/Events/StatusChange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ public class StatusChange
public long EventId { get; set; }
public Dictionary<string, object> ExtraData { get; set; }
public StatusChangeOrigin Origin { get; set; }
public bool IsPresentOnChart { get; set; }
public string NotPresentOnChartReason { get; set; }
}
}
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>85.2.0</Version>
<Version>85.3.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 2e13381

Please sign in to comment.