Exemplo n.º 1
0
        public void SerializerCanLoad()
        {
            string         filePath       = Path.Combine(this.Repo.GitParentPath, "test-file");
            FileSerializer fileSerializer = new FileSerializer(this.Repo.Context, filePath);

            this.Repo.Context.FileSystem.FileExists(filePath).ShouldEqual(false);
            fileSerializer.ReadAll().ShouldBeEmpty();
            this.Repo.Context.FileSystem.FileExists(filePath).ShouldEqual(true);

            List <string> lines = new List <string>()
            {
                "test1", "test2", "test3"
            };

            foreach (string line in lines)
            {
                fileSerializer.AppendLine(line);
            }

            fileSerializer.ReadAll().Count().ShouldEqual(lines.Count);
            IEnumerator <string> expectedLines = lines.GetEnumerator();

            expectedLines.MoveNext();
            foreach (string fileLine in fileSerializer.ReadAll())
            {
                expectedLines.Current.ShouldEqual(fileLine);
                expectedLines.MoveNext();
            }
        }