コード例 #1
0
        public void ParseFile_GivenInvalidFile_ReturnNull(string fileContents)
        {
            // Assemble
            byte[]       buffer = Encoding.ASCII.GetBytes(fileContents);
            MemoryStream ms     = new MemoryStream(buffer);
            StreamReader file   = new StreamReader(ms);

            // Act
            IList <Record> result = CJFileParser.ParseFile(file);

            // Assert
            Assert.AreEqual(result, null);
        }
コード例 #2
0
        public void ParseFile_GivenValidFile_ReturnRecordListWithElements()
        {
            // Assemble
            string fileContents = "Wilmerschmidt|John|Male|Perriwinkle|1984-11-11";

            byte[]       buffer = Encoding.ASCII.GetBytes(fileContents);
            MemoryStream ms     = new MemoryStream(buffer);
            StreamReader file   = new StreamReader(ms);

            // Act
            IList <Record> result = CJFileParser.ParseFile(file);

            // Assert
            IList <Record> expected = new List <Record>()
            {
                new Record("Wilmerschmidt", "John", "Male", "Perriwinkle", DateTime.Parse("1984-11-11"))
            };

            Assert.AreEqual(JsonConvert.SerializeObject(expected), JsonConvert.SerializeObject(result));
        }