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 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 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"); }
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"); }
public void TestGenerateIntegers() { _fakeTaskDll = XamlTestHelpers.SetupGeneratedCode(); object obj = _fakeTaskDll.CreateInstance("XamlTaskNamespace.FakeTask"); PropertyInfo pi = obj.GetType().GetProperty("BasicInteger"); Assert.NotNull(pi); // "Shouldn't be null" Assert.Equal(pi.PropertyType, typeof(int)); // "PropertyType should be an int" object[] attributes = pi.GetCustomAttributes(true); foreach (object attribute in attributes) { Assert.Equal((attribute.GetType().GetProperty("SwitchName").GetValue(attribute, null).ToString()), "/Bi"); } }
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 TestGenerateStrings() { _fakeTaskDll = XamlTestHelpers.SetupGeneratedCode(); object obj = _fakeTaskDll.CreateInstance("XamlTaskNamespace.FakeTask"); PropertyInfo pi = obj.GetType().GetProperty("BasicString"); Assert.IsNotNull(pi, "Shouldn't be null"); Assert.IsTrue(pi.PropertyType == typeof(string), "PropertyType should be a string"); object[] attributes = pi.GetCustomAttributes(true); foreach (object attribute in attributes) { Assert.IsTrue((attribute.GetType().GetProperty("SwitchName").GetValue(attribute, null).ToString()) == "/Bs"); } }
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"); }
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"); }
public void TestGenerateStringArrays() { _fakeTaskDll = XamlTestHelpers.SetupGeneratedCode(); object obj = _fakeTaskDll.CreateInstance("XamlTaskNamespace.FakeTask"); PropertyInfo pi = obj.GetType().GetProperty("BasicStringArray"); Assert.NotNull(pi); // "Shouldn't be null" Assert.Equal(pi.PropertyType, typeof(string[])); // "PropertyType should be a stringarray" object[] attributes = pi.GetCustomAttributes(true); foreach (object attribute in attributes) { PropertyInfo documentationAttribute = attribute.GetType().GetProperty("SwitchName"); if (documentationAttribute != null) { Assert.Equal((attribute.GetType().GetProperty("SwitchName").GetValue(attribute, null).ToString()), "/Bsa"); } else { // required attribute Assert.True(attribute is RequiredAttribute); } } }
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); }
public void SetupGeneratedCode() { _fakeTaskDll = XamlTestHelpers.SetupGeneratedCode(); }
public void TestQuotingBackslashes() { _fakeTaskDll = XamlTestHelpers.SetupGeneratedCode(XamlTestHelpers.QuotingBackslashXml); object obj = _fakeTaskDll.CreateInstance("XamlTaskNamespace.FakeTask"); }