Ejemplo n.º 1
0
        public void No_Session()
        {
            var services = new MockContainer(MockBehavior.Strict)
                           .Push <IVariableService, MockVariableService>()
                           .GetValue <RestartManagerSession>(SessionManager.VariableName, () => null)
                           .Pop();

            using (fixture.UseServices(services))
            {
                fixture.Create()
                .AddCommand(CommandName)
                .Invoke();
            }

            services.Verify();
        }
Ejemplo n.º 2
0
        public void No_Session_Throws()
        {
            var services = new MockContainer(MockBehavior.Strict)
                           .Push <IVariableService, MockVariableService>()
                           .GetValue <RestartManagerSession>(SessionManager.VariableName, () => null)
                           .Pop();

            using (fixture.UseServices(services))
            {
                var sut = fixture.Create()
                          .AddCommand(CommandName);

                var ex = Assert.Throws <CmdletInvocationException>(() => sut.Invoke());
                Assert.IsType <NoSessionException>(ex.InnerException);
            }

            services.Verify();
        }
        public void Creates_Session_Throws()
        {
            var services = new MockContainer(MockBehavior.Strict)
                           .Push <IRestartManagerService>(error: NativeMethods.ERROR_OUTOFMEMORY)
                           .Pop()
                           .Push <IVariableService, MockVariableService>()
                           .GetValue <RestartManagerSession>(SessionManager.VariableName, () => null)
                           .Pop();

            using (fixture.UseServices(services))
            {
                var sut = fixture.Create()
                          .AddCommand(CommandName)
                          .AddParameter("PassThru");

                var ex = Assert.Throws <CmdletInvocationException>(() => sut.Invoke());
                Assert.IsType <OutOfMemoryException>(ex.InnerException);
            }

            services.Verify();
        }