示例#1
0
        public void TestInteger()
        {
            object fakeTaskInstance = CreateFakeTask();

            XamlTestHelpers.SetProperty(fakeTaskInstance, "BasicInteger", 2);
            string expectedResult = "/always /Bi2 /Cr:CT";

            CheckCommandLine(expectedResult, XamlTestHelpers.GenerateCommandLine(fakeTaskInstance));
        }
示例#2
0
        public void TestDynamicEnum()
        {
            object fakeTaskInstance = CreateFakeTask();

            XamlTestHelpers.SetProperty(fakeTaskInstance, "BasicDynamicEnum", "MyBeforeTarget");
            string expectedResult = "/always MyBeforeTarget /Cr:CT";

            CheckCommandLine(expectedResult, XamlTestHelpers.GenerateCommandLine(fakeTaskInstance));
        }
示例#3
0
        /// <summary>
        /// XamlTaskFactory does not, in and of itself, support the idea of "always" switches or default values.  At least
        /// for Dev10, the workaround is to create a property as usual, and then specify the required values in the .props
        /// file.  Since these unit tests are just testing the task itself, this method serves as our ".props file".
        /// </summary>
        public object CreateFakeTask()
        {
            object fakeTaskInstance = _fakeTaskDll.CreateInstance("XamlTaskNamespace.FakeTask");

            XamlTestHelpers.SetProperty(fakeTaskInstance, "Always", true);
            XamlTestHelpers.SetProperty(fakeTaskInstance, "ComplexReversible", true);

            return(fakeTaskInstance);
        }
示例#4
0
        public void TestComplexIntegerGreaterThanMax()
        {
            object fakeTaskInstance = CreateFakeTask();

            XamlTestHelpers.SetProperty(fakeTaskInstance, "ComplexInteger", 256);
            string expectedResult = "/always /Ci256 /Cr:CT";

            CheckCommandLine(expectedResult, XamlTestHelpers.GenerateCommandLine(fakeTaskInstance));
        }
示例#5
0
        public void TestComplexIntegerWithinRange()
        {
            object fakeTaskInstance = CreateFakeTask();

            XamlTestHelpers.SetProperty(fakeTaskInstance, "ComplexInteger", 128);
            string expectedResult = "/always /Cr:CT /Ci128";

            CheckCommandLine(expectedResult, XamlTestHelpers.GenerateCommandLine(fakeTaskInstance));
        }
示例#6
0
        public void TestReversibleFlagsWithDefaults()
        {
            object fakeTaskInstance = CreateFakeTask();

            XamlTestHelpers.SetProperty(fakeTaskInstance, "BasicReversible", true);
            string expectedResult = "/always /Br /Cr:CT";

            CheckCommandLine(expectedResult, XamlTestHelpers.GenerateCommandLine(fakeTaskInstance));
        }
示例#7
0
        public void TestBasicString()
        {
            object fakeTaskInstance = CreateFakeTask();

            XamlTestHelpers.SetProperty(fakeTaskInstance, "BasicString", "Enum1");
            string expectedResult = "/always /Bs1 /Cr:CT";

            CheckCommandLine(expectedResult, XamlTestHelpers.GenerateCommandLine(fakeTaskInstance));
        }
示例#8
0
 public void TestComplexIntegerLessThanMin()
 {
     Assert.Throws <InvalidOperationException>(() =>
     {
         object fakeTaskInstance = CreateFakeTask();
         XamlTestHelpers.SetProperty(fakeTaskInstance, "ComplexInteger", 2);
     }
                                               );
 }
示例#9
0
        public void TestComplexStringArray()
        {
            object fakeTaskInstance = CreateFakeTask();

            string[] fakeArray = new string[] { "FakeFile1", "FakeFile2", "FakeFile3" };
            XamlTestHelpers.SetProperty(fakeTaskInstance, "ComplexStringArray", new object[] { fakeArray });
            string expectedResult = "/always /Cr:CT /CsaFakeFile1;FakeFile2;FakeFile3";

            CheckCommandLine(expectedResult, XamlTestHelpers.GenerateCommandLine(fakeTaskInstance));
        }
