public void NewInstance_ClearInstance_NotPowerShell_AssemblyResolverIsNull_DoesNotThrow()
 {
     try
     {
         AutomationSession.NewInstance(TestParameters, null);
     }
     finally
     {
         AutomationSession.ClearInstance();
     }
 }
 public void ClearInstance_NoInstanceExists_ThrowsAutomationException_Automation011()
 {
     try
     {
         AutomationSession.ClearInstance();
     }
     catch (A11yAutomationException e)
     {
         Assert.IsTrue(e.Message.Contains(" Automation011:"));
         throw;
     }
 }
 public void SessionParameters_MatchesInputParameters()
 {
     try
     {
         AutomationSession session = AutomationSession.NewInstance(TestParameters, null);
         Assert.AreSame(TestParameters, session.SessionParameters);
     }
     finally
     {
         AutomationSession.ClearInstance();
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Execute the Stop command. Used by both .NET and by PowerShell entry points
 /// </summary>
 /// <returns>A StopCommandResult that describes the result of the command</returns>
 public static StopCommandResult Execute()
 {
     return(ExecutionWrapper.ExecuteCommand(() =>
     {
         AutomationSession.ClearInstance();
         return new StopCommandResult
         {
             Completed = true,
             SummaryMessage = DisplayStrings.SuccessStop,
             Succeeded = true,
         };
     }, ErrorCommandResultFactory));
 }
        public void Instance_InstanceExists_ReturnsSameInstance()
        {
            AutomationSession session = AutomationSession.NewInstance(TestParameters, null);

            Assert.IsNotNull(session);
            try
            {
                Assert.AreSame(session, AutomationSession.Instance());
            }
            finally
            {
                AutomationSession.ClearInstance();
            }
        }
        public void NewInstance_NoInstanceExists_ReturnsInstance()
        {
            AutomationSession session = null;

            try
            {
                session = AutomationSession.NewInstance(TestParameters, null);
            }
            finally
            {
                AutomationSession.ClearInstance();
            }

            Assert.IsNotNull(session);
        }
        public void NewInstance_ClearInstance_AssemblyResolverIsDisposed()
        {
            DummyDisposable assemblyResolver = new DummyDisposable();

            try
            {
                AutomationSession session = AutomationSession.NewInstance(TestParameters, assemblyResolver);
                Assert.AreEqual(0, assemblyResolver.TimesDisposed);
            }
            finally
            {
                AutomationSession.ClearInstance();
                Assert.AreEqual(1, assemblyResolver.TimesDisposed);
            }
        }
 public void NewInstance_ClearInstance_NotPowerShell_AssemblyResolverIsNull_DoesNotThrow()
 {
     using (ShimsContext.Create())
     {
         InitializeShims();
         try
         {
             AutomationSession.NewInstance(TestParameters, null);
         }
         finally
         {
             AutomationSession.ClearInstance();
         }
     }
 }
        public void SessionParameters_MatchesInputParameters()
        {
            using (ShimsContext.Create())
            {
                InitializeShims();

                try
                {
                    AutomationSession session = AutomationSession.NewInstance(TestParameters, null);
                    Assert.AreSame(TestParameters, session.SessionParameters);
                }
                finally
                {
                    AutomationSession.ClearInstance();
                }
            }
        }
        public void ClearInstance_NoInstanceExists_ThrowsAutomationException_Automation011()
        {
            using (ShimsContext.Create())
            {
                InitializeShims();

                try
                {
                    AutomationSession.ClearInstance();
                }
                catch (A11yAutomationException e)
                {
                    Assert.IsTrue(e.Message.Contains(" Automation011:"));
                    throw;
                }
            }
        }
        public void Instance_InstanceExists_ReturnsSameInstance()
        {
            using (ShimsContext.Create())
            {
                InitializeShims();

                AutomationSession session = AutomationSession.NewInstance(TestParameters, null);
                Assert.IsNotNull(session);
                try
                {
                    Assert.AreSame(session, AutomationSession.Instance());
                }
                finally
                {
                    AutomationSession.ClearInstance();
                }
            }
        }
        public void NewInstance_NoInstanceExists_ReturnsInstance()
        {
            AutomationSession session = null;

            using (ShimsContext.Create())
            {
                InitializeShims();
                try
                {
                    session = AutomationSession.NewInstance(TestParameters, null);
                }
                finally
                {
                    AutomationSession.ClearInstance();
                }
            }

            Assert.IsNotNull(session);
        }
        public void NewInstance_ClearInstance_AssemblyResolverIsDisposed()
        {
            using (ShimsContext.Create())
            {
                DummyDisposable assemblyResolver = new DummyDisposable();
                InitializeShims();

                try
                {
                    AutomationSession session = AutomationSession.NewInstance(TestParameters, assemblyResolver);
                    Assert.AreEqual(0, assemblyResolver.TimesDisposed);
                }
                finally
                {
                    AutomationSession.ClearInstance();
                    Assert.AreEqual(1, assemblyResolver.TimesDisposed);
                }
            }
        }
        public void NewInstance_InstanceAlreadyExists_ThrowsAutomationException_ErrorAutomation009()
        {
            AutomationSession session = AutomationSession.NewInstance(TestParameters, null);

            Assert.IsNotNull(session);

            try
            {
                AutomationSession.NewInstance(TestParameters, null);
            }
            catch (A11yAutomationException e)
            {
                Assert.IsTrue(e.Message.Contains(" Automation009:"));
                throw;
            }
            finally
            {
                AutomationSession.ClearInstance();
            }
        }