Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        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"));
            }
        }
Example #6
0
        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"));
			}
				
        }