public void ConvertTestWithBlanks() { ArrayToStringConverter target = new ArrayToStringConverter(); string val = (string)target.Convert(new[] { "Hello", "", null, "World." }, typeof(string), null, null); Assert.AreEqual("Hello,World.", val); }
public void EmptyTest() { ArrayToStringConverter target = new ArrayToStringConverter(); string value = (string)target.Convert(new [] { null, "", "", null }, typeof(string), null, null); Assert.AreEqual(value, string.Empty); }
public void NullTest() { ArrayToStringConverter target = new ArrayToStringConverter(); object value = target.Convert(null, typeof(string), null, null); Assert.AreSame(string.Empty, value); value = target.ConvertBack(null, typeof(string), null, null); Assert.IsInstanceOfType(value, typeof(string[])); }
public void ConvertTestWithSeparator() { ArrayToStringConverter target = new ArrayToStringConverter() { Separator = " " }; string val = (string)target.Convert(new[] { "This", "is", "a", "Test" }, typeof(string), null, null); Assert.AreEqual("This is a Test", val); }
public void ArrayToStringConverterTest() { var conv = new ArrayToStringConverter(); var a = new[] { "asd", "qwe", "zzz" }; var b = new[] { 1, 2, 3 }; var aForward = conv.Convert(a, null, ";", _cult) as string; var bForward = conv.Convert(b, null, null, _cult) as string; Assert.IsNotNull(aForward); Assert.AreEqual("asd;qwe;zzz", aForward); Assert.IsNotNull(bForward); Assert.AreEqual("1, 2, 3", bForward); var aBack = conv.ConvertBack(aForward, null, ";", _cult) as string[]; var bBack = conv.ConvertBack(bForward, null, null, _cult) as string[]; Assert.IsNotNull(aBack); CollectionAssert.AreEqual(a, aBack); Assert.IsNotNull(bBack); CollectionAssert.AreEqual(b, bBack.Select(int.Parse).ToArray()); }
public void TagsConverter() { var arrayToStringConverter = new ArrayToStringConverter(); string[] tags = new string[] { "Turn-Based Strategy", "Tactical", "Strategy", "Sci-fi", "Turn-Based" }; Assert.Equal("Turn-Based Strategy, Tactical, Strategy, Sci-fi, Turn-Based", arrayToStringConverter.Convert(tags, typeof(string), null, CultureInfo.InvariantCulture)); }
public void GetWordCounts() { if (this.Clauses == null) { return; } List <Tuple <string, string> > bigrams = new List <Tuple <string, string> >(); foreach (ClausalItem clause in this.Clauses) { bigrams.AddRange(clause.GetBigrams()); } ArrayToStringConverter converter = new ArrayToStringConverter(); this.Output = $"Word Counts:\r\n{converter.Convert(LinqFish.Calculator.GetWordCounts(bigrams), null, null, null).ToString()}\r\nWord Frequency:\r\n{converter.Convert(LinqFish.Calculator.GetInstanceDistribution(bigrams), null, null, null)}"; }
public void ConvertBadParameters() { ArrayToStringConverter target = new ArrayToStringConverter(); target.Convert("test", typeof(string), null, null); }