コード例 #1
0
ファイル: TestFileFilters.cs プロジェクト: killbug2004/WSProf
        public void Test_04_FileNameMatching_FilterFromDeltaView( )
        {
            string filterString = "Documents (*.docx;*.doc;*.pdf;*.rtf;*.txt)|*.docx; *.doc; *.pdf; *.rtf; *.txt|All files (*.*)|*.*||";
            FileFilters filter = new FileFilters( filterString );
            filter.SelectedIndex = 0;

            Assert.IsTrue( filter.Match( "test.doc" ), "Filter failed to recognize test.doc" );
            Assert.IsTrue( filter.Match( "c:\test.doc" ), "Filter failed to recognize c:\test.doc" );
            Assert.IsTrue( filter.Match( "c:\folder\test.doc" ), "Filter failed to recognize c:\folder\test.doc" );
            Assert.IsTrue( filter.Match( "test.DoC" ), "Filter failed to recognize test.DoC" );
            Assert.IsTrue( filter.Match( "http://somewhere/test.doc" ), "Filter failed to recognize http://somewhere/test.doc" );
            Assert.IsTrue( filter.Match( "http://somewhere/deeper/test.doc" ), "Filter failed to recognize http://somewhere/deeper/test.doc" );
            Assert.IsTrue( filter.Match( "test.doc.doc.doc" ), "Filter failed to recognize test.doc.doc.doc" );
            Assert.IsTrue( filter.Match( "test.xls.doc.doc" ), "Filter failed to recognize test.xls.doc.doc" );
            Assert.IsTrue( filter.Match( "test.doc.xls.doc" ), "Filter failed to recognize test.doc.xls.doc" );
            Assert.IsTrue(filter.Match( TestServerInfo.CombineUrlWithSPServer("/sites/dev/TestDocs/172172v1.doc")), string.Format("Filter failed to recognize {0}/sites/dev/TestDocs/172172v1.doc", TestServerInfo.SPTestServerAddr));

            Assert.IsFalse( filter.Match( "test.xls" ), "Incorrecly matched test.xls on a .doc filter" );
            Assert.IsFalse( filter.Match( "test.doc.xls" ), "Incorrecly matched test.doc.xls on a .doc filter" );
            Assert.IsFalse( filter.Match( "test" ), "Incorrecly matched 'test' on a .doc filter" );
            Assert.IsFalse( filter.Match( "http://test.xls" ), "Incorrecly matched http://test.xls on a .doc filter" );
            Assert.IsFalse( filter.Match( "http://test.doc.xls" ), "Incorrecly matched http://test.doc.xls on a .doc filter" );
            Assert.IsFalse( filter.Match( "" ), "Incorrecly matched a blank string on a .doc filter" );
            Assert.IsFalse( filter.Match( null ), "Incorrecly matched a null to a .doc filter" );
        }
コード例 #2
0
ファイル: TestFileFilters.cs プロジェクト: killbug2004/WSProf
		public void Test_03_FileNameMatching()
		{
			FileFilters filter = new FileFilters("Word (*.doc)|*.doc|Excel (*.xls)|*.xls|All(*.*)|*.*");
			filter.SelectedIndex = 0;
			Assert.IsTrue(filter.Match("test.doc"), "Filter failed to recognize test.doc");
			Assert.IsTrue(filter.Match("c:\test.doc"), "Filter failed to recognize c:\test.doc");
			Assert.IsTrue(filter.Match("c:\folder\test.doc"), "Filter failed to recognize c:\folder\test.doc");
			Assert.IsTrue(filter.Match("test.DoC"), "Filter failed to recognize test.DoC");
			Assert.IsTrue(filter.Match("http://somewhere/test.doc"), "Filter failed to recognize http://somewhere/test.doc");
			Assert.IsTrue(filter.Match("http://somewhere/deeper/test.doc"), "Filter failed to recognize http://somewhere/deeper/test.doc");
			Assert.IsTrue(filter.Match("test.doc.doc.doc"), "Filter failed to recognize test.doc.doc.doc");
			Assert.IsTrue(filter.Match("test.xls.doc.doc"), "Filter failed to recognize test.xls.doc.doc");
			Assert.IsTrue(filter.Match("test.doc.xls.doc"), "Filter failed to recognize test.doc.xls.doc");
            Assert.IsTrue(filter.Match(TestServerInfo.CombineUrlWithSPServer("/sites/dev/TestDocs/172172v1.doc")), string.Format("Filter failed to recognize {0}/sites/dev/TestDocs/172172v1.doc",TestServerInfo.SPTestServerAddr));
			
            Assert.IsFalse(filter.Match("test.xls"), "Incorrecly matched test.xls on a .doc filter");
			Assert.IsFalse(filter.Match("test.doc.xls"), "Incorrecly matched test.doc.xls on a .doc filter");
			Assert.IsFalse(filter.Match("test"), "Incorrecly matched 'test' on a .doc filter");
			Assert.IsFalse(filter.Match("http://test.xls"), "Incorrecly matched http://test.xls on a .doc filter");
			Assert.IsFalse(filter.Match("http://test.doc.xls"), "Incorrecly matched http://test.doc.xls on a .doc filter");
			Assert.IsFalse(filter.Match(""), "Incorrecly matched a blank string on a .doc filter");
			Assert.IsFalse(filter.Match(null), "Incorrecly matched a null to a .doc filter");
		}