public void TestFile() { FileName v1 = new FileName("c:/foo.txt"); FileName v2 = (FileName)CloneObject(v1); Assert.IsTrue(!Object.ReferenceEquals(v1, v2)); Assert.AreEqual(v1, v2); }
public void TestCreateTestConfiguration() { IDictionary<string, object> expectedData = new Dictionary<string, object>(); expectedData["String"] = "retipipiter"; expectedData["StringArray"] = new [] { "value1", "value2", "value3" }; expectedData["Long"] = 11L; expectedData["LongArray"] = new []{12L, 13L}; expectedData["LongObject"] = 14L; expectedData["LongObjectArray"] = new long?[]{15, null}; expectedData["Char"] = 'a'; expectedData["CharArray"] = new []{'b','c'}; expectedData["Character"] = 'd'; expectedData["CharacterArray"] = new char?[]{'e','f'}; expectedData["Double"] = 0D; expectedData["DoubleArray"] = new []{0D, 100D}; expectedData["DoubleObject"] = 0d; expectedData["DoubleObjectArray"] = new double?[] { 0D, 100D }; expectedData["Float"] = 0F; expectedData["FloatArray"] = new[] { 0F, 100F }; expectedData["FloatObject"] = null; expectedData["FloatObjectArray"] = new float?[] { 0F, 100F }; expectedData["Int"] = 0; expectedData["IntArray"] = new[] { 0, 100 }; expectedData["Integer"] = 0; expectedData["IntegerArray"] = new int?[] { 0, 100 }; expectedData["Boolean"] = true; expectedData["BooleanArray"] = new[]{true, false}; expectedData["BooleanObject"] = false; expectedData["BooleanObjectArray"] = new bool?[] { true, false }; expectedData["URI"] = new Uri("http://localhost:8080"); expectedData["URIArray"] = ""; expectedData["URIArray"] = new[] { new Uri("http://localhost:8080"), new Uri("http://localhost:8443") }; expectedData["File"] = new FileName("c:\\Users\\Admin"); expectedData["FileArray"] = new[] {new FileName("c:\\Users\\Admin\\Documents"), new FileName("c:\\Users\\Admin\\Settings")}; var array = new GuardedByteArray(); Encoding.UTF8.GetBytes("array").ToList().ForEach(array.AppendByte); expectedData["GuardedByteArray"] = array; array = new GuardedByteArray(); Encoding.UTF8.GetBytes("item1").ToList().ForEach(array.AppendByte); var array2 = new GuardedByteArray(); Encoding.UTF8.GetBytes("item2").ToList().ForEach(array2.AppendByte); expectedData["GuardedByteArrayArray"] = new []{array, array2}; var secret = new GuardedString(); "secret".ToCharArray().ToList().ForEach(secret.AppendChar); expectedData["GuardedString"] = secret; secret = new GuardedString(); "secret1".ToCharArray().ToList().ForEach(secret.AppendChar); var secret2 = new GuardedString(); "secret2".ToCharArray().ToList().ForEach(secret2.AppendChar); expectedData["GuardedStringArray"] = new[]{secret, secret2}; expectedData["Script"] = new ScriptBuilder { ScriptLanguage = "PowerShell", ScriptText = "echo 'Hello OpenICF Developer'" }.Build(); expectedData["ScriptArray"] = new[]{new ScriptBuilder { ScriptLanguage = "Groovy", ScriptText = "println 'Hello'" }.Build(),new ScriptBuilder { ScriptLanguage = "Groovy", ScriptText = "println 'OpenICF Developer'" }.Build()}; Environment.SetEnvironmentVariable(TestHelpers.TestConfigEVName, "converter"); FieldInfo info = typeof (TestHelpers).GetField("_propertyBags", BindingFlags.NonPublic | BindingFlags.Static); (info.GetValue(null) as Dictionary<string, PropertyBag>).Clear(); PropertyBag propertyBag = TestHelpers.GetProperties(typeof(Org.IdentityConnectors.TestConnector.FakeConnector)); (info.GetValue(null) as Dictionary<string, PropertyBag>).Clear(); APIConfiguration testable = TestHelpers.CreateTestConfiguration(SafeType<Connector>.Get<Org.IdentityConnectors.TestConnector.FakeConnector>(), propertyBag, null); foreach (KeyValuePair<string, object> entry in expectedData) { Assert.AreEqual(entry.Value, testable.ConfigurationProperties.GetProperty(entry.Key).Value, "Configuration property: " + entry.Key + " has different value"); } }