public void NullConditions() { MultiTextBase text = new MultiTextBase(); Assert.AreSame(string.Empty, text["foo"], "never before heard of alternative should give back an empty string"); Assert.AreSame(string.Empty, text["foo"], "second time"); Assert.AreSame(string.Empty, text.GetBestAlternative("fox")); text.SetAlternative("zox", ""); Assert.AreSame(string.Empty, text["zox"]); text.SetAlternative("zox", null); Assert.AreSame(string.Empty, text["zox"], "should still be empty string after setting to null"); text.SetAlternative("zox", "something"); text.SetAlternative("zox", null); Assert.AreSame(string.Empty, text["zox"], "should still be empty string after setting something and then back to null"); }
public void UsesNextAlternativeWhenMissing() { MultiTextBase MultiTextBase = new MultiTextBase(); MultiTextBase["wsWithNullElement"] = null; MultiTextBase["wsWithEmptyElement"] = ""; MultiTextBase["wsWithContent"] = "hello"; Assert.AreEqual(String.Empty, MultiTextBase.GetExactAlternative("missingWs")); Assert.AreEqual(String.Empty, MultiTextBase.GetExactAlternative("wsWithEmptyElement")); Assert.AreEqual("hello", MultiTextBase.GetBestAlternative("missingWs")); Assert.AreEqual("hello", MultiTextBase.GetBestAlternative("wsWithEmptyElement")); Assert.AreEqual("hello*", MultiTextBase.GetBestAlternative("wsWithEmptyElement", "*")); Assert.AreEqual("hello", MultiTextBase.GetBestAlternative("wsWithNullElement")); Assert.AreEqual("hello*", MultiTextBase.GetBestAlternative("wsWithNullElement", "*")); Assert.AreEqual("hello", MultiTextBase.GetExactAlternative("wsWithContent")); Assert.AreEqual("hello", MultiTextBase.GetBestAlternative("wsWithContent")); Assert.AreEqual("hello", MultiTextBase.GetBestAlternative("wsWithContent", "*")); }