public void TestWithControlFlowOfType(Type filterType, Type returnType, bool result) { var filter = new SearcherFilter(SearcherContext.Graph).WithControlFlow(filterType); var data = new ControlFlowSearcherItemData(returnType); Assert.AreEqual(result, filter.ApplyFilters(data)); }
public void TestWithControlFlowOfTypeInStack(Type filterType, Type returnType, bool acceptNode, bool result) { var stackMock = new Mock <IStackModel>(); stackMock.Setup(s => s.AcceptNode(It.IsAny <Type>())).Returns(acceptNode); var filter = new SearcherFilter(SearcherContext.Stack).WithControlFlow(filterType, stackMock.Object); var data = new ControlFlowSearcherItemData(returnType); Assert.AreEqual(result, filter.ApplyFilters(data)); }
public void TestWithIfConditions(Type inputType, Type controlFlowType, bool acceptNode, bool result) { var stackMock = new Mock <IStackModel>(); stackMock.Setup(s => s.AcceptNode(It.IsAny <Type>())).Returns(acceptNode); var th = Stencil.GenerateTypeHandle(inputType); var filter = new SearcherFilter(SearcherContext.Stack).WithIfConditions(th, stackMock.Object); var data = new ControlFlowSearcherItemData(controlFlowType); Assert.AreEqual(result, filter.ApplyFilters(data)); }
public void TestWithControlFlowExcept(Type nodeType, bool acceptNode, bool expected) { var stackMock = new Mock <IStackModel>(); stackMock.Setup(s => s.AcceptNode(It.IsAny <Type>())).Returns(acceptNode); var filter = new SearcherFilter(SearcherContext.Graph) .WithControlFlowExcept(stackMock.Object, new[] { typeof(ICoroutine) }); var data = new ControlFlowSearcherItemData(nodeType); var applyFilter = typeof(SearcherFilter).GetMethod( "ApplyFilters", BindingFlags.Instance | BindingFlags.NonPublic); var result = applyFilter?.Invoke(filter, new object[] { data }); Assert.AreEqual(expected, result); }