Example #1
0
		public void Test_13_CustomColumn_AcceptanceTest()
		{
            Proxy.UploaderRef.Uploader uploader = new Proxy.UploaderRef.Uploader( );
			uploader.Url = Globals.UploaderUrl();
			uploader.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), "");
            string libUrl = Globals.SiteCollectionForTests() + "/ForColumnTesting";
			string docUrl = libUrl + "/FileForUploadToSP_TestCustomColumnValue.doc";
            byte[] fileBuf = Helper_ReadLocalFile(FILE_FOR_UPLOAD_DOC);

			try
			{
                //// Creating custom columns
                uploader.DeleteCustomColumn(libUrl, "Test Column Text"); // tests that deleting a non-existant column does not throw
                uploader.CreateCustomColumn(libUrl, "Test Column Text", "Text", "Default Text");
                Assert.AreEqual("Text", uploader.GetCustomColumnType(libUrl, "Test Column Text"));

                uploader.DeleteCustomColumn(libUrl, "Test Column Note"); // tests that deleting a non-existant column does not throw
                uploader.CreateCustomColumn(libUrl, "Test Column Note", "Note", "Default Text\nDefaul Text");
                Assert.AreEqual("Note", uploader.GetCustomColumnType(libUrl, "Test Column Note"));

                uploader.DeleteCustomColumn(libUrl, "Test Column Choice"); // tests that deleting a non-existant column does not throw
                uploader.CreateCustomColumn(libUrl, "Test Column Choice", "Choice", "True");
                Assert.AreEqual("Choice", uploader.GetCustomColumnType(libUrl, "Test Column Choice"));

                uploader.DeleteCustomColumn(libUrl, "Test Column Number"); // tests that deleting a non-existant column does not throw
                uploader.CreateCustomColumn(libUrl, "Test Column Number", "Number", "0");
                Assert.AreEqual("Number", uploader.GetCustomColumnType(libUrl, "Test Column Number"));

                uploader.DeleteCustomColumn(libUrl, "Test Column Currency"); // tests that deleting a non-existant column does not throw
                uploader.CreateCustomColumn(libUrl, "Test Column Currency", "Currency", "1.50");
                Assert.AreEqual("Currency", uploader.GetCustomColumnType(libUrl, "Test Column Currency"));

                uploader.DeleteCustomColumn(libUrl, "Test Column DateTime"); // tests that deleting a non-existant column does not throw

                uploader.CreateCustomColumn(libUrl, "Test Column DateTime", "DateTime", "");
                Assert.AreEqual("DateTime", uploader.GetCustomColumnType(libUrl, "Test Column DateTime"));

                uploader.CreateCustomColumn(libUrl, "Test Column User", "User", "");
                Assert.AreEqual("User", uploader.GetCustomColumnType(libUrl, "Test Column User"));

                uploader.CreateCustomColumn(libUrl, "Test Column Boolean", "Boolean", "True");
                Assert.AreEqual("Boolean", uploader.GetCustomColumnType(libUrl, "Test Column Boolean"));

				// Upload a document
				uploader.Upload(fileBuf, docUrl);
				
				// Set it's custom fields
				uploader.SetCustomColumnValue(docUrl, "Test Column Text", "New Test Data");
				Assert.AreEqual("New Test Data", uploader.GetCustomColumnValue(docUrl, "Test Column Text"));

				uploader.SetCustomColumnValue(docUrl, "Test Column Note", "New Test Data\nNew Test Data");
				Assert.AreEqual("New Test Data\nNew Test Data", uploader.GetCustomColumnValue(docUrl, "Test Column Note"));

				uploader.SetCustomColumnValue(docUrl, "Test Column Choice", false);
				Assert.AreEqual("False", uploader.GetCustomColumnValue(docUrl, "Test Column Choice"));

				uploader.SetCustomColumnValue(docUrl, "Test Column Number", 1);
				Assert.AreEqual(1, uploader.GetCustomColumnValue(docUrl, "Test Column Number"));

				uploader.SetCustomColumnValue(docUrl, "Test Column Currency", 9.99);
				Assert.AreEqual(9.99, uploader.GetCustomColumnValue(docUrl, "Test Column Currency"));

				DateTime now = DateTime.Today.Date;
				DateTime nowPlus1 = now.Add(new TimeSpan(1, 0, 0, 0));
				uploader.SetCustomColumnValue(docUrl, "Test Column DateTime", nowPlus1);
				Assert.AreEqual(nowPlus1, uploader.GetCustomColumnValue(docUrl, "Test Column DateTime"));

				uploader.SetCustomColumnValue(docUrl, "Test Column Boolean", false);
				Assert.AreEqual(false, uploader.GetCustomColumnValue(docUrl, "Test Column Boolean"));

				// Re-upload it
				//uploader.Upload(fileBuf, docUrl);

				// Ensure custom fields haven't changed / disappeared
				Assert.AreEqual("New Test Data", uploader.GetCustomColumnValue(docUrl, "Test Column Text"));
				//Assert.AreEqual("New Test Data\nNew Test Data", uploader.GetCustomColumnValue(docUrl, "Test Column Note"));
				//Assert.AreEqual("False", uploader.GetCustomColumnValue(docUrl, "Test Column Choice"));
				//Assert.AreEqual(1, uploader.GetCustomColumnValue(docUrl, "Test Column Number"));
				//Assert.AreEqual(9.99, uploader.GetCustomColumnValue(docUrl, "Test Column Currency"));
				//Assert.AreEqual(nowPlus1, uploader.GetCustomColumnValue(docUrl, "Test Column DateTime"));
				//Assert.AreEqual(false, uploader.GetCustomColumnValue(docUrl, "Test Column Boolean"));
			}
			finally
			{
				uploader.Delete(docUrl);

				uploader.DeleteCustomColumn(libUrl, "Test Column Text");
				uploader.DeleteCustomColumn(libUrl, "Test Column Note");
				uploader.DeleteCustomColumn(libUrl, "Test Column Choice");
				uploader.DeleteCustomColumn(libUrl, "Test Column Number");
				uploader.DeleteCustomColumn(libUrl, "Test Column Currency");
				uploader.DeleteCustomColumn(libUrl, "Test Column DateTime");
				uploader.DeleteCustomColumn(libUrl, "Test Column User");
				uploader.DeleteCustomColumn(libUrl, "Test Column Boolean");
			}
		}
