Exemple #1
0
        public void Execute_ClearInstanceSucceeds_ReturnsSuccessfulResult()
        {
            using (ShimsContext.Create())
            {
                int callsToClearInstance = 0;

                ShimAutomationSession.ClearInstance = () =>
                {
                    callsToClearInstance++;
                };

                StopCommandResult result = StopCommand.Execute();

                Assert.AreEqual(1, callsToClearInstance);
                Assert.AreEqual(true, result.Completed);
                Assert.AreEqual(true, result.Succeeded);
                Assert.IsFalse(string.IsNullOrWhiteSpace(result.SummaryMessage));
            }
        }
Exemple #2
0
        public void Execute_ClearInstanceThrowsAutomationException_ReturnsFailedResult()
        {
            const string exceptionMessage = "Hello from your local exception!";

            using (ShimsContext.Create())
            {
                int callsToClearInstance = 0;

                ShimAutomationSession.ClearInstance = () =>
                {
                    callsToClearInstance++;
                    throw new A11yAutomationException(exceptionMessage);
                };

                StopCommandResult result = StopCommand.Execute();

                Assert.AreEqual(1, callsToClearInstance);
                Assert.AreEqual(false, result.Completed);
                Assert.AreEqual(false, result.Succeeded);
                Assert.AreEqual(exceptionMessage, result.SummaryMessage);
            }
        }