public void ItemExistsWhenInsertNewFile() { RedisDataContext dataContext = new RedisDataContext(); dataContext.InsertFile("./anotherFile.txt", "c:\\users\\harageth\\documents\\visual studio 2012\\Projects\\PolyglotDemo\\TesterFile.txt"); Assert.IsNotNull(dataContext.ReadFile("./anotherFile.txt")); }
public void FileContainsDataAfterInsertNewFile() { RedisDataContext dataContext = new RedisDataContext(); string value = dataContext.InsertFile("./anotherFile.txt", "c:\\users\\harageth\\documents\\visual studio 2012\\Projects\\PolyglotDemo\\TesterFile.txt"); Assert.AreEqual <string>("This is a specific file that I am adding to the project to make sure that I can add all sorts of files directly to the database.", value); }
protected void UploadFile_Click(object sender, EventArgs e) { if (uploadFileToDatabase.HasFile) { string contentType = uploadFileToDatabase.PostedFile.ContentType; string fileName = uploadFileToDatabase.PostedFile.FileName; byte[] byteArray = uploadFileToDatabase.FileBytes; MongoDataContext mongoContext = new MongoDataContext(); RedisDataContext redisContext = new RedisDataContext(); RootDirectory directory = (RootDirectory)Session["directory"]; if (directory.files == null) { directory.files = new List <string>(); } string virPath = virtualPath.Text; if (virPath.Split('/')[1].Equals("")) { //virPath; } else { virPath = virPath + "/"; } if (directory.AddFileToCWD(fileName, virPath)) { mongoContext.UpdateFileStructure(directory); redisContext.InsertFile(directory.un + virPath + fileName, byteArray); /*if (virtualPath.Text.Equals("/")) * { * * } * else * { * redisContext.InsertFile(directory.un + virtualPath.Text + "/" + fileName, byteArray); * }*/ //Response.Redirect("Default.aspx"); } else { Response.Write("Upload failed due to file already existing... in path");//should probably check redis as well... } } }