public void Send20MessagesAndThenPaginateHistory() { //Arrange Ably.RestClient ably = GetAbly(); IChannel channel = ably.Channels.Get("persisted:historyTest:" + _protocol.ToString()); //Act for (int i = 0; i < 20; i++) { channel.Publish("name" + i, "data" + i); } //Assert var history = channel.History(new DataRequestQuery() { Limit = 10 }); history.Should().HaveCount(10); history.HasNext.Should().BeTrue(); history.First().Name.Should().Be("name19"); var secondPage = channel.History(history.NextQuery); secondPage.Should().HaveCount(10); secondPage.First().Name.Should().Be("name9"); }
public void CanPublishAMessageAndRetrieveIt() { var items = (JArray)examples["items"]; Ably.RestClient ably = GetAbly(); IChannel channel = ably.Channels.Get("persisted:test", GetOptions()); var count = 0; foreach (var item in items) { var encoded = item["encoded"]; var encoding = (string)encoded["encoding"]; var decodedData = DecodeData((string)encoded["data"], encoding); channel.Publish((string)encoded["name"], decodedData); var message = channel.History().First(); if (message.Data is byte[]) { (message.Data as byte[]).Should().BeEquivalentTo(decodedData as byte[], "Item number {0} data does not match decoded data", count); } else if (encoding == "json") { JToken.DeepEquals((JToken)message.Data, (JToken)decodedData).Should().BeTrue("Item number {0} data does not match decoded data", count); } else { message.Data.Should().Be(decodedData, "Item number {0} data does not match decoded data", count); } count++; } }