Represents a color formatter which formats colors for a PowerShell ISE host.
상속: IColorFormatter
        public void GetBackgroundColor()
        {
            // Arrange.
            const string expectedColor = "color";
            var psobjects = new Collection<PSObject>
            {
                new PSObject(expectedColor)
            };
            const string command =
                "[string]$psISE.Options.OutputPaneTextBackgroundColor";

            var pipeline = MockRepository.GenerateMock<IPipeline>();
            pipeline.Expect(p => p.Invoke()).Return(psobjects);

            var runspace = MockRepository.GenerateMock<IRunspace>();
            runspace
                .Expect(r => r.CreateNestedPipeline(command, false))
                .Return(pipeline);

            var formatter = new PowerShellIseColorFormatter(runspace);

            // Act.
            var actualColor = formatter.GetBackgroundColor();

            // Assert.
            runspace.VerifyAllExpectations();
            pipeline.VerifyAllExpectations();
            Assert.AreEqual(expectedColor, actualColor);
        }
예제 #2
0
 /// <summary>
 /// Initializes a new cmdlet with a default color formatter.
 /// </summary>
 public FormatTestResultCmdlet()
 {
     ColorFormatter = new PowerShellIseColorFormatter(
         new RunspaceWrapper(Runspace.DefaultRunspace)
         );
     SuccessColor = DefaultSuccessColor;
     FailureColor = DefaultFailureColor;
 }
        public void CtorSavesRunspaceReference()
        {
            // Arrange.
            var expectedRunspace = MockRepository.GenerateStub<IRunspace>();

            // Act.
            var formatter = new PowerShellIseColorFormatter(expectedRunspace);

            // Assert.
            Assert.AreEqual(expectedRunspace, formatter.Runspace);
        }
        public void SetBackgroundColor()
        {
            // Arrange.
            const string color = "color";
            var command = string.Format(
                "$psISE.Options.OutputPaneTextBackgroundColor = '{0}'",
                color
            );

            var pipeline = MockRepository.GenerateMock<IPipeline>();
            pipeline.Expect(p => p.Invoke()).Return(null);

            var runspace = MockRepository.GenerateMock<IRunspace>();
            runspace
                .Expect(r => r.CreateNestedPipeline(command, false))
                .Return(pipeline);

            var formatter = new PowerShellIseColorFormatter(runspace);

            // Act.
            formatter.SetBackgroundColor(color);

            // Assert.
            runspace.VerifyAllExpectations();
            pipeline.VerifyAllExpectations();
        }