Exemplo n.º 1
0
        public void TestBooleanSV()
        {
            PowerShellScriptTransform transform = new PowerShellScriptTransform();

            transform.ScriptPath = @"..\..\TestData\Transform-Boolean.ps1";

            this.ExecuteTest(transform, true, false);
        }
Exemplo n.º 2
0
        public void TestIntegerSV()
        {
            PowerShellScriptTransform transform = new PowerShellScriptTransform();

            transform.ScriptPath = @"..\..\TestData\Transform-Integer.ps1";

            this.ExecuteTest(transform, 1, 2);
        }
Exemplo n.º 3
0
        public void TestBinarySV()
        {
            PowerShellScriptTransform transform = new PowerShellScriptTransform();

            transform.ScriptPath = @"..\..\TestData\Transform-Binary.ps1";

            this.ExecuteTest(transform, new byte[] { 0, 1, 2, 3 }, new byte[] { 3, 2, 1, 0 });
        }
Exemplo n.º 4
0
        public void TestStringSV()
        {
            PowerShellScriptTransform transform = new PowerShellScriptTransform();

            transform.ScriptPath = @"..\..\TestData\Transform-String.ps1";

            this.ExecuteTest(transform, "Things & stuff", "THINGS & STUFF");
        }
Exemplo n.º 5
0
        public void PerformanceTest()
        {
            PowerShellScriptTransform transform = new PowerShellScriptTransform();

            transform.ScriptPath = @"..\..\TestData\Transform-String.ps1";

            UnitTestControl.PerformanceTest(() =>
            {
                Assert.AreEqual("THINGS & STUFF", transform.TransformValue("Things & stuff").First());
            }, 100000, 30000);
        }
Exemplo n.º 6
0
        private void ExecuteTest(PowerShellScriptTransform transform, IList <object> sourceValue, IList <object> expectedValue)
        {
            IList <object> outValue = transform.TransformValue(sourceValue);

            if (sourceValue.First() is byte[])
            {
                CollectionAssert.AreEqual(expectedValue.ToArray(), outValue.ToArray(), new ByteArrayComparer());
            }
            else
            {
                CollectionAssert.AreEqual(expectedValue.ToArray(), outValue.ToArray());
            }
        }
Exemplo n.º 7
0
        private void ExecuteTest(PowerShellScriptTransform transform, object sourceValue, object expectedValue)
        {
            object outValue = transform.TransformValue(sourceValue).FirstOrDefault();

            if (sourceValue is byte[])
            {
                CollectionAssert.AreEqual((byte[])expectedValue, (byte[])outValue);
            }
            else
            {
                Assert.AreEqual(expectedValue, outValue);
            }
        }
Exemplo n.º 8
0
        public void TestIntegerMV()
        {
            PowerShellScriptTransform transform = new PowerShellScriptTransform();

            transform.ScriptPath = @"..\..\TestData\Transform-Integer.ps1";

            this.ExecuteTest(transform, new List <object>()
            {
                1, 3, 5
            }, new List <object>()
            {
                2, 4, 6
            });
        }
Exemplo n.º 9
0
        public void TestStringMV()
        {
            PowerShellScriptTransform transform = new PowerShellScriptTransform();

            transform.ScriptPath = @"..\..\TestData\Transform-String.ps1";

            this.ExecuteTest(transform, new List <object>()
            {
                "Things & stuff", "test", "test2"
            }, new List <object>()
            {
                "THINGS & STUFF", "TEST", "TEST2"
            });
        }
Exemplo n.º 10
0
        public void TestBinaryMV()
        {
            PowerShellScriptTransform transform = new PowerShellScriptTransform();

            transform.ScriptPath = @"..\..\TestData\Transform-Binary.ps1";

            this.ExecuteTest(transform, new List <object>()
            {
                new byte[] { 0, 1, 2, 3 }, new byte[] { 4, 5, 6, 7 }
            }, new List <object>()
            {
                new byte[] { 3, 2, 1, 0 }, new byte[] { 7, 6, 5, 4 }
            });
        }
Exemplo n.º 11
0
        public void TestBooleanMV()
        {
            PowerShellScriptTransform transform = new PowerShellScriptTransform();

            transform.ScriptPath = @"..\..\TestData\Transform-Boolean.ps1";

            this.ExecuteTest(transform, new List <object>()
            {
                true, false, true
            }, new List <object>()
            {
                false, true, false
            });
        }
 public PowerShellScriptTransformViewModel(PowerShellScriptTransform model)
     : base(model)
 {
     this.model = model;
     this.Commands.AddItem("SelectFile", x => this.SelectFile());
 }