public void Test_Count() { TokenCollection col = TokenCollection.Deserialize(_JSON); Assert.AreEqual(0, col.get("superman")); Assert.AreEqual(3, col.get("hello")); Assert.AreEqual(1, col.get("chicken")); }
public void Test_From_JSON() { TokenCollection col = TokenCollection.Deserialize(_JSON); Assert.AreEqual(4, col.Sum); Assert.AreEqual(2, col.Count); Assert.AreEqual(3, col.get("hello")); Assert.AreEqual(1, col.get("chicken")); }
public void Test_Merge() { TokenCollection a = Create(new[] { "mouse", "mouse", "mouse" }); TokenCollection b = Create(new[] { "mouse", "chicken", "chicken" }); TokenCollection merge = TokenCollection.Merge(a, b); Assert.AreEqual(6, merge.Sum); Assert.AreEqual(4, merge.get("mouse")); Assert.AreEqual(2, merge.get("chicken")); }
public void Test_Add() { TokenCollection a = Create(new[] { "mouse", "mouse", "mouse" }); TokenCollection b = Create(new[] { "mouse", "chicken", "chicken" }); TokenCollection add = TokenCollection.Add(a, b); Assert.AreEqual(4, add.Sum); Assert.AreEqual(4, add.get("mouse")); Assert.IsFalse(add.Contains("chicken")); Assert.AreEqual(0, add.get("house")); }
public void Test_Subtract() { TokenCollection a = Create(new[] { "mouse", "mouse", "mouse" }); TokenCollection b = Create(new[] { "mouse", "chicken", "chicken" }); TokenCollection sub = TokenCollection.Subtract(a, b); Assert.AreEqual(2, sub.Sum); Assert.AreEqual(2, sub.get("mouse")); Assert.AreEqual(1, sub.Count); Assert.IsFalse(sub.Contains("chicken")); Assert.AreEqual(0, sub.get("chicken")); }
public void Test_Subtract_Empty() { TokenCollection a = Create(new[] { "mouse", "mouse", "mouse" }); TokenCollection b = Create(new[] { "mouse", "mouse", "mouse" }); TokenCollection sub = TokenCollection.Subtract(a, b); Assert.AreEqual(0, sub.Sum); Assert.AreEqual(0, sub.get("mouse")); Assert.AreEqual(0, sub.Count); }
protected static TokenCollection Create(string[] pTokens) { TokenCollection a = new TokenCollection(); foreach (string token in pTokens) { a.Add(token); } Assert.AreEqual(pTokens.Length, a.Sum); Assert.AreEqual(pTokens.Distinct().Count(), a.Count); foreach (string token in pTokens) { Assert.AreNotEqual(0, a.get(token)); } return(a); }