Exemple #1
0
        public void DefaultFeedbackIsMessageOfNoImportance()
        {
            var feedback = new FeedbackToApplication();

            Assert.AreEqual(FeedbackType.MessageOfNoImportance, feedback.Type);
            Assert.AreEqual("", feedback.Message);
        }
Exemple #2
0
        public void StringFeedbackIsMessageOfImportanceOrNot()
        {
            var feedback = new FeedbackToApplication(TestMessage, false);

            Assert.AreEqual(FeedbackType.ImportantMessage, feedback.Type);
            Assert.AreEqual(TestMessage, feedback.Message);
            feedback = new FeedbackToApplication(TestMessage, true);
            Assert.AreEqual(FeedbackType.MessageOfNoImportance, feedback.Type);
            Assert.AreEqual(TestMessage, feedback.Message);
        }
        internal async Task <FeedbackToApplication> CreateFeedbackAndReportAsync(ApplicationCommandControllerTestExecutionContext context, FeedbackType type, string message)
        {
            var feedback = new FeedbackToApplication()
            {
                Type = type, Message = message
            };
            await context.ExecutionContext.ReportAsync(feedback);

            return(feedback);
        }
        public async Task ThenCommandCanBeDisabledViaFeedback()
        {
            var executionContext = new ApplicationCommandControllerTestExecutionContext(SimpleLogger);

            executionContext.Controller.AddCommand(new PrimeNumbersCommand(), true);
            Assert.IsTrue(await executionContext.Controller.EnabledAsync(typeof(PrimeNumbersCommand)));
            var feedback = new FeedbackToApplication()
            {
                Type = FeedbackType.DisableCommand, CommandType = typeof(PrimeNumbersCommand)
            };
            await executionContext.ExecutionContext.ReportAsync(feedback);

            Assert.IsFalse(await executionContext.Controller.EnabledAsync(typeof(PrimeNumbersCommand)));
        }
Exemple #5
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 #6
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);
        }
Exemple #7
0
        public void GuidIsDifferentForTwoNewPiecesOfFeedback()
        {
            IFeedbackToApplication feedback = new FeedbackToApplication(), moreFeedback = new FeedbackToApplication();

            Assert.AreNotEqual(feedback.Guid, moreFeedback.Guid);
        }