Example #2
0
		public void Test_11_TestDeleteCustomColumn()
		{
            Proxy.UploaderRef.Uploader uploader = new Proxy.UploaderRef.Uploader( );
			uploader.Url = Globals.UploaderUrl();
			uploader.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), "");
            string url = Globals.SiteCollectionForTests() + "/ForColumnTesting";
			Assert.IsNull(uploader.GetCustomColumnType(url, "TestColumn1"));
			uploader.CreateCustomColumn(url, "TestColumn1", "Text", "");
			Assert.AreEqual("Text", uploader.GetCustomColumnType(url, "TestColumn1"));
			uploader.DeleteCustomColumn(url, "TestColumn1");
			Assert.IsNull(uploader.GetCustomColumnType(url, "TestColumn1"));
		}
Example #3
0
		public void Test_12_TestGetProp()
		{
            Proxy.UploaderRef.Uploader uploader = new Proxy.UploaderRef.Uploader( );
			uploader.Url = Globals.UploaderUrl();
			uploader.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), "");
            string libUrl = Globals.SiteCollectionForTests() + "/ForColumnTesting";
            string docUrl = Globals.SiteCollectionForTests() + "/ForColumnTesting/FileForUploadToSP.doc";

			uploader.CreateCustomColumn(libUrl, "TestColumn", "Text", "");
			try
			{
                byte[] fileBuf = Helper_ReadLocalFile(FILE_FOR_UPLOAD_DOC);
                uploader.Upload(fileBuf, docUrl);
                uploader.SetCustomColumnValue(docUrl, "TestColumn", "New Value");
                string s = uploader.GetCustomColumnValue(docUrl, "TestColumn") as string;
				Assert.AreEqual("New Value", s);

                uploader.SetCustomColumnValue(docUrl, "TestColumn", "A Newer Value");
                s = uploader.GetCustomColumnValue(docUrl, "TestColumn") as string;
				Assert.AreEqual("A Newer Value", s);
			}
			finally
			{
                uploader.DeleteCustomColumn(libUrl, "TestColumn");
                uploader.Delete(docUrl);
			}
		}
Example #4
0
		public void Test_10_TestGetCustomColumnValue()
		{
            Proxy.UploaderRef.Uploader uploader = new Proxy.UploaderRef.Uploader( );
			uploader.Url = Globals.UploaderUrl();
			uploader.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), "");
            string libUrl = Globals.SiteCollectionForTests() + "/ForColumnTesting";
            string docUrl = Globals.SiteCollectionForTests() + "/ForColumnTesting/FileForUploadToSP_TestCustomColumnValue.doc";

			Assert.IsNull(uploader.GetCustomColumnType(libUrl, "TestColumn"));
			try
			{
				uploader.CreateCustomColumn(libUrl, "TestColumn", "Text", "");

                byte[] fileBuf = Helper_ReadLocalFile(FILE_FOR_UPLOAD_DOC);
				uploader.Upload(fileBuf, docUrl);
				uploader.SetCustomColumnValue(docUrl, "TestColumn", "Some test data");
				Assert.AreEqual("Some test data", uploader.GetCustomColumnValue(docUrl, "TestColumn"));
				uploader.Delete(docUrl);
			}
			finally
			{
				uploader.DeleteCustomColumn(libUrl, "TestColumn");
			}
		}