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>()); }
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); }
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); } }