public void should_write_a_poco()
        {
            var parentFormat = new DocumentFormat("parent");

            var o = new Parent();

            o.AddChild("one");
            o.AddChild("于百");

            var id = _fs.Save(parentFormat, o);

            Assert.AreEqual(new BlobId(parentFormat, 1), id);

            var descriptor = _fs.GetDescriptor(id);

            Assert.AreEqual(
                new FileNameWithExtension("Parent.json"),
                descriptor.FileNameWithExtension
                );

            using (var stream = descriptor.OpenRead())
                using (var reader = new StreamReader(stream))
                {
                    var asString = reader.ReadToEnd();
                    Assert.AreEqual("{\"Format\":null,\"Childs\":[{\"Value\":\"one\"},{\"Value\":\"于百\"}]}", asString);

                    stream.Seek(0, SeekOrigin.Begin);
                    Assert.AreEqual(0xEF, stream.ReadByte(), "Missing UTF-8 BOM");
                    Assert.AreEqual(0xBB, stream.ReadByte(), "Missing UTF-8 BOM");
                    Assert.AreEqual(0xBF, stream.ReadByte(), "Missing UTF-8 BOM");
                }
        }
        public IBlobStore ForFormat(DocumentFormat format)
        {
            if (format == DocumentFormats.Original)
            {
                return _originals;
            }

            return _artifacts;
        }
Beispiel #3
0
        public IBlobStore ForFormat(DocumentFormat format)
        {
            if (format == DocumentFormats.Original)
            {
                return(_originals);
            }

            return(_artifacts);
        }
        public void should_write_a_poco()
        {
            var parentFormat = new DocumentFormat("parent");

            var o = new Parent();
            o.AddChild("one");
            o.AddChild("于百");

            var id = _fs.Save(parentFormat, o);
            Assert.AreEqual(new BlobId(parentFormat, 1), id);

            var descriptor = _fs.GetDescriptor(id);

            Assert.AreEqual(
                new FileNameWithExtension("Parent.json"), 
                descriptor.FileNameWithExtension
            );

            using(var stream = descriptor.OpenRead())
            using (var reader = new StreamReader(stream))
            {
                var asString = reader.ReadToEnd();
                Assert.AreEqual("{\"Format\":null,\"Childs\":[{\"Value\":\"one\"},{\"Value\":\"于百\"}]}", asString);

                stream.Seek(0, SeekOrigin.Begin);
                Assert.AreEqual(0xEF, stream.ReadByte(), "Missing UTF-8 BOM");
                Assert.AreEqual(0xBB, stream.ReadByte(), "Missing UTF-8 BOM");
                Assert.AreEqual(0xBF, stream.ReadByte(), "Missing UTF-8 BOM");
            }
        }
 public BlobId Upload(DocumentFormat format, FileNameWithExtension fileName, Stream sourceStrem)
 {
     return ForFormat(format).Upload(format, fileName, sourceStrem);
 }
 public BlobId Upload(DocumentFormat format, string pathToFile)
 {
     return ForFormat(format).Upload(format, pathToFile);
 }
 public IBlobWriter CreateNew(DocumentFormat format, FileNameWithExtension fname)
 {
     return ForFormat(format).CreateNew(format, fname);
 }
Beispiel #8
0
 public BlobId Upload(DocumentFormat format, FileNameWithExtension fileName, Stream sourceStream)
 {
     return(ForFormat(format).Upload(format, fileName, sourceStream));
 }
Beispiel #9
0
 public BlobId Upload(DocumentFormat format, string pathToFile)
 {
     return(ForFormat(format).Upload(format, pathToFile));
 }
Beispiel #10
0
 public IBlobWriter CreateNew(DocumentFormat format, FileNameWithExtension fname)
 {
     return(ForFormat(format).CreateNew(format, fname));
 }