示例#10
0
        public void TestComplexString()
        {
            // check to see that the resulting value is good
            object fakeTaskInstance = CreateFakeTask();

            XamlTestHelpers.SetProperty(fakeTaskInstance, "ComplexString", "LegalValue1");
            string expectedResult = "/always /Cr:CT /Lv1";

            CheckCommandLine(expectedResult, XamlTestHelpers.GenerateCommandLine(fakeTaskInstance));
        }
 public void TestBasicInteger()
 {
     _fakeTaskDll = XamlTestHelpers.SetupGeneratedCode();
     object obj = _fakeTaskDll.CreateInstance("XamlTaskNamespace.FakeTask");
     XamlTestHelpers.SetProperty(obj, "BasicInteger", 1);
     Dictionary<string, CommandLineToolSwitch> switchList = (Dictionary<string, CommandLineToolSwitch>)XamlTestHelpers.GetProperty(obj, "ActiveToolSwitches");
     Assert.NotNull(switchList);
     string CommandLineToolSwitchOutput = switchList["BasicInteger"].SwitchValue + switchList["BasicInteger"].Separator + switchList["BasicInteger"].Number;
     Assert.Equal(CommandLineToolSwitchOutput, "/Bi1");
 }
 public void TestBasicDirectory()
 {
     _fakeTaskDll = XamlTestHelpers.SetupGeneratedCode();
     object obj = _fakeTaskDll.CreateInstance("XamlTaskNamespace.FakeTask");
     XamlTestHelpers.SetProperty(obj, "BasicDirectory", "FakeDirectory");
     Dictionary<string, CommandLineToolSwitch> switchList = (Dictionary<string, CommandLineToolSwitch>)XamlTestHelpers.GetProperty(obj, "ActiveToolSwitches");
     Assert.NotNull(switchList);
     string toolSwitchValue = switchList["BasicDirectory"].SwitchValue;
     Assert.True(String.IsNullOrEmpty(toolSwitchValue), "Expected nothing, got " + toolSwitchValue);
 }
 public void TestBasicFileWSwitch()
 {
     _fakeTaskDll = XamlTestHelpers.SetupGeneratedCode();
     object obj = _fakeTaskDll.CreateInstance("XamlTaskNamespace.FakeTask");
     XamlTestHelpers.SetProperty(obj, "BasicFileWSwitch", "File");
     Dictionary<string, CommandLineToolSwitch> switchList = (Dictionary<string, CommandLineToolSwitch>)XamlTestHelpers.GetProperty(obj, "ActiveToolSwitches");
     Assert.NotNull(switchList);
     string toolSwitchValue = switchList["BasicFileWSwitch"].SwitchValue;
     Assert.Equal(toolSwitchValue, "/Bfws");
 }
示例#14
0
        public void TestBasicStringArray()
        {
            object fakeTaskInstance = CreateFakeTask();

            string[] fakeArray = new string[1];
            fakeArray[0] = "FakeStringArray";
            XamlTestHelpers.SetProperty(fakeTaskInstance, "BasicStringArray", new object[] { fakeArray });
            string expectedResult = "/always /BsaFakeStringArray /Cr:CT";

            CheckCommandLine(expectedResult, XamlTestHelpers.GenerateCommandLine(fakeTaskInstance));
        }
 public void TestBasicNonreversible()
 {
     _fakeTaskDll = XamlTestHelpers.SetupGeneratedCode();
     object obj = _fakeTaskDll.CreateInstance("XamlTaskNamespace.FakeTask");
     XamlTestHelpers.SetProperty(obj, "BasicNonreversible", true);
     Dictionary<string, CommandLineToolSwitch> switchList = (Dictionary<string, CommandLineToolSwitch>)XamlTestHelpers.GetProperty(obj, "ActiveToolSwitches");
     Assert.NotNull(switchList);
     bool booleanValue = switchList["BasicNonreversible"].BooleanValue;
     Assert.True(booleanValue, "Actual BooleanValue is " + booleanValue.ToString());
     string toolSwitchValue = switchList["BasicNonreversible"].SwitchValue;
     Assert.Equal(toolSwitchValue, "/Bn");
 }
