Ejemplo n.º 1
0
        public void Session_Variable()
        {
            var services = new MockContainer(MockBehavior.Strict)
                           .Push <IRestartManagerService>()
                           .RegisterResources()
                           .GetProcesses()
                           .Pop()
                           .Push <IVariableService, MockVariableService>()
                           .GetValue(SessionManager.VariableName, s =>
            {
                var session = new RestartManagerSession(s);
                session.RegisterResources(files: new[] { @"C:\ShouldNotExist.txt" });

                return(session);
            })
                           .Pop();

            using (fixture.UseServices(services))
            {
                var output = fixture.Create()
                             .AddCommand(CommandName)
                             .AddStatement()
                             .AddCommand("Stop-RestartManagerSession")
                             .Invoke <IProcessInfo>();

                var expected = MockRestartManagerService.GetDefaultProcessesInfo(RebootReason.None);
                Assert.Equal(expected, output, ProcessComparer.Default);
            }

            services.Verify();
        }
Ejemplo n.º 2
0
        public void ProcessRecord()
        {
            var services = new MockContainer(MockBehavior.Strict)
                           .Push <IRestartManagerService>()
                           .RegisterResources()
                           .GetProcesses()
                           .Pop();

            using (var session = new RestartManagerSession(services))
            {
                session.RegisterResources(files: new[] { @"C:\ShouldNotExist.txt" });

                var output = fixture.Create()
                             .AddCommand(CommandName)
                             .AddParameter("Session", session)
                             .Invoke <IProcessInfo>();

                var expected = MockRestartManagerService.GetDefaultProcessesInfo(RebootReason.None);
                Assert.Equal(expected, output, ProcessComparer.Default);
            }

            services.Verify();
        }