public void FoldShouldWorkCorrectOnSameType() { Assert.AreEqual(24, FunctionsOnLists.Fold(new List <int>() { 2, 3, 4 }, 1, (cur, next) => cur * next)); }
public void FoldShouldWorkCorrectOnDifferentTypes() { Assert.AreEqual(24, FunctionsOnLists.Fold(new List <string>() { "aa", "aaa", "aaaa" }, 1, (cur, next) => cur * next.Length)); }
public void FilterShouldReturnsEmptyList() { Assert.IsEmpty(FunctionsOnLists.Filter(new List <string>() { "kek", "lol" }, x => x.Contains('a'))); Assert.IsEmpty(FunctionsOnLists.Filter(new List <string>(), x => true)); }
public void FilterShouldWorkCorrectOnIntegers() { CollectionAssert.AreEqual( new List <int>() { 1, 3 }, FunctionsOnLists.Filter(new List <int>() { 1, 2, 3 }, x => x % 2 == 1)); }
public void MapShouldGiveCorrectResultOnDifferentTypes() { CollectionAssert.AreEqual( new List <bool>() { false, true, false }, FunctionsOnLists.Map(new List <string>() { "kek", "KaRaNtIn", "lol" }, x => x.Contains('a'))); }
public void MapShouldGiveCorrectResultOnIntegers() { CollectionAssert.AreEqual( new List <int>() { 2, 4, 6 }, FunctionsOnLists.Map(new List <int>() { 1, 2, 3 }, x => x * 2)); }
public void FoldShouldWorkCorrectWithEmptyList() { Assert.AreEqual(173, FunctionsOnLists.Fold(new List <int>(), 173, (cur, next) => 0)); }
public void MapShouldReturnEmptyListOnEmptyLists() { Assert.IsEmpty(FunctionsOnLists.Map(new List <string>(), x => string.Empty)); Assert.IsEmpty(FunctionsOnLists.Map(new List <bool>(), x => x.ToString())); }