Esempio n. 1
0
        public void ReturnCorrectResultMessage_WhenPassedParametersAreValid()
        {
            // arrange
            var importersFactory = new Mock <IWordsImporterFactory>();

            string fileType          = "SomeFileType";
            string dictionaryTitle   = "SomeTitle";
            string filePath          = "SomePath";
            var    commandParameters = new List <string>()
            {
                fileType,
                dictionaryTitle,
                filePath
            };

            var importer = new Mock <IWordsImporterProvider>();

            importersFactory
            .Setup(x => x.GetImporter(It.IsAny <string>()))
            .Returns(importer.Object);

            var importWordsFromFileCommand = new ImportWordsFromFileCommand(importersFactory.Object);

            // act
            string resultMessage = importWordsFromFileCommand.Execute(commandParameters);

            // assert
            StringAssert.Contains($"from {filePath} have been successfuly imported", resultMessage);
        }
Esempio n. 2
0
        public void CallTheTargetImportersImportMethodWithCorrectDictionaryTitleAndFilePath_WhenPassedParametersAreValid()
        {
            // arrange
            var importersFactory = new Mock <IWordsImporterFactory>();

            string fileType          = "SomeFileType";
            string dictionaryTitle   = "SomeTitle";
            string filePath          = "SomePath";
            var    commandParameters = new List <string>()
            {
                fileType,
                dictionaryTitle,
                filePath
            };

            var importer = new Mock <IWordsImporterProvider>();

            importersFactory
            .Setup(x => x.GetImporter(It.IsAny <string>()))
            .Returns(importer.Object);

            var importWordsFromFileCommand = new ImportWordsFromFileCommand(importersFactory.Object);

            // act
            importWordsFromFileCommand.Execute(commandParameters);

            // assert
            importer.Verify(x => x.Import(filePath, dictionaryTitle));
        }