public void NotExtensionEvaluesCorrectly() { var model = new GuidCount(); model.Increment(); Assert.False(new PositiveCounterRule().Not().IsSatisfied(model)); }
public void SimpleSatisfiedRuleReturnsTrue() { var model = new GuidCount(); model.Increment(); Assert.True(new PositiveCounterRule().IsSatisfied(model)); }
public void OrExtensionEvaluatesCorrectly() { var model = new GuidCount(); model.Increment(); Assert.True(new PositiveCounterRule().Or(new NegativeCounterRule()).IsSatisfied(model)); }
public void ExecutesWithoutBusinessRule() { var model = new GuidCount(); new GuidCountIncrementWorkflow().Execute(model); Assert.Equal(1, model.Counter); }
public void CanExecuteChainedWorkflowsOfDifferentTypeViaFlow() { var incWorkflow = new GuidCountIncrementWorkflow(); var dupWorkflow = new GuidCountDuplicateWorkflow(); var results = new GuidCount().AsFlowable().Flow(incWorkflow).Flow(incWorkflow).Flow(dupWorkflow).Value; Assert.Equal(2, results.Count); Assert.True(results.All(r => r.Counter == 2)); }
public void ValidatesPreBusinessRuleAndExecutes() { var model = new GuidCount(); var preRule = Substitute.For <IStateRule <GuidCount> >(); preRule.IsSatisfied(Arg.Any <GuidCount>()).Returns(true); new GuidCountIncrementWorkflow(preRule).Execute(model); Assert.Equal(1, model.Counter); }
public void TypeModWorkflowExecutesCorrectly() { var model = new GuidCount(); var preRule = Substitute.For <IStateRule <GuidCount> >(); preRule.IsSatisfied(Arg.Any <GuidCount>()).Returns(true); var result = new GuidCountDuplicateWorkflow(preRule).Execute(model); Assert.IsType <List <GuidCount> >(result); Assert.Equal(2, result.Count); }
public void AndPredicateFiltersCorrectly() { var validCandidate = new GuidCount { Counter = 1 }; var invalidCandidate = new GuidCount { Counter = -1 }; var candidates = new List <GuidCount> { validCandidate, invalidCandidate }.AsQueryable(); var filtered = candidates.Where(new PositiveCounterRule().And(new LessThanTenCounterRule()).Predicate).ToList(); Assert.Equal(1, filtered.Count); Assert.Equal(validCandidate.Id, filtered[0].Id); }
public void ThrowsErrorOnInvalidPreBusinessRuleAndDoesNotExecute() { var model = new GuidCount(); var preRule = Substitute.For <IStateRule <GuidCount> >(); preRule.IsSatisfied(Arg.Any <GuidCount>()).Returns(false); const string description = "This mock rule must be satisfied."; preRule.Description = description; var message = Assert.Throws(typeof(StateRuleException), () => new GuidCountIncrementWorkflow(preRule).Execute(model)).Message; Assert.Equal(description, message); Assert.Equal(0, model.Counter); }