public void CannotLogIfLaunchNotStarted() { var service = new MockServiceBuilder().Build(); var launch = new LaunchReporter(service.Object, null, null, new ExtensionManager()); Action act = () => launch.Log(new CreateLogItemRequest { Time = DateTime.UtcNow, Text = "log" }); act.Should().Throw <InsufficientExecutionStackException>().WithMessage("*launch wasn't scheduled for starting*"); }
public void ShouldBeAbleToLogIntoLaunch() { var service = new MockServiceBuilder().Build(); var launch = new LaunchReporter(service.Object, null, null, new ExtensionManager()); launch.Start(new StartLaunchRequest() { StartTime = DateTime.UtcNow }); launch.Log(new CreateLogItemRequest { Time = DateTime.UtcNow, Text = "log" }); launch.Finish(new FinishLaunchRequest() { EndTime = DateTime.UtcNow }); launch.Sync(); service.Verify(s => s.LogItem.CreateAsync(It.IsAny <CreateLogItemRequest[]>()), Times.Once); }
public void FailedLaunchLogShouldNotBreakReporting() { var service = new MockServiceBuilder().Build(); service.Setup(s => s.LogItem.CreateAsync(It.IsAny <CreateLogItemRequest>())).Throws(new Exception()); var launch = new LaunchReporter(service.Object, null, null, new ExtensionManager()); launch.Start(new StartLaunchRequest() { StartTime = DateTime.UtcNow }); launch.Log(new CreateLogItemRequest { Time = DateTime.UtcNow, Text = "log" }); launch.Finish(new FinishLaunchRequest() { EndTime = DateTime.UtcNow }); launch.Sync(); }
public void ShouldNotLogIfLaunchFailedToStart() { var service = new MockServiceBuilder().Build(); service.Setup(s => s.Launch.StartAsync(It.IsAny <StartLaunchRequest>())).Throws(new Exception()); var launch = new LaunchReporter(service.Object, null, null, new ExtensionManager()); launch.Start(new StartLaunchRequest() { StartTime = DateTime.UtcNow }); launch.Log(new CreateLogItemRequest { Time = DateTime.UtcNow, Text = "log" }); Action waitAct = () => launch.Sync(); waitAct.Should().Throw <Exception>(); service.Verify(s => s.LogItem.CreateAsync(It.IsAny <CreateLogItemRequest>()), Times.Never); }