Skip to content

Commit

Permalink
Merge pull request microsoft#3 from AbhitejJohn/fastfilterfixes
Browse files Browse the repository at this point in the history
Fast filter fixes
  • Loading branch information
AbhitejJohn authored Oct 4, 2017
2 parents b62c6ed + e1b4e4e commit 7a95760
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ public string ParseError
/// </summary>
public string[] ValidForProperties(IEnumerable<String> supportedProperties, Func<string, TestProperty> propertyProvider)
{
Debug.Assert(this.filterExpression != null || this.fastFilter != null);
return UseFastFilter ? this.fastFilter.ValidForProperties(supportedProperties) : this.filterExpression.ValidForProperties(supportedProperties, propertyProvider);
return UseFastFilter ? this.fastFilter.ValidForProperties(supportedProperties) : this.filterExpression?.ValidForProperties(supportedProperties, propertyProvider);
}

/// <summary>
Expand All @@ -122,9 +121,13 @@ public string[] ValidForProperties(IEnumerable<String> supportedProperties, Func
public bool Evaluate(Func<string, Object> propertyValueProvider)
{
ValidateArg.NotNull(propertyValueProvider, "propertyValueProvider");

if (UseFastFilter)
{
return this.fastFilter.Evaluate(propertyValueProvider);
}

Debug.Assert(this.filterExpression != null || this.fastFilter != null);
return UseFastFilter ? this.fastFilter.Evaluate(propertyValueProvider) : this.filterExpression.Evaluate(propertyValueProvider);
return this.filterExpression == null ? false : this.filterExpression.Evaluate(propertyValueProvider);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ public string TestCaseFilter
set;
}

/// <summary> 
   /// Get or set additional options for test case filter. 
   /// </summary> 

/// <summary>
/// Gets or sets additional options for filtering.
/// </summary>
[DataMember]
public FilterOptions FilterOptions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,15 +472,18 @@ public void StartTestRunShouldCallHandleLogMessageOnTestMessage()
() =>
{
this.mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.IsAny<string>())).Returns(completeMessage);
this.mockDataSerializer.Setup(ds => ds.DeserializePayload<TestRunCompletePayload>(completeMessage)).Returns(completePayload);
waitHandle.Set();
this.mockDataSerializer.Setup(ds => ds.DeserializePayload<TestRunCompletePayload>(completeMessage)).Callback(() => { waitHandle.Set(); })
.Returns(completePayload);
});

this.testRequestSender.StartTestRun(runCriteria, mockHandler.Object);
waitHandle.WaitOne();

this.mockCommunicationManager.Verify(mc => mc.SendMessage(MessageType.StartTestExecutionWithSources, runCriteria, this.protocolConfig.Version), Times.Once);
this.mockDataSerializer.Verify(ds => ds.DeserializeMessage(It.IsAny<string>()), Times.Exactly(2));
this.mockDataSerializer.Verify(ds => ds.DeserializeMessage(It.IsAny<string>()), Times.AtLeast(2));

// Asserting that 'StartTestRun" should have been completed, & invoked only once
this.mockDataSerializer.Verify(ds => ds.DeserializePayload<TestRunCompletePayload>(completeMessage), Times.Exactly(1));
mockHandler.Verify(mh => mh.HandleLogMessage(payload.MessageLevel, payload.Message), Times.Once);
mockHandler.Verify(mh => mh.HandleRawMessage(rawMessage), Times.AtLeastOnce);
}
Expand Down

0 comments on commit 7a95760

Please sign in to comment.