Exemplo n.º 1
0
        public void TestWriteFilesLocal()
        {
            string strTestJSPath = TestContent.GetContentFilePhysicalPath("/Scripts/jQuery.validate.js");

            IFileServer server1 = new FileServerLocal("Temp", "");
            IFileQuery file1 = new FileQuery("validate.js", "Scripts");
            IFileQuery file2 = new FileQuery("validate2.js", "Scripts");
            IFileQuery file3 = new FileQuery("validate3.js", "Scripts");

            server1.StoreFile(strTestJSPath, file1);
            Assert.IsTrue(server1.FileExistsLocal(file1));

            server1.StoreFileAsync(strTestJSPath, file2).ContinueWith((t) => {
                Assert.IsTrue(server1.FileExistsLocal(file2));
            });

            //Test System.Stream
            using (System.IO.Stream stmFile = new System.IO.FileStream(strTestJSPath, System.IO.FileMode.Open))
            {
                server1.StoreFile(stmFile, file3);
                stmFile.Close();
            }
            Assert.IsTrue(server1.FileExistsLocal(file3));

            IFileQuery file4 = new FileQuery("text.txt", "Docs");
            server1.StoreFileFromString("this is some text § how was that", file4);
            string strLoaded = server1.LoadFileText(file4);
            Assert.AreEqual(strLoaded, "this is some text § how was that");

            IFileQuery file5 = new FileQuery("textEncodedAscii.txt", "Docs");
            server1.StoreFileFromString("this is some text § how was that", file5, Encoding.ASCII);
            strLoaded = server1.LoadFileText(file5);
            Assert.AreEqual(strLoaded, "this is some text ? how was that");
        }