public void TestReadOnlyCopyConstruct() { Guid id = new Guid("{53BC19DB-1D34-4995-82FE-8041C9E71EC5}"); IPolicyLanguageItem name = new NonTranslateableLanguageItem("Test routing"); RoutingTable httpRoutingTable = new RoutingTable(id, name, ChannelType.HTTP); Assert.AreEqual(id, httpRoutingTable.Identifier); Assert.IsFalse(httpRoutingTable.ReadOnly); Assert.AreEqual(name.Value, httpRoutingTable.Name.Value); Assert.IsNotNull(httpRoutingTable.DefaultDestination); Assert.IsNotNull(httpRoutingTable.DefaultSource); Assert.IsNotNull(httpRoutingTable[httpRoutingTable.DefaultSource, httpRoutingTable.DefaultDestination]); RoutingTable copy = new RoutingTable(httpRoutingTable, true, false); Assert.AreEqual(id, copy.Identifier); Assert.IsTrue(copy.ReadOnly); Assert.AreEqual(name.Value, copy.Name.Value); Assert.IsNotNull(copy.DefaultSource); Assert.IsNotNull(copy.DefaultDestination); Assert.IsNotNull(copy[copy.DefaultSource, copy.DefaultDestination]); Assert.IsNotNull(copy[copy.DefaultSource, copy.DefaultDestination].Name); Assert.IsNotInstanceOf(typeof(NonTranslateableLanguageItem), copy[copy.DefaultSource, copy.DefaultDestination].Name.GetType()); Assert.AreEqual(httpRoutingTable[httpRoutingTable.DefaultSource, httpRoutingTable.DefaultDestination].Identifier, copy[copy.DefaultSource, copy.DefaultDestination].Identifier); Assert.AreEqual(httpRoutingTable[httpRoutingTable.DefaultSource, httpRoutingTable.DefaultDestination].Name.Identifier, copy[copy.DefaultSource, copy.DefaultDestination].Name.Identifier); Assert.AreEqual(httpRoutingTable[httpRoutingTable.DefaultSource, httpRoutingTable.DefaultDestination].Name.Value, copy[copy.DefaultSource, copy.DefaultDestination].Name.Value); }
public void TestConstruct() { Guid id = new Guid("{53BC19DB-1D34-4995-82FE-8041C9E71EC5}"); IPolicyLanguageItem name = new NonTranslateableLanguageItem("Test routing"); RoutingTable routingTable = new RoutingTable(id, name, ChannelType.Mta); Assert.AreEqual(id, routingTable.Identifier); Assert.IsFalse(routingTable.ReadOnly); Assert.AreEqual(name.Value, routingTable.Name.Value); Assert.IsNotNull(routingTable.DefaultDestination); Assert.AreEqual(1, routingTable.Destinations.Count); Assert.IsNotNull(routingTable.DefaultSource); Assert.IsNotNull(routingTable[routingTable.DefaultSource, routingTable.DefaultDestination]); Assert.AreEqual(2, routingTable.Sources.Count); Assert.AreEqual("Mail server", routingTable.Sources[0].Name.Value); Assert.IsTrue(System.Convert.ToBoolean(routingTable.Sources[0][RoutingTable.DefaultGroupName].Value, System.Globalization.CultureInfo.CurrentCulture)); Assert.AreEqual("Blackberry", routingTable.Sources[1].Name.Value); Assert.IsTrue(string.IsNullOrEmpty(routingTable.Sources[1][RoutingTable.DefaultGroupName].Value)); Assert.IsNotNull(routingTable[routingTable.Sources[0], routingTable.DefaultDestination]); Assert.IsNotNull(routingTable[routingTable.Sources[1], routingTable.DefaultDestination]); }
public void TestConstruct() { Guid id = new Guid("{53BC19DB-1D34-4995-82FE-8041C9E71EC5}"); IPolicyLanguageItem name = new NonTranslateableLanguageItem("Test routing"); RoutingTable httpRoutingTable = new RoutingTable(id, name, ChannelType.HTTP); Assert.AreEqual(id, httpRoutingTable.Identifier); Assert.IsFalse(httpRoutingTable.ReadOnly); Assert.AreEqual(name.Value, httpRoutingTable.Name.Value); Assert.IsNotNull(httpRoutingTable.DefaultDestination); Assert.IsNotNull(httpRoutingTable.DefaultSource); Assert.IsNotNull(httpRoutingTable[httpRoutingTable.DefaultSource, httpRoutingTable.DefaultDestination]); }
public void TestReadOnlyCopyConstruct() { Guid id = new Guid("{53BC19DB-1D34-4995-82FE-8041C9E71EC5}"); IPolicyLanguageItem name = new NonTranslateableLanguageItem("Test routing"); RoutingTable activeContentRoutingTable = new RoutingTable(id, name, ChannelType.ActiveContent); Assert.AreEqual(id, activeContentRoutingTable.Identifier); Assert.IsFalse(activeContentRoutingTable.ReadOnly); Assert.AreEqual(name.Value, activeContentRoutingTable.Name.Value); Assert.IsNotNull(activeContentRoutingTable.DefaultDestination); Assert.IsNotNull(activeContentRoutingTable.DefaultSource); Assert.IsNotNull(activeContentRoutingTable[activeContentRoutingTable.DefaultSource, activeContentRoutingTable.DefaultDestination]); RoutingTable copy = new RoutingTable(activeContentRoutingTable, true, false); Assert.AreEqual(id, copy.Identifier); Assert.IsTrue(copy.ReadOnly); Assert.AreEqual(name.Value, copy.Name.Value); Assert.IsNotNull(copy.DefaultDestination); Assert.IsNotNull(copy.DefaultSource); Assert.IsNotNull(copy[copy.DefaultSource, copy.DefaultDestination]); }
public void TestCreateDataItem() { //Test that CreateDataItem correctly initialised data and returns Invariant format data items CultureInfo originalCulture = System.Threading.Thread.CurrentThread.CurrentCulture; try { //use french culture, so we can compare various current culture fields against invariant culture System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR"); //Test Boolean Boolean inputBool = false; NonTranslateableLanguageItem dataItemName = new NonTranslateableLanguageItem("boolean value"); DataItem dataItem = DataItem.CreateDataItem(dataItemName, DataType.Boolean, inputBool); Assert.IsTrue(dataItem.Name.Value == "boolean value", "Incorrect name on boolean"); Assert.IsTrue((Boolean)dataItem.Value == inputBool, "Incorrect name on boolean"); dataItem = DataItem.CreateDataItem(dataItemName, DataType.Boolean, inputBool.ToString(CultureInfo.InvariantCulture)); Assert.IsTrue(dataItem.Name.Value == "boolean value", "Incorrect name on boolean"); Assert.IsTrue((Boolean)dataItem.Value == inputBool, "Incorrect name on boolean"); //don't know of any culture where boolean format differs from invariant, so can't test that non-invariant culture throws exception //Test DateTime DateTime inputDateTime = new DateTime(2006, 9, 27, 15, 46, 12); dataItemName = new NonTranslateableLanguageItem("DateTime value"); dataItem = DataItem.CreateDataItem(dataItemName, DataType.DateTime, inputDateTime); Assert.IsTrue(dataItem.Name.Value == "DateTime value", "Incorrect name on DateTime"); Assert.IsTrue((DateTime)dataItem.Value == inputDateTime, "Incorrect value on DateTime"); dataItem = DataItem.CreateDataItem(dataItemName, DataType.DateTime, inputDateTime.ToString(CultureInfo.InvariantCulture)); Assert.IsTrue(dataItem.Name.Value == "DateTime value", "Incorrect name on DateTime"); Assert.IsTrue((DateTime)dataItem.Value == inputDateTime, "Incorrect value on DateTime"); Assert.IsFalse(inputDateTime.ToString(CultureInfo.CurrentCulture) == inputDateTime.ToString(CultureInfo.InvariantCulture), "Didn't expect current culture format to match invariant culture format"); //double check that we're not just returning culture culture format! try { dataItem = DataItem.CreateDataItem(dataItemName, DataType.DateTime, inputDateTime.ToString(CultureInfo.CurrentCulture)); Assert.IsFalse(false, "Didn't throw an exception on DateTime current culture"); } catch (FormatException) { Assert.IsTrue(true); } catch { Assert.IsFalse(false, "Threw an unexpected exception on DateTime current culture"); } //Test Double Double inputDouble = 10.2; dataItemName = new NonTranslateableLanguageItem("Double value"); dataItem = DataItem.CreateDataItem(dataItemName, DataType.Double, inputDouble); Assert.IsTrue(dataItem.Name.Value == "Double value", "Incorrect name on Double"); Assert.IsTrue((Double)dataItem.Value == inputDouble, "Incorrect value on Double"); dataItem = DataItem.CreateDataItem(dataItemName, DataType.Double, inputDouble.ToString(CultureInfo.InvariantCulture)); Assert.IsTrue(dataItem.Name.Value == "Double value", "Incorrect name on Double"); Assert.IsTrue((Double)dataItem.Value == inputDouble, "Incorrect value on Double"); Assert.IsFalse(inputDouble.ToString(CultureInfo.CurrentCulture) == inputDouble.ToString(CultureInfo.InvariantCulture), "Didn't expect current culture format to match invariant culture format"); //double check that we're not just returning culture culture format! try { dataItem = DataItem.CreateDataItem(dataItemName, DataType.DateTime, inputDouble.ToString(CultureInfo.CurrentCulture)); Assert.IsFalse(false, "Didn't throw an exception on Double current culture"); } catch (FormatException) { Assert.IsTrue(true); } catch { Assert.IsFalse(false, "Threw an unexpected exception on Double current culture"); } //Test Long long inputLong = 123456; dataItemName = new NonTranslateableLanguageItem("Long value"); dataItem = DataItem.CreateDataItem(dataItemName, DataType.Long, inputLong); Assert.IsTrue(dataItem.Name.Value == "Long value", "Incorrect name on Long"); Assert.IsTrue((long)dataItem.Value == inputLong, "Incorrect value on Long"); dataItem = DataItem.CreateDataItem(dataItemName, DataType.Long, inputLong.ToString(CultureInfo.InvariantCulture)); Assert.IsTrue(dataItem.Name.Value == "Long value", "Incorrect name on Long"); Assert.IsTrue((long)dataItem.Value == inputLong, "Incorrect value on Long"); //don't know of any culture where Long format differs from invariant, so can't test that non-invariant culture throws exception //Test String string inputString = "test data"; dataItemName = new NonTranslateableLanguageItem("String value"); dataItem = DataItem.CreateDataItem(dataItemName, DataType.String, inputString); Assert.IsTrue(dataItem.Name.Value == "String value", "Incorrect name on String"); Assert.IsTrue((string)dataItem.Value == inputString, "Incorrect value on String"); //don't know of any culture where string format differs from invariant, so can't test that non-invariant culture throws exception } finally { //remember to set back to original culture! System.Threading.Thread.CurrentThread.CurrentCulture = originalCulture; } }
public void TestCopyInternalExternalSmtpRoutingTable() { Guid id = new Guid("{DCFC6999-5A1C-43A3-8216-4B700EDFDD33}"); IPolicyLanguageItem routingName = new TranslateableLanguageItem("Internal External SMTP routing table"); IRoutingTable routingTable = new RoutingTable(id, routingName, ChannelType.SMTP); routingTable["resolve"] = new NonTranslateableLanguageItem("emailclient"); RoutingItemCollection interalGroup = new RoutingItemCollection(Guid.NewGuid(), "Recipients:Internal"); interalGroup.Add(new RoutingItem("Recipients:Internal", "Recipients:Internal")); interalGroup["InternalGroup"] = new NonTranslateableLanguageItem("true"); interalGroup["assembly"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver.dll"); interalGroup["class"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver"); routingTable.Destinations.Add(interalGroup); Assert.IsNotNull(routingTable); Assert.AreEqual(ChannelType.SMTP, routingTable.Type); Assert.AreEqual(routingName.Value, routingTable.Name.Value); IRoutingTable routingTableCopy = RoutingTableFactory.Instance.Copy(routingTable, false, true); Assert.IsNotNull(routingTableCopy); Assert.AreEqual(routingName.Value, routingTableCopy.Name.Value); Assert.AreEqual(ChannelType.SMTP, routingTableCopy.Type); Assert.AreNotEqual(routingTable.Identifier, routingTableCopy.Identifier); }