示例#16
0
        public void TestBasicStringArray()
        {
            _fakeTaskDll = XamlTestHelpers.SetupGeneratedCode();
            object obj = _fakeTaskDll.CreateInstance("XamlTaskNamespace.FakeTask");

            XamlTestHelpers.SetProperty(obj, "BasicStringArray", new string[1]);
            Dictionary <string, CommandLineToolSwitch> switchList = (Dictionary <string, CommandLineToolSwitch>)XamlTestHelpers.GetProperty(obj, "ActiveToolSwitches");

            Assert.IsNotNull(switchList);
            string toolSwitchValue = switchList["BasicStringArray"].SwitchValue;

            Assert.IsTrue(toolSwitchValue == "/Bsa", "Expected /Bsa, got " + toolSwitchValue);
        }
 public void TestBasicString()
 {
     _fakeTaskDll = XamlTestHelpers.SetupGeneratedCode();
     object obj = _fakeTaskDll.CreateInstance("XamlTaskNamespace.FakeTask");
     XamlTestHelpers.SetProperty(obj, "BasicString", "Enum1");
     Dictionary<string, CommandLineToolSwitch> switchList = (Dictionary<string, CommandLineToolSwitch>)XamlTestHelpers.GetProperty(obj, "ActiveToolSwitches");
     Assert.NotNull(switchList);
     string CommandLineToolSwitchOutput = switchList["BasicString"].SwitchValue;
     Assert.Equal(CommandLineToolSwitchOutput, "/Bs1");
     obj = _fakeTaskDll.CreateInstance("XamlTaskNamespace.FakeTask");
     XamlTestHelpers.SetProperty(obj, "BasicString", "Enum2");
     switchList = (Dictionary<string, CommandLineToolSwitch>)XamlTestHelpers.GetProperty(obj, "ActiveToolSwitches");
     Assert.NotNull(switchList);
     CommandLineToolSwitchOutput = switchList["BasicString"].SwitchValue;
     Assert.Equal(CommandLineToolSwitchOutput, "/Bs2");
 }
示例#18
0
        [Ignore] // Arguments are not supported in Dev10
        public void TestComplexNonreversible()
        {
            // When flag is set to false
            object fakeTaskInstance = CreateFakeTask();

            XamlTestHelpers.SetProperty(fakeTaskInstance, "ComplexNonreversibleWArgument", false);
            string expectedResult = "/always /Cr:CT";

            CheckCommandLine(expectedResult, XamlTestHelpers.GenerateCommandLine(fakeTaskInstance));

            // When flag is set to true
            fakeTaskInstance = CreateFakeTask();
            XamlTestHelpers.SetProperty(fakeTaskInstance, "ComplexNonreversibleWArgument", true);
            expectedResult = "/always /Cr:CT /CnrwaDefaultFile";
            CheckCommandLine(expectedResult, XamlTestHelpers.GenerateCommandLine(fakeTaskInstance));
        }
 public void TestBasicReversibleFalse()
 {
     _fakeTaskDll = XamlTestHelpers.SetupGeneratedCode();
     object obj = _fakeTaskDll.CreateInstance("XamlTaskNamespace.FakeTask");
     XamlTestHelpers.SetProperty(obj, "BasicReversible", false);
     Dictionary<string, CommandLineToolSwitch> switchList = (Dictionary<string, CommandLineToolSwitch>)XamlTestHelpers.GetProperty(obj, "ActiveToolSwitches");
     Assert.NotNull(switchList);
     bool booleanValue = switchList["BasicReversible"].BooleanValue;
     string toolSwitchValue;
     if (booleanValue)
     {
         toolSwitchValue = switchList["BasicReversible"].SwitchValue;
     }
     else
     {
         toolSwitchValue = switchList["BasicReversible"].ReverseSwitchValue;
     }
     Assert.Equal(toolSwitchValue, "/BrF");
 }
示例#20
0
        public void TestBasicReversibleTrue()
        {
            _fakeTaskDll = XamlTestHelpers.SetupGeneratedCode();
            object obj = _fakeTaskDll.CreateInstance("XamlTaskNamespace.FakeTask");

            XamlTestHelpers.SetProperty(obj, "BasicReversible", true);
            Dictionary <string, CommandLineToolSwitch> switchList = (Dictionary <string, CommandLineToolSwitch>)XamlTestHelpers.GetProperty(obj, "ActiveToolSwitches");

            Assert.IsNotNull(switchList);
            bool   booleanValue = switchList["BasicReversible"].BooleanValue;
            string toolSwitchValue;

            if (booleanValue)
            {
                toolSwitchValue = switchList["BasicReversible"].SwitchValue;
            }
            else
            {
                toolSwitchValue = switchList["BasicReversible"].SwitchValue + switchList["BasicReversible"].FalseSuffix;
            }
            Assert.IsTrue(toolSwitchValue == "/Br", "Expected /Br, got " + toolSwitchValue);
        }
示例#21
0
        public void TestComplexIntegerLessThanMin()
        {
            object fakeTaskInstance = CreateFakeTask();

            XamlTestHelpers.SetProperty(fakeTaskInstance, "ComplexInteger", 2);
        }