public void TestDeletion() { var watch = new Stopwatch(); var testObject = new Parse.ParseObject("Score"); var score = random.Next(); testObject["Level"] = "First"; testObject["Score"] = score; //Create a new object watch.Restart(); testObject = localClient.CreateObject(testObject); watch.Stop(); Console.WriteLine(string.Format("Individual creation took {0}ms", watch.ElapsedMilliseconds)); var objList = localClient.GetObjectsWithQuery("Score", new { Level = "First", objectId = testObject.objectId }); Assert.IsNotNull(objList); Assert.AreEqual(objList.Length, 1); watch.Restart(); localClient.DeleteObject(testObject); watch.Stop(); Console.WriteLine(string.Format("Individual deletion took {0}ms", watch.ElapsedMilliseconds)); objList = localClient.GetObjectsWithQuery("Score", new { Level = "First", objectId = testObject.objectId }); Assert.IsEmpty(objList); }
public void TestMethod1() { string fileContents = "This is a test file."; File.WriteAllText("testFile.txt", fileContents); Parse.ParseFile parseFile = new Parse.ParseFile("testFile.txt"); Parse.ParseFile testFile = localClient.CreateFile(parseFile); //Test to make sure test file is returned after creation. Assert.IsNotNull(testFile); Parse.ParseObject testObject = new Parse.ParseObject("ClassOne"); testObject["foo"] = "bar"; //Create a new object testObject = localClient.CreateObject(testObject); //Test to make sure we returned a ParseObject Assert.IsNotNull(testObject); //Test to make sure we were assigned an object id and the object was actually remotely created Assert.IsNotNull(testObject.objectId); //Search for the newly-created object on the server Parse.ParseObject searchObject = localClient.GetObject("ClassOne", testObject.objectId); //Test to make sure the same object was returned Assert.AreEqual(testObject.objectId, searchObject.objectId); testObject["foo"] = "notbar"; //Change a value on the server localClient.UpdateObject(testObject); searchObject = localClient.GetObject("ClassOne", testObject.objectId); //Test to make sure the object was updated on the server Assert.AreEqual("notbar", searchObject["foo"]); //Test to make sure we can retrieve objects from Parse Parse.ParseObject[] objList = localClient.GetObjectsWithQuery("ClassOne", new { foo = "notbar" }); Assert.IsNotNull(objList); //Test to make sure the same object was returned Assert.AreEqual(objList.First()["objectId"], testObject.objectId); //Cleanup localClient.DeleteObject(testObject); }
public void TestMethod1() { string fileContents = "This is a test file."; File.WriteAllText("testFile.txt", fileContents); Parse.ParseFile parseFile = new Parse.ParseFile("testFile.txt"); Parse.ParseFile testFile = localClient.CreateFile(parseFile); //Test to make sure test file is returned after creation. Assert.IsNotNull(testFile); Parse.ParseObject testObject = new Parse.ParseObject("ClassOne"); testObject["foo"] = "bar"; //Create a new object testObject = localClient.CreateObject(testObject); //Test to make sure we returned a ParseObject Assert.IsNotNull(testObject); //Test to make sure we were assigned an object id and the object was actually remotely created Assert.IsNotNull(testObject.objectId); //Search for the newly-created object on the server Parse.ParseObject searchObject = localClient.GetObject("ClassOne", testObject.objectId); //Test to make sure the same object was returned Assert.AreEqual(testObject.objectId, searchObject.objectId); testObject["foo"] = "notbar"; //Change a value on the server localClient.UpdateObject(testObject); searchObject = localClient.GetObject("ClassOne", testObject.objectId); //Test to make sure the object was updated on the server Assert.AreEqual("notbar", searchObject["foo"]); //Test to make sure we can retrieve objects from Parse Parse.ParseObject[] objList = localClient.GetObjectsWithQuery("ClassOne", new { foo = "notbar" }); Assert.IsNotNull(objList); // Test to make sure the same object was returned // We can't assume that the first object will be the one we've just // sent, since some other people may be running tests as well. Assert.IsTrue(objList.Any(x => (string)x["objectId"] == testObject.objectId)); //Cleanup localClient.DeleteObject(testObject); }
public void TestMP3() { Parse.ParseFile parseFile = new Parse.ParseFile( Path.Combine(Environment.CurrentDirectory, "..", "..", "..", "ParseTests", "sweep.mp3")); Parse.ParseFile testFile = localClient.CreateFile(parseFile); //Test to make sure test file is returned after creation. Assert.IsNotNull(testFile); Parse.ParseObject testObject = new Parse.ParseObject("ClassOne"); testObject["foo"] = "bar"; //Create a new object testObject = localClient.CreateObject(testObject); //Test to make sure we returned a ParseObject Assert.IsNotNull(testObject); //Test to make sure we were assigned an object id and the object was actually remotely created Assert.IsNotNull(testObject.objectId); //Search for the newly-created object on the server Parse.ParseObject searchObject = localClient.GetObject("ClassOne", testObject.objectId); //Test to make sure the same object was returned Assert.AreEqual(testObject.objectId, searchObject.objectId); testObject["foo"] = "notbar"; //Change a value on the server localClient.UpdateObject(testObject); searchObject = localClient.GetObject("ClassOne", testObject.objectId); //Test to make sure the object was updated on the server Assert.AreEqual("notbar", searchObject["foo"]); //Test to make sure we can retrieve objects from Parse Parse.ParseObject[] objList = localClient.GetObjectsWithQuery("ClassOne", new { foo = "notbar" }); Assert.IsNotNull(objList); //Test to make sure the same object was returned Assert.AreEqual(objList.First()["objectId"], testObject.objectId); //Cleanup localClient.DeleteObject(testObject); }
public void TestCreateAndQuery() { var testObject = new Parse.ParseObject("Score"); var score = random.Next(); testObject["Level"] = "First"; testObject["Score"] = score; //Create a new object testObject = localClient.CreateObject(testObject); //Test to make sure we returned a ParseObject Assert.IsNotNull(testObject); //Test to make sure we were assigned an object id and the object was actually remotely created Assert.IsNotNull(testObject.objectId); //Test to make sure we can retrieve objects from Parse Parse.ParseObject[] objList = localClient.GetObjectsWithQuery("Score", new { Level = "First" }); Assert.IsNotNull(objList); var foundId = objList.First(x => (string)x["objectId"] == testObject.objectId); Assert.IsNotNull(foundId); Assert.AreEqual((Int64)foundId["Score"], score); }
public void TestGetObject() { Parse.ParseObject[] objects = new Parse.ParseObject[20]; var levelName = string.Format("Level-{0}", random.Next()); Console.WriteLine("Creating..."); for (int i = 0; i < 20; i++) { var parseObject = new Parse.ParseObject("LevelScore"); parseObject["Level"] = levelName; parseObject["Score"] = i; objects[i] = localClient.CreateObject(parseObject); Assert.IsNotNull(objects[i].objectId); } // Retrieve the first 10 scores for this level Console.WriteLine("Retrieving..."); foreach (var o in objects) { var parseObject = localClient.GetObject("LevelScore", o.objectId); Assert.IsNotNull(parseObject); Assert.AreEqual(o["Level"], parseObject["Level"]); Assert.AreEqual(o["Score"], parseObject["Score"]); } // Let's clean up Console.WriteLine("Cleaning up..."); foreach (var o in objects) { localClient.DeleteObject(o); } }
public void TestGetObject() { Parse.ParseObject[] objects = new Parse.ParseObject[20]; var levelName = string.Format("Level-{0}", random.Next()); Console.WriteLine("Creating..."); for (int i = 0; i < 20; i++) { var parseObject = new Parse.ParseObject("LevelScore"); parseObject["Level"] = levelName; parseObject["Score"] = i; objects[i] = localClient.CreateObject(parseObject); Assert.IsNotNull(objects[i].objectId); } // Retrieve the first 10 scores for this level Console.WriteLine("Retrieving..."); foreach(var o in objects) { var parseObject = localClient.GetObject("LevelScore", o.objectId); Assert.IsNotNull(parseObject); Assert.AreEqual(o["Level"], parseObject["Level"]); Assert.AreEqual(o["Score"], parseObject["Score"]); } // Let's clean up Console.WriteLine("Cleaning up..."); foreach(var o in objects) { localClient.DeleteObject(o); } }
public void TestQueryLimitsAndSorting() { var watch = new Stopwatch(); Parse.ParseObject[] objects = new Parse.ParseObject[20]; var levelName = string.Format("Level-{0}", random.Next()); Console.WriteLine("Creating..."); watch.Restart(); for (int i = 0; i < 20; i++) { var parseObject = new Parse.ParseObject("LevelScore"); parseObject["Level"] = levelName; parseObject["Score"] = i; objects[i] = localClient.CreateObject(parseObject); Assert.IsNotNull(objects[i].objectId); } watch.Stop(); Console.WriteLine(string.Format("Creation took {0}ms", watch.ElapsedMilliseconds)); // Retrieve the first 10 scores for this level Console.WriteLine("Retrieving..."); watch.Restart(); var objList = localClient.GetObjectsWithQuery("LevelScore", new { Level = levelName }, "Score", 10); watch.Stop(); Console.WriteLine(string.Format("Retrieval took {0}ms", watch.ElapsedMilliseconds)); Assert.IsNotEmpty(objList); Assert.AreEqual(objList.Length, 10); // All scores returned should be in the 0-9 range, in ascending order for (int i = 0; i <= 9; i++) { Assert.AreEqual((string)objList[i]["Level"], levelName); Assert.AreEqual((Int64)objList[i]["Score"], i); } // Retrieve the middle 10 scores for this level, in inverse order Console.WriteLine("Retrieving second batch..."); watch.Restart(); objList = localClient.GetObjectsWithQuery("LevelScore", new { Level = levelName }, "-Score", 10, 5); watch.Stop(); Console.WriteLine(string.Format("Sorted retrieval took {0}ms", watch.ElapsedMilliseconds)); Assert.IsNotEmpty(objList); Assert.AreEqual(objList.Length, 10); // All scores returned should be in the 0-9 range, in ascending order for (int i = 0; i <= 9; i++) { Assert.AreEqual((string)objList[i]["Level"], levelName); Assert.AreEqual((Int64)objList[i]["Score"], 14-i); } // Retrieve the top 5 scores for this level, in inverse order Console.WriteLine("Retrieving third batch..."); objList = localClient.GetObjectsWithQuery("LevelScore", new { Level = levelName }, "-Score", 5, 0); Assert.IsNotEmpty(objList); Assert.AreEqual(objList.Length, 5); // All scores returned should be in the 0-9 range, in ascending order for (int i = 0; i <= 4; i++) { Assert.AreEqual((string)objList[i]["Level"], levelName); Assert.AreEqual((Int64)objList[i]["Score"], 19-i); } // Let's clean up Console.WriteLine("Cleaning up..."); watch.Restart(); foreach(var o in objects) { localClient.DeleteObject(o); } watch.Stop(); Console.WriteLine(string.Format("Clean up took {0}ms", watch.ElapsedMilliseconds)); }
public void TestMethod1() { string fileContents = "This is a test file."; string testFileLocalPath = "testFile.txt"; File.WriteAllText(testFileLocalPath, fileContents); Parse.ParseFile parseFile = new Parse.ParseFile(testFileLocalPath); Parse.ParseFile testFile = localClient.CreateFile(parseFile); //Test to make sure test file is returned after creation. Assert.IsNotNull(testFile); Console.WriteLine(testFileLocalPath + " uploaded to :" + testFile.Url); //access the file outside the parse api WebRequest fileRequest = WebRequest.Create(testFile.Url); fileRequest.Method = "GET"; HttpWebResponse foundTestFile = (HttpWebResponse)fileRequest.GetResponse(); // we don't have to stream the body content - just check the status code Assert.AreEqual(HttpStatusCode.OK, foundTestFile.StatusCode); Parse.ParseObject testObject = new Parse.ParseObject("ClassOne"); testObject["foo"] = "bar"; //Create a new object testObject = localClient.CreateObject(testObject); //Test to make sure we returned a ParseObject Assert.IsNotNull(testObject); //Test to make sure we were assigned an object id and the object was actually remotely created Assert.IsNotNull(testObject.objectId); //Search for the newly-created object on the server Parse.ParseObject searchObject = localClient.GetObject("ClassOne", testObject.objectId); //Test to make sure the same object was returned Assert.AreEqual(testObject.objectId, searchObject.objectId); testObject["foo"] = "notbar"; //Change a value on the server localClient.UpdateObject(testObject); searchObject = localClient.GetObject("ClassOne", testObject.objectId); //Test to make sure the object was updated on the server Assert.AreEqual("notbar", searchObject["foo"]); //Test to make sure we can retrieve objects from Parse Parse.ParseObject[] objList = localClient.GetObjectsWithQuery("ClassOne", new { foo = "notbar" }); Assert.IsNotNull(objList); // Test to make sure the same object was returned // We can't assume that the first object will be the one we've just // sent, since some other people may be running tests as well. Assert.IsTrue(objList.Any(x => (string)x["objectId"] == testObject.objectId)); //Cleanup localClient.DeleteObject(testObject); localClient.DeleteFile(testFile); //verify that the deleted file is no longer accessible try { WebRequest deletedFileRequest = WebRequest.Create(testFile.Url); deletedFileRequest.Method = "GET"; HttpWebResponse deletedTestFile = (HttpWebResponse)deletedFileRequest.GetResponse(); Assert.That(deletedTestFile.StatusCode == HttpStatusCode.Forbidden || deletedTestFile.StatusCode == HttpStatusCode.NotFound); } catch (WebException accessException) { Assert.That(accessException.Message.Contains("403") || accessException.Message.Contains("404")); } }
public void TestMethod1() { string fileContents = "This is a test file."; string testFileLocalPath = "testFile.txt"; File.WriteAllText(testFileLocalPath, fileContents); Parse.ParseFile parseFile = new Parse.ParseFile(testFileLocalPath); Parse.ParseFile testFile = localClient.CreateFile(parseFile); //Test to make sure test file is returned after creation. Assert.IsNotNull(testFile); Console.WriteLine(testFileLocalPath + " uploaded to :" + testFile.Url); //access the file outside the parse api WebRequest fileRequest = WebRequest.Create(testFile.Url); fileRequest.Method = "GET"; HttpWebResponse foundTestFile = (HttpWebResponse)fileRequest.GetResponse(); // we don't have to stream the body content - just check the status code Assert.AreEqual (HttpStatusCode.OK, foundTestFile.StatusCode); Parse.ParseObject testObject = new Parse.ParseObject("ClassOne"); testObject["foo"] = "bar"; //Create a new object testObject = localClient.CreateObject(testObject); //Test to make sure we returned a ParseObject Assert.IsNotNull(testObject); //Test to make sure we were assigned an object id and the object was actually remotely created Assert.IsNotNull(testObject.objectId); //Search for the newly-created object on the server Parse.ParseObject searchObject = localClient.GetObject("ClassOne", testObject.objectId); //Test to make sure the same object was returned Assert.AreEqual(testObject.objectId, searchObject.objectId); testObject["foo"] = "notbar"; //Change a value on the server localClient.UpdateObject(testObject); searchObject = localClient.GetObject("ClassOne", testObject.objectId); //Test to make sure the object was updated on the server Assert.AreEqual("notbar", searchObject["foo"]); //Test to make sure we can retrieve objects from Parse Parse.ParseObject[] objList = localClient.GetObjectsWithQuery("ClassOne", new { foo = "notbar" }); Assert.IsNotNull(objList); // Test to make sure the same object was returned // We can't assume that the first object will be the one we've just // sent, since some other people may be running tests as well. Assert.IsTrue(objList.Any(x => (string)x["objectId"] == testObject.objectId)); //Cleanup localClient.DeleteObject(testObject); localClient.DeleteFile (testFile); //verify that the deleted file is no longer accessible try { WebRequest deletedFileRequest = WebRequest.Create(testFile.Url); deletedFileRequest.Method = "GET"; HttpWebResponse deletedTestFile = (HttpWebResponse)deletedFileRequest.GetResponse(); Assert.That(deletedTestFile.StatusCode == HttpStatusCode.Forbidden || deletedTestFile.StatusCode == HttpStatusCode.NotFound); } catch (WebException accessException) { Assert.That(accessException.Message.Contains("403") || accessException.Message.Contains("404")); } }
public void TestQueryLimitsAndSorting() { var watch = new Stopwatch(); Parse.ParseObject[] objects = new Parse.ParseObject[20]; var levelName = string.Format("Level-{0}", random.Next()); Console.WriteLine("Creating..."); watch.Restart(); for (int i = 0; i < 20; i++) { var parseObject = new Parse.ParseObject("LevelScore"); parseObject["Level"] = levelName; parseObject["Score"] = i; objects[i] = localClient.CreateObject(parseObject); Assert.IsNotNull(objects[i].objectId); } watch.Stop(); Console.WriteLine(string.Format("Creation took {0}ms", watch.ElapsedMilliseconds)); // Retrieve the first 10 scores for this level Console.WriteLine("Retrieving..."); watch.Restart(); var objList = localClient.GetObjectsWithQuery("LevelScore", new { Level = levelName }, "Score", 10); watch.Stop(); Console.WriteLine(string.Format("Retrieval took {0}ms", watch.ElapsedMilliseconds)); Assert.IsNotEmpty(objList); Assert.AreEqual(objList.Length, 10); // All scores returned should be in the 0-9 range, in ascending order for (int i = 0; i <= 9; i++) { Assert.AreEqual((string)objList[i]["Level"], levelName); Assert.AreEqual((Int64)objList[i]["Score"], i); } // Retrieve the middle 10 scores for this level, in inverse order Console.WriteLine("Retrieving second batch..."); watch.Restart(); objList = localClient.GetObjectsWithQuery("LevelScore", new { Level = levelName }, "-Score", 10, 5); watch.Stop(); Console.WriteLine(string.Format("Sorted retrieval took {0}ms", watch.ElapsedMilliseconds)); Assert.IsNotEmpty(objList); Assert.AreEqual(objList.Length, 10); // All scores returned should be in the 0-9 range, in ascending order for (int i = 0; i <= 9; i++) { Assert.AreEqual((string)objList[i]["Level"], levelName); Assert.AreEqual((Int64)objList[i]["Score"], 14 - i); } // Retrieve the top 5 scores for this level, in inverse order Console.WriteLine("Retrieving third batch..."); objList = localClient.GetObjectsWithQuery("LevelScore", new { Level = levelName }, "-Score", 5, 0); Assert.IsNotEmpty(objList); Assert.AreEqual(objList.Length, 5); // All scores returned should be in the 0-9 range, in ascending order for (int i = 0; i <= 4; i++) { Assert.AreEqual((string)objList[i]["Level"], levelName); Assert.AreEqual((Int64)objList[i]["Score"], 19 - i); } // Let's clean up Console.WriteLine("Cleaning up..."); watch.Restart(); foreach (var o in objects) { localClient.DeleteObject(o); } watch.Stop(); Console.WriteLine(string.Format("Clean up took {0}ms", watch.ElapsedMilliseconds)); }