public void TestGetDisplayName() { //nominal case - display name already set IPolicyObjectCollection<IDataItem> dataItems = new PolicyObjectCollection<IDataItem>(); dataItems.Add(DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, Enum.GetName(typeof(ConditionUnitFactory.FileHiddenDataType), ConditionUnitFactory.FileHiddenDataType.Markups))); dataItems.Add(DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, Enum.GetName(typeof(ConditionUnitFactory.FileHiddenDataType), ConditionUnitFactory.FileHiddenDataType.Bookmarks))); IDataElement dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("name"), new NonTranslateableLanguageItem("This is a preset Display Name"), DataType.StringArray, dataItems); ConditionDisplayParameterHiddenDataInPDF hiddenDataParam = new ConditionDisplayParameterHiddenDataInPDF(dataElement, this.Callback, null, Workshare.Policy.PolicyType.ClientEmail); Assert.AreEqual("Markups, Bookmarks", hiddenDataParam.GetDisplayName(), "unexpected displayname - displayname should be the same as dataElement"); //data items in collection dataElement.DisplayName.Value = ""; Assert.AreEqual(0, dataElement.DisplayName.Value.Length, "unexpected dataelement.displayname.value"); Assert.AreEqual("Markups, Bookmarks", hiddenDataParam.GetDisplayName(), "unexpected displayname"); Assert.AreEqual("Markups, Bookmarks", dataElement.DisplayName.Value, "unexpected dataelement.displayname.value"); //no data items in collection dataItems = new PolicyObjectCollection<IDataItem>(); dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("name"), new NonTranslateableLanguageItem(""), DataType.StringArray, dataItems); Assert.AreEqual(0, dataElement.DisplayName.Value.Length, "unexpected length on dataelement.displayname.value"); hiddenDataParam = new ConditionDisplayParameterHiddenDataInPDF(dataElement, this.Callback, null, Workshare.Policy.PolicyType.ClientEmail); Assert.AreEqual(Properties.Resources.IDS_EXPRESSION_PARAM_HIDDENDATA_DEFAULT, hiddenDataParam.GetDisplayName(), "unexpected displayname"); Assert.AreEqual(Properties.Resources.IDS_EXPRESSION_PARAM_HIDDENDATA_DEFAULT, dataElement.DisplayName.Value, "unexpected length on dataelement.displayname.value"); //invalid format for data dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("name"), new NonTranslateableLanguageItem(""), DataType.String, DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, Enum.GetName(typeof(ConditionUnitFactory.FileContextType), ConditionUnitFactory.FileContextType.Header))); hiddenDataParam = new ConditionDisplayParameterHiddenDataInPDF(null, this.Callback, null, Workshare.Policy.PolicyType.ClientEmail); hiddenDataParam.Object = dataElement; try { string displayName = hiddenDataParam.GetDisplayName(); Assert.IsTrue(false, "didn't throw on invalid data format"); } catch (PolicyDesignerException) { Assert.IsTrue(true); } catch { Assert.IsTrue(false, "Unexpected exception"); } //no data hiddenDataParam = new ConditionDisplayParameterHiddenDataInPDF(null, this.Callback, null, Workshare.Policy.PolicyType.ClientEmail); try { string displayName = hiddenDataParam.GetDisplayName(); Assert.IsTrue(false, "didn't throw on empty data"); } catch (PolicyDesignerException) { Assert.IsTrue(true); } catch { Assert.IsTrue(false, "Unexpected exception"); } }