public void CanReadAndWriteStringWithNullChar() { const int STR_LEN = 32; int rnd = RandomTools.RNG.Next(STR_LEN); string p1 = RandomTools.GetAlphaString(rnd); rnd = RandomTools.RNG.Next(STR_LEN); string p2 = RandomTools.GetAlphaString(rnd); string test = p1 + (char)0 + p2; using (MemoryStream ms = new MemoryStream()) { EZWriter.Write(ms, test); ms.Seek(0, SeekOrigin.Begin); string comp = EZReader.ReadString(ms); Assert.AreEqual(test, comp, "Strings don't match!"); } }
public void CanReadAndWriteString() { const int SIZE = 100; // The first string is null, because we need to be able to support this concept. List <string> testStrings = new List <string>() { null }; for (int i = 0; i < MAX_TEST; i++) { string test = RandomTools.GetAlphaString(SIZE); testStrings.Add(test); } foreach (var test in testStrings) { using (var ms = new MemoryStream()) { EZWriter.Write(ms, test); ms.Seek(0, SeekOrigin.Begin); string comp = EZReader.ReadString(ms); Assert.AreEqual(test, comp, "The strings should be the same!"); } } }