public async Task GetHistoryUnitTest_ShouldSucceed()
        {
            var identity      = Identity.Parse(IdentityString);
            var client        = BuildSenderSubstitute_ReturnsSuccessStatus();
            var threadService = new ThreadService(client);
            var logger        = Substitute.For <ILogger>();
            var task          = threadService.GetHistoryAsync(identity, Enumerations.ChatOrder.Asc, logger, CancellationToken.None, DateTime.Parse("2018-12-06T10:16:50.088Z"));

            await TestInfoLogsWithOneArg <Identity>(task, 3, logger);
            await TestInfoLogsWithTwoArgs <Identity, IEnumerable <ThreadMessage> >(task, 1, logger);
        }
Example #2
0
        public async Task Get_History_UnitTest(string authKey)
        {
            var identity = Identity.Parse(IdentityString);
            IEnumerable <ThreadMessage> history;

            if (authKey.Equals(""))
            {
                history = await _threadService.GetHistoryAsync(identity, Enumerations.ChatOrder.Asc, _logger, CancellationToken.None, DateTime.Parse("2018-12-06T10:16:50.088Z"));
            }
            else
            {
                var threadService = new ThreadService(authKey);
                history = await threadService.GetHistoryAsync(identity, Enumerations.ChatOrder.Asc, _logger, CancellationToken.None, DateTime.Parse("2018-12-06T10:16:50.088Z"));
            }

            var historyList = history.ToList();

            historyList.Count.ShouldBeGreaterThan(0);
            historyList.OrderBy(h => h.Date).IsSameOrEqualTo(historyList);
        }
        public async Task GetHistoryLogUnitTest_ShouldThrowEx()
        {
            var identity        = Identity.Parse(IdentityString);
            var logger          = Substitute.For <ILogger>();
            var client          = BuildSenderSubstitute_ThrowsException();
            var threadService   = new ThreadService(client);
            var exceptionThrown = false;

            try
            {
                await threadService.GetHistoryAsync(identity, Enumerations.ChatOrder.Asc, logger, CancellationToken.None, DateTime.Parse("2018-12-06T10:16:50.088Z"));
            }
            catch (Exception ex)
            {
                logger.Received(1).Error(ex, Arg.Any <string>(), Arg.Any <Identity>());
                exceptionThrown = true;
            }
            finally
            {
                exceptionThrown.ShouldBe(true);
            }
        }