public void BlankFilenameReturnsFalse() { ReadOnlyFilter filter = (ReadOnlyFilter)this.CreateInstance(); MockFileInfo fi = new MockFileInfo( "" ); bool result = filter.Filter( fi ); Assert.AreEqual( false, result, "A blank filename didn't fail the test" ); }
public void BlankFilenameReturnsFalse() { NameFilter filter = (NameFilter)this.CreateInstance(); filter.StringFilter = "something"; MockFileInfo fi = new MockFileInfo( "" ); bool result = filter.Filter( fi ); Assert.AreEqual( false, result, "A blank filename didn't fail the test" ); }
public void ReadOnlyTesting( bool ReadOnlyState, bool ExpectedResult ) { ReadOnlyFilter filter = (ReadOnlyFilter)this.CreateInstance(); MockFileInfo fi = new MockFileInfo( filename ); Assert.AreEqual( true, fi.Exists, "Trying to test a filter on a file that exists and the sample file doesn't" ); fi.IsReadOnly_Mock = ReadOnlyState; bool result = filter.Filter( fi ); Assert.AreEqual( ExpectedResult, result ); }
public void FilterByString( string StringFilter, bool CaseSensitive, bool HandleDirSep, bool ExpectedResult ) { NameFilter filter = (NameFilter)this.CreateInstance(); filter.CaseSensitive = CaseSensitive; filter.HandleDirSep = HandleDirSep; filter.StringFilter = StringFilter; MockFileInfo fi = new MockFileInfo( filename ); bool result = filter.Filter( fi ); Assert.AreEqual( ExpectedResult, result ); }
public void InvalidRegexThrowsException() { NameFilter filter = (NameFilter)this.CreateInstance(); filter.RegexFilter = "("; MockFileInfo fi = new MockFileInfo( filename ); try { bool result = filter.Filter( fi ); Assert.Fail( "An exception wasn't thrown with an invalid regex" ); } catch ( BuildException ex ) { if ( ex == null || ex.InnerException == null || !ex.Message.Contains( "regex", StringComparison.InvariantCultureIgnoreCase ) || ex.InnerException.GetType() != typeof(ArgumentException) ) { throw; } else { // It passed } } }
public void NoFilenameOrRegexThrows() { NameFilter filter = (NameFilter)this.CreateInstance(); // No StringFilter, no RegexFilter MockFileInfo fi = new MockFileInfo( filename ); try { bool result = filter.Filter( fi ); Assert.Fail( "An exception wasn't thrown with no string or regex" ); } catch ( BuildException ex ) { if ( !ex.Message.Contains( "requires exactly one", StringComparison.InvariantCultureIgnoreCase ) ) { throw; } else { // It passed } } }
public void NoDateOrMillsIsEpoch() { MockFileInfo fi = new MockFileInfo( "mockfile" ) { LastWriteTime_Mock = this.EPOCH }; DateFilter filter = (DateFilter)this.CreateInstance(); filter.Granularity = 0; filter.When = TimeWhen.equal; // We can't test the date it uses, but we can test if it's equal to something bool result = filter.Filter( fi ); Assert.AreEqual( true, result ); }