public void FormatStringOk() { var t = StringTokenEx.FormatString("test", "t{0}{1}", "es", "t"); Assert.Equal("test", t.Name); Assert.Equal("test", t.ToString(null)); Assert.Equal("test", t.ToString("f")); }
public void StringOk() { var t = StringTokenEx.String("test", "t"); Assert.Equal("test", t.Name); Assert.Equal("t", t.ToString(null)); Assert.Equal("t", t.ToString("f")); }
public TokenizedWriterTests() { var s = StringTokenProviderEx.Sequential(); s.Add(StringTokenEx.String("test", "1")); s.Add(StringTokenEx.DateTime("dt", _dt)); _provider = s; }
public void FuncOk() { var t = StringTokenEx.Func("test", f => "tt" + f); Assert.Equal("test", t.Name); Assert.Equal("tt", t.ToString(null)); Assert.Equal("ttf", t.ToString("f")); Assert.Equal("tto.O", t.ToString("o.O")); }
public void FormatStringCaches() { var diff = new ToStringDiff(); var t = StringTokenEx.FormatString("test", "t{0}{1}", "est", diff); Assert.Equal("test", t.Name); Assert.Equal("test1", t.ToString(null)); Assert.Equal("test1", t.ToString("f")); Assert.Equal(1, diff.I); }
public void DateTimeOk() { var dt = DateTime.Now.AddDays(-1); var t = StringTokenEx.DateTime("test", dt); Assert.Equal("test", t.Name); Assert.Equal(dt.ToString(CultureInfo.CurrentCulture), t.ToString(null)); Assert.Equal(dt.ToString("t"), t.ToString("t")); Assert.Equal(dt.ToString("G"), t.ToString("G")); Assert.Equal(dt.ToString("d"), t.ToString("d")); }
public void NameEqualsOk() { var str = StringTokenEx.String("test", "1"); Assert.True(str.NameEquals("test")); Assert.True(str.NameEquals("TEST")); Assert.True(str.NameEquals("Test")); Assert.False(str.NameEquals("none")); Assert.False(str.NameEquals("")); Assert.False(str.NameEquals(null)); }
private static void StorageOk(IStringTokenStorage storage) { Assert.Equal(0, storage.Count()); Assert.Null(storage.Get("test")); var test = StringTokenEx.String("test", "1"); storage.Add(test); Assert.True(storage.SequenceEqual(new []{test})); Assert.Equal(test, storage.Get("test")); var test2 = StringTokenEx.String("test", "2"); storage.Upsert(test2); Assert.Equal(test2, storage.Get("test")); Assert.True(storage.SequenceEqual(new[] { test2 })); var other = StringTokenEx.String("other", "3"); storage.Upsert(other); Assert.Equal(test2, storage.Get("test")); Assert.Equal(other, storage.Get("other")); Assert.True(storage.OrderBy(x => x.Name).SequenceEqual(new[] { other, test2 })); }
public void CombinedCombines() { var s1 = StringTokenProviderEx.Sequential(); var s2 = StringTokenProviderEx.Sequential(); var c = StringTokenProviderEx.Combine(s1, s2); Assert.Equal(0, c.Count()); var test1 = StringTokenEx.String("test", "1"); s2.Add(test1); Assert.True(c.SequenceEqual(new[] { test1 })); Assert.Equal(test1, c.Get("test")); var test2 = StringTokenEx.String("test", "2"); s1.Add(test2); Assert.True(c.SequenceEqual(new[] { test2, test1 })); Assert.Equal(test2, c.Get("test")); var other = StringTokenEx.String("other", "3"); s2.Upsert(other); Assert.Equal(test2, c.Get("test")); Assert.Equal(other, c.Get("other")); Assert.True(c.OrderBy(x => x.Name).SequenceEqual(new[] { other, test2, test1 })); }