public void ShouldThrowMeaningfulExceptionGivenInvalidChain() { //Arrange ChainValidation subject = new ChainValidation() .NextClassInChain <LinkA>("Not_The_Field_Name") .NextClassInChain <LinkA>(); //Act Action action = () => subject.AssertExpectedChainOrder(new LinkHead()); //Assert action.Should().Throw <Exception>().WithMessage("Expected field [name=Not_The_Field_Name] to be of [type=LinkA] but a field [name=Not_The_Field_Name] was not found."); }
public void ShouldThrowGivenInvalidChain() { //Arrange ChainValidation subject = new ChainValidation() .NextClassInChain <LinkA>() .NextClassInChain <LinkA>(); //Act Action action = () => subject.AssertExpectedChainOrder(new LinkHead()); //Assert action.Should().Throw <Exception>().WithMessage("Expected [name=_nextAction] to be of [type=LinkA] but found [type=LinkB]"); }
public void ShouldAcceptCustomNames() { //Arrange ChainValidation subject = new ChainValidation() .NextClassInChain <LinkC>() .NextClassInChain <LinkA>("_someOtherName"); //Act Action action = () => subject.AssertExpectedChainOrder(new LinkCustom()); //Assert action.Should().Throw <Exception>().WithMessage("Expected [name=_someOtherName] to be of [type=LinkA] but found [type=LinkB]"); }
public void ShouldNotThrowGivenValidChain() { //Arrange ChainValidation subject = new ChainValidation() .NextClassInChain <LinkA>() .NextClassInChain <LinkB>(); //Act Action action = () => subject.AssertExpectedChainOrder(new LinkHead()); //Assert action.Should().NotThrow(); }