Beispiel #1
0
            public async Task History_ForAnEncryptedChannel_DecryptsMessagesBeforeReturningThem()
            {
                //Arrange
                var rest    = GetRestClient();
                var message = new Message()
                {
                    Name = "test", Data = "Test"
                };
                var defaultParams = Crypto.GetDefaultParams();

                rest.ExecuteHttpRequest = request =>
                {
                    var response = new AblyResponse()
                    {
                        Headers      = DataRequestQueryTests.GetSampleHistoryRequestHeaders(),
                        TextResponse = $"[{JsonHelper.Serialize(message)}]"
                    };
                    return(response.ToTask());
                };

                var channel = rest.Channels.Get("test", new ChannelOptions(defaultParams));

                //Act
                var result = await channel.HistoryAsync();

                //Assert
                Assert.NotEmpty(result.Items);
                var firstMessage = result.Items.First();

                Assert.Equal(message.Data, firstMessage.Data);
            }
Beispiel #2
0
            public async Task History_WithPartialResult_ReturnsCorrectFirstCurrentAndNextLinks()
            {
                //Arrange
                var rest = GetRestClient(request => new AblyResponse()
                {
                    Headers      = DataRequestQueryTests.GetSampleHistoryRequestHeaders(),
                    TextResponse = "[]"
                }.ToTask());

                var channel = rest.Channels.Get("test");

                //Act
                var result = await channel.HistoryAsync();

                //Assert
                Assert.NotNull(result.NextDataQuery);
                Assert.NotNull(result.CurrentQuery);
                Assert.NotNull(result.FirstDataQuery);
            }