Пример #1
0
		public void TearDownSuite()
		{
            Proxy.UploaderRef.Uploader uploader = new Proxy.UploaderRef.Uploader( );
			uploader.Url = Globals.UploaderUrl();
			uploader.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), "");
			string docUrl = Globals.DocumentLibForUploadTesting()+"/Uploaded.doc";
				
			if (uploader.DocumentExists(docUrl))
				uploader.Delete(docUrl);
		}
Пример #2
0
		public void SetupSuite()
		{
			Globals.SetUseLocal(false); // use this to debug on sharepoint
			//Globals.SetUseLocal(true); // use this to debug on this machine

            Proxy.UploaderRef.Uploader uploader = new Proxy.UploaderRef.Uploader( );
			uploader.Url = Globals.UploaderUrl();
			uploader.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), "");
			string docUrl = Globals.DocumentLibForUploadTesting()+"/Uploaded.doc";

            if (uploader.DocumentExists(docUrl))
                uploader.Delete(docUrl);
		}
Пример #3
0
		public void Test_02_Upload_And_Delete()
		{
            Proxy.UploaderRef.Uploader uploader = new Proxy.UploaderRef.Uploader( );
			uploader.Url = Globals.UploaderUrl();
			uploader.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), "");
			string uploadDocUrl = Globals.DocumentLibForUploadTesting()+"/Uploaded.doc";
			byte[] fileBuf;

			using(FileStream fileStream = new FileStream(FILE_FOR_UPLOAD_DOC, FileMode.Open, FileAccess.Read, FileShare.Read))
			using(BinaryReader reader = new BinaryReader(fileStream))
			{
				fileBuf = reader.ReadBytes((int)fileStream.Length);
			}

			Assert.IsFalse(uploader.DocumentExists(uploadDocUrl), "This document should NOT exist before the test is run.  Please delete "+uploadDocUrl+" and try again.");
			uploader.Upload(fileBuf, uploadDocUrl);
			Assert.IsTrue(uploader.DocumentExists(uploadDocUrl), "This document should exist.  We just uploaded it.  Don't you think?");
			uploader.Delete(uploadDocUrl);
			Assert.IsFalse(uploader.DocumentExists(uploadDocUrl), "This document should NOT exist. We just deleted it.  What do you think?");
		}
Пример #4
0
        private void Test_Download(string downloadDocUrl, string referenceFilename)
        {
            Proxy.UploaderRef.Uploader uploader = new Proxy.UploaderRef.Uploader( );
            uploader.Url = Globals.UploaderUrl();
            uploader.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), "");

            if (uploader.DocumentExists(downloadDocUrl))
                uploader.Delete(downloadDocUrl);
            Helper_EnsureDocumentIsThereForTesting(downloadDocUrl, referenceFilename);

            byte[] fileBuf = uploader.Download(downloadDocUrl);
            byte[] refFileBuf = Helper_ReadLocalFile(referenceFilename);

            Assert.IsTrue(fileBuf != null, "Failed to download the document from SharePoint.");
            Assert.IsTrue(refFileBuf != null, "Failed to load the test file.  Test can't run.");
            
            //TODO: why aren't the files the same size?
            //Assert.AreSame(fileBuf, refFileBuf);
            //Assert.IsTrue(fileBuf.Length > 0 && fileBuf.Length == refFileBuf.Length, "Didn't read all the bytes we are expecting!");
        }
Пример #5
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");
			}
		}
Пример #6
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);
			}
		}
Пример #7
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");
			}
		}
Пример #8
0
		public void Test_07_GetDocumentAuthor()
		{
			byte[] bufV1 = new byte[100];
			byte[] bufV2 = new byte[200];
			byte[] bufV3 = new byte[300];

            Proxy.UploaderRef.Uploader uploader = new Proxy.UploaderRef.Uploader( );
			uploader.Url = Globals.UploaderUrl();
			uploader.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), "");
			string docUrl = Globals.DocumentLibForUploadTesting()+"/Uploaded.doc";

			if (uploader.DocumentExists(docUrl))
				uploader.Delete(docUrl);

			uploader.Upload(bufV1, docUrl);
			uploader.Upload(bufV2, docUrl);
			uploader.Upload(bufV3, docUrl);

			string currentUser = System.Environment.UserDomainName + @"\" + System.Environment.UserName;
			currentUser = currentUser.ToLower();

			Assert.IsTrue(uploader.GetDocumentAuthor(docUrl, 1).ToLower() == currentUser, "Was " + uploader.GetDocumentAuthor(docUrl, 1).ToLower() + " expected " + currentUser);
			Assert.IsTrue(uploader.GetDocumentAuthor(docUrl, 2).ToLower() == currentUser, "Was " + uploader.GetDocumentAuthor(docUrl, 1).ToLower() + " expected " + currentUser);
			Assert.IsTrue(uploader.GetDocumentAuthor(docUrl, 3).ToLower() == currentUser, "Was " + uploader.GetDocumentAuthor(docUrl, 1).ToLower() + " expected " + currentUser);
		}
