Exemple #1
0
        public async Task ExecuteCommandCreatesExecutionAndState()
        {
            Assert.IsNotNull(WakekApplication);
            Assert.AreEqual(0, WakekApplication.BenchmarkExecutions.Count);
            await WakekApplication.ApplicationCommandController.ExecuteAsync(typeof(ExecuteCommand));

            Assert.AreEqual(1, WakekApplication.BenchmarkExecutions.Count);
            var executionGuid = WakekApplication.BenchmarkExecutions[0].Guid;
            var states        = GetStatesForExecution(executionGuid, 1);
            var state         = states[0] as BenchmarkExecutionState;

            Assert.IsNotNull(state);
            var displayedStates = GetDisplayedStatesForExecution(1);
            var displayedState  = displayedStates[0];

            Assert.AreEqual(WakekApplication.SelectedBenchmarkDefinition.Description, displayedState.BenchmarkDescription);
            Assert.AreEqual(state.ExecutingForHowManySeconds, displayedState.ExecutingForHowManySeconds);
            Assert.AreEqual(state.Failures, displayedState.Failures);
            Assert.AreEqual(state.Successes, displayedState.Successes);
            Assert.AreEqual(state.RemoteExecutingForHowManySeconds, displayedState.RemoteExecutingForHowManySeconds);
            Assert.AreEqual(state.RemoteRequiringForHowManySeconds, displayedState.RemoteRequiringForHowManySeconds);
            Assert.AreEqual(state.Finished, displayedState.Finished);

            var feedback = new FeedbackToApplication {
                Type = FeedbackType.ImportantMessage, Message = Container.Resolve <IXmlSerializer>().Serialize(state)
            };
            var handled = await WakekApplication.HandleFeedbackToApplicationReturnSuccessAsync(feedback);

            Assert.IsTrue(handled);
            GetStatesForExecution(executionGuid, 1);

            var execution = Container.Resolve <IBenchmarkExecutionFactory>().CreateBenchmarkExecution(WakekApplication.BenchmarkDefinitions[0]);

            state    = Container.Resolve <IBenchmarkExecutionFactory>().CreateBenchmarkExecutionState(execution, 1) as BenchmarkExecutionState;
            feedback = new FeedbackToApplication {
                Type = FeedbackType.ImportantMessage, Message = Container.Resolve <IXmlSerializer>().Serialize(state)
            };
            handled = await WakekApplication.HandleFeedbackToApplicationReturnSuccessAsync(feedback);

            Assert.IsTrue(handled);
            GetStatesForExecution(2);
        }
Exemple #2
0
        public async Task WakekTestApplicationHandlesLogAndCommandDisabledFeedback()
        {
            var feedback = new FeedbackToApplication {
                Type = FeedbackType.LogWarning, Message = "Warning"
            };
            var handled = await Sut.HandleFeedbackToApplicationReturnSuccessAsync(feedback);

            Assert.IsTrue(handled);
            feedback = new FeedbackToApplication {
                Type = FeedbackType.LogError, Message = "Error"
            };
            handled = await Sut.HandleFeedbackToApplicationReturnSuccessAsync(feedback);

            Assert.IsTrue(handled);
            feedback = new FeedbackToApplication {
                Type = FeedbackType.CommandIsDisabled, Message = "Disabled", CommandType = typeof(ExecuteCommand)
            };
            handled = await Sut.HandleFeedbackToApplicationReturnSuccessAsync(feedback);

            Assert.IsTrue(handled);
        }