コード例 #1
0
ファイル: ChainValidationTests.cs プロジェクト: Fyzxs/IMock
        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.");
        }
コード例 #2
0
ファイル: ChainValidationTests.cs プロジェクト: Fyzxs/IMock
        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]");
        }
コード例 #3
0
ファイル: ChainValidationTests.cs プロジェクト: Fyzxs/IMock
        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]");
        }
コード例 #4
0
ファイル: ChainValidationTests.cs プロジェクト: Fyzxs/IMock
        public void ShouldNotThrowGivenValidChain()
        {
            //Arrange
            ChainValidation subject = new ChainValidation()
                                      .NextClassInChain <LinkA>()
                                      .NextClassInChain <LinkB>();

            //Act
            Action action = () => subject.AssertExpectedChainOrder(new LinkHead());

            //Assert
            action.Should().NotThrow();
        }