Пример #9
0
		public void Test_06_GetLockStatus_SetLockStatus()
		{
            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.DocumentLibForUploadTesting()+"/Uploaded.doc";

			if (uploader.DocumentExists(url))
				uploader.Delete(url);
            Helper_EnsureDocumentIsThereForTesting(url, FILE_FOR_UPLOAD_DOC);

            Assert.IsTrue( uploader.GetLockStatus( url ) == Proxy.UploaderRef.LockStatus.Unlocked, "Document wasn't locked, so why say it is?" );
            uploader.SetLockStatus( url, Proxy.UploaderRef.LockStatus.Locked, "Testing" );
            Assert.IsTrue( uploader.GetLockStatus( url ) == Proxy.UploaderRef.LockStatus.Locked, "We just locked it." );
            uploader.SetLockStatus( url, Proxy.UploaderRef.LockStatus.Unlocked, "Testing" );
            Assert.IsTrue( uploader.GetLockStatus( url ) == Proxy.UploaderRef.LockStatus.Unlocked, "We just unlocked it." );
		}
Пример #10
0
		public void Test_05_Download_A_Particular_Version()
		{
			byte[] bufV1 = new byte[100];
			byte[] bufV2 = new byte[200];
			byte[] bufV3 = new byte[300];

            Proxy.UploaderRef.Uploader uploader = new Proxy.UploaderRef.Uploader( );
			uploader.Url = Globals.UploaderUrl();
			uploader.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), "");
			string docUrl = Globals.DocumentLibForUploadTesting()+"/Uploaded.doc";

			if (uploader.DocumentExists(docUrl))
				uploader.Delete(docUrl);

			uploader.Upload(bufV1, docUrl);
			uploader.Upload(bufV2, docUrl);
			uploader.Upload(bufV3, docUrl);

			byte[] downloaded = uploader.DownloadVersion(docUrl, 1);
			Assert.IsTrue(downloaded.Length == 100, "Failed to download the expected document version: 1");
			downloaded = uploader.DownloadVersion(docUrl, 2);
			Assert.IsTrue(downloaded.Length == 200, "Failed to download the expected document version: 2");
			downloaded = uploader.DownloadVersion(docUrl, 3);
			Assert.IsTrue(downloaded.Length == 300, "Failed to download the expected document version: 3");
		}
Пример #11
0
		public void Test_04_GetDocumentVersionCount()
		{
            Proxy.UploaderRef.Uploader uploader = new Proxy.UploaderRef.Uploader( );
			uploader.Url = Globals.UploaderUrl();
			uploader.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), "");
			string docUrl = Globals.DocumentLibForUploadTesting()+"/Uploaded.doc";

			if (uploader.DocumentExists(docUrl))
				uploader.Delete(docUrl);

            byte[] fileBuf = Helper_ReadLocalFile(FILE_FOR_UPLOAD_DOC);
			uploader.Upload(fileBuf, docUrl);
			Assert.IsTrue(uploader.GetDocumentVersionCount(docUrl) == 1, "So where did the other versions come from then?");
			uploader.Upload(fileBuf, docUrl);
			Assert.IsTrue(uploader.GetDocumentVersionCount(docUrl) == 2, "We just uploaded another.  There should be another version.  Don't you agree?");
			uploader.Upload(fileBuf, docUrl);
			Assert.IsTrue(uploader.GetDocumentVersionCount(docUrl) == 3, "We just uploaded yet another.  There should be yet another version.  Don't you think?");
			uploader.Delete(docUrl);

			Assert.IsTrue(uploader.GetDocumentVersionCount(Globals.DocumentLibForTests()+"/Expected Test Document 1.doc") == 1, "Versioning not switch on and document should never have been modified anyway.");
			Assert.IsTrue(uploader.GetDocumentVersionCount("") == 0, "Failed to handle invalid filename");
			Assert.IsTrue(uploader.GetDocumentVersionCount(" ") == 0, "Failed to handle invalid filename");
			Assert.IsTrue(uploader.GetDocumentVersionCount(Globals.SiteCollectionForTests()) == 0, "Failed to handle invalid filename: Site Name");
			Assert.IsTrue(uploader.GetDocumentVersionCount(Globals.DocumentLibForTests()) == 0, "Failed to handle invalid filename: Document Library Name");
			Assert.IsTrue(uploader.GetDocumentVersionCount(Globals.DeepFolderForTests()) == 0, "Failed to handle invalid filename: Folder Name");
			Assert.IsTrue(uploader.GetDocumentVersionCount(Globals.DeepFolderForTests()) == 0, "Failed to handle invalid filename: Folder Name");
		}