Example #1
0
        public void PositiveAddFile()
        {
            string filepath = testsDirFullPath + "\\" + "file.txt";
            string lines    = "HELLO!";

            BaseFileWorker.Write(lines, filepath);

            byte[] byteArr = File.ReadAllBytes(filepath);

            storageDatкabaseUtils.AddFile(filepath, byteArr);

            byte[] returnedArr;
            string returnedFileName;

            int returned = int.Parse(storageDatкabaseUtils.GetFiles(filepath).Rows[0]["FileID"].ToString());

            storageDatкabaseUtils.GetFile(returned, out returnedFileName, out returnedArr);


            Assert.AreEqual(byteArr, returnedArr);
            Assert.AreEqual(filepath, returnedFileName);
        }
Example #2
0
 public void AddFileTest()
 {
     Assert.True(storageDatabaseUtils.AddFile("testfile.txt", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testfile.txt"))));
     Assert.True(storageDatabaseUtils.AddFile("db.accdb", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\db.accdb"))));
     Assert.True(storageDatabaseUtils.AddFile("docfile.docx", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\docfile.docx"))));
     Assert.True(storageDatabaseUtils.AddFile("pdftest.pdf", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\pdftest.pdf"))));
     Assert.True(storageDatabaseUtils.AddFile("archive.zip", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\archive.zip"))));
     Assert.True(storageDatabaseUtils.AddFile("picture.jpg", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\picture.jpg"))));
     Assert.True(storageDatabaseUtils.AddFile("present.pptx", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\present.pptx"))));
     Assert.True(storageDatabaseUtils.AddFile("✔️✔️✔️.txt", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\✔️✔️✔️.txt"))));
     Assert.True(storageDatabaseUtils.AddFile("ґєїъэё.txt", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\ґєїъэё.txt"))));
     Assert.True(storageDatabaseUtils.AddFile("mathcad.xmcd", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\mathcad.xmcd"))));
     Assert.True(storageDatabaseUtils.AddFile("somepng.png", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\somepng.png"))));
     Assert.True(storageDatabaseUtils.AddFile("Відео-файл.mp4", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\Відео-файл.mp4"))));
     Assert.True(storageDatabaseUtils.AddFile("music.mp3", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\music.mp3"))));
     Assert.True(storageDatabaseUtils.AddFile("apktest.apk", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\apktest.apk"))));
     Assert.True(storageDatabaseUtils.AddFile("someexe.exe", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\someexe.exe"))));
     Assert.True(storageDatabaseUtils.AddFile("HUH", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\HUH"))));
     Assert.True(storageDatabaseUtils.AddFile("oops.torrent", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\oops.torrent"))));
     Assert.True(storageDatabaseUtils.AddFile(".txt", Encoding.ASCII.GetBytes(FileWorker.GetFileName(@"C:\testing\.txt"))));
 }
Example #3
0
        public void Test_Add_EmptyFile()
        {
            var    fileWorker = new FileWorker("../../../test/test1.txt");
            string content    = fileWorker.ReadAll();

            byte[] data   = Encoding.ASCII.GetBytes(content);
            var    result = _databaseConnection.AddFile(fileWorker.GetFileName(), data);

            Assert.IsTrue(result);
        }