예제 #1
0
        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*");
        }
예제 #2
0
        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);
        }
예제 #3
0
        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();
        }
예제 #4
0
        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);
        }