コード例 #1
0
ファイル: TestUploader.cs プロジェクト: killbug2004/WSProf
		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
ファイル: TestUploader.cs プロジェクト: killbug2004/WSProf
		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?");
		}
コード例 #3
0
ファイル: TestUploader.cs プロジェクト: killbug2004/WSProf
		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);
		}
コード例 #4
0
ファイル: TestUploader.cs プロジェクト: killbug2004/WSProf
		public void Test_01_DocumentExists()
		{
            Proxy.UploaderRef.Uploader uploader = new Proxy.UploaderRef.Uploader( );
			uploader.Url = Globals.UploaderUrl();
			uploader.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), "");

			Assert.IsTrue (uploader.DocumentExists(Globals.DocumentLibForTests()+"/Expected Test Document 1.doc"), "Failed to determine that a document which is there exists.");

			Assert.IsFalse(uploader.DocumentExists(Globals.DocumentLibForTests()+"/Expected Test Document 99.doc"), "That document most certainly does NOT exist.");
			Assert.IsFalse(uploader.DocumentExists(""), "Didn't handle invalid value NULL string");
			Assert.IsFalse(uploader.DocumentExists(" "), "Didn't handle invalid value blank string");
			Assert.IsFalse(uploader.DocumentExists(Globals.SiteCollectionForTests()), "Didn't handle invalid value site url");
			Assert.IsFalse(uploader.DocumentExists(Globals.DocumentLibForTests()), "Didn't handle invalid value document library");
			Assert.IsFalse(uploader.DocumentExists(Globals.DeepFolderForTests()), "Didn't handle invalid value folder");
		}
コード例 #5
0
        private void buttonGo_Click( object sender, EventArgs e )
        {
            Cursor cursor = this.Cursor;
            this.Cursor = Cursors.WaitCursor;

            try
            {

                Proxy.UploaderRef.Uploader up = new Proxy.UploaderRef.Uploader( );
                up.Url = "http://ln1-iainb-2008/Workshare.Connect.SharePoint.WebService/Uploader.asmx";
                up.PreAuthenticate = true;
                up.Credentials = System.Net.CredentialCache.DefaultCredentials;

                string filename = this.textBoxFilename.Text;

                using( FileStream fileStream = new FileStream( filename, FileMode.Open, FileAccess.Read, FileShare.Read ) )
                using( BinaryReader reader = new BinaryReader( fileStream ) )
                {
                    byte[ ] fileBuf = reader.ReadBytes( ( int )fileStream.Length );

                    for( int i = 1; i <= Convert.ToInt32( textBoxCount.Text ); ++i )
                    {
                        string paddedname = i.ToString( );
                        labelCount.Text = paddedname;
                        this.Update( );

                        paddedname = new string( '0', textBoxCount.Text.Length - paddedname.Length ) + paddedname + filename.Substring( filename.LastIndexOf( '.' ) );

                        string url = this.textBoxDocLib.Text + "/" + paddedname;
                        if( !up.DocumentExists( url ) )
                            up.Upload( fileBuf, url );
                    }
                }

            }
            finally
            {
                this.Cursor = cursor;
            }
        }
コード例 #6
0
ファイル: TestUploader.cs プロジェクト: killbug2004/WSProf
        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!");
        }
コード例 #7
0
ファイル: TestUploader.cs プロジェクト: killbug2004/WSProf
		private void Helper_EnsureDocumentIsThereForTesting(string url, 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(url))
				return;
			byte[] fileBuf;
            using (FileStream fileStream = new FileStream(referenceFilename, FileMode.Open, FileAccess.Read, FileShare.Read))
			using(BinaryReader reader = new BinaryReader(fileStream))
			{
				fileBuf = reader.ReadBytes((int)fileStream.Length);
			}
			uploader.Upload(fileBuf, url);
		}
コード例 #8
0
ファイル: TestUploader.cs プロジェクト: killbug2004/WSProf
		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
ファイル: TestUploader.cs プロジェクト: killbug2004/WSProf
		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
ファイル: TestUploader.cs プロジェクト: killbug2004/WSProf
		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
ファイル: TestUploader.cs プロジェクト: killbug2004/WSProf
		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");
		}