示例#1
0
        public async Task Add_LogUnitTest_ShouldSucceed()
        {
            Identity identity          = Identity.Parse(RecipientIdentity);
            var      client            = BuildSenderSubstitute_ReturnsSuccessStatus();
            var      eventTrackService = new EventTrackService(client);
            var      logger            = Substitute.For <ILogger>();
            var      task = await eventTrackService.AddAsync(Category, Action, logger, identity : identity);

            logger.Received(2).Information(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>());
        }
示例#2
0
        public async Task Add_UnitTest(string authKey, bool fireAndForget)
        {
            Command  addResponse;
            Identity identity = Identity.Parse(RecipientIdentity);

            if (fireAndForget)
            {
                addResponse = await _eventTrackService.AddAsync(Category, Action, _logger, contact : contact, fireAndForget : fireAndForget);
            }
            else if (authKey == "")
            {
                addResponse = await _eventTrackService.AddAsync(Category, Action, _logger, identity : identity);
            }
            else
            {
                var eventTrackService = new EventTrackService(authKey);
                addResponse = await eventTrackService.AddAsync(Category, Action, _logger, contact : contact);
            }

            addResponse.Status.ShouldBe(CommandStatus.Success);
        }
示例#3
0
        public async Task Add_LogUnitTest_ShouldThrowBlipHttpClientException()
        {
            Identity identity          = Identity.Parse(RecipientIdentity);
            var      client            = BuildSenderSubstitute_ReturnsFailureStatus();
            var      eventTrackService = new EventTrackService(client);
            var      logger            = Substitute.For <ILogger>();
            var      exceptionThrown   = false;

            try
            {
                await eventTrackService.AddAsync(Category, Action, logger, identity : identity);
            }
            catch (BlipHttpClientException bex)
            {
                logger.Received(1).Error(bex, Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>());
                exceptionThrown = true;
            }
            finally
            {
                exceptionThrown.ShouldBe(true);
            }
        }