Ejemplo n.º 1
0
        public void Validate_WhenWordLadderResultFileHasNoTxtExtension_CallsHandlesErrorsAction()
        {
            // Arrange
            var startWord = "ABCD";
            var endWord   = "WXYA";
            var executing = false;
            var wordLadderResultFilePath = "teste.bin";

            var args = new Options(startWord, endWord, _validWordDictionaryFilePath, wordLadderResultFilePath);

            var expectedError =
                $"The provided file path {wordLadderResultFilePath} is not valid. Please provide a valid file path with a .txt extension for the answer file.";
            string actualError = null;

            _fileWrapper.ClearReceivedCalls();
            _fileWrapper.FileExists(Arg.Is(_validWordDictionaryFilePath)).Returns(true);
            _fileWrapper.IsValidPath(Arg.Is(wordLadderResultFilePath)).Returns(true);
            _fileWrapper.HasTxtExtension(Arg.Is(wordLadderResultFilePath)).Returns(false);

            // act
            _sut.Validate(args, (options) => { executing = true; }).HandleErrors((str) => { actualError = str; });

            // assert
            Assert.False(executing);
            actualError.Should().BeEquivalentTo(expectedError);
        }
Ejemplo n.º 2
0
        public InputValidatorTests()
        {
            _fileWrapper = Substitute.For <IFileWrapper>();
            _fileWrapper.ClearReceivedCalls();
            _fileWrapper.FileExists(Arg.Is(_validWordDictionaryFilePath)).Returns(true);
            _fileWrapper.IsValidPath(Arg.Is(_validWordLadderFilePath)).Returns(true);
            _fileWrapper.HasTxtExtension(Arg.Is(_validWordLadderFilePath)).Returns(true);

            _sut = new InputValidator(_fileWrapper);
        }