コード例 #1
0
        public DictionaryFileLoaderTests()
        {
            _mockFileSystem                = new Mock <IFileSystem>();
            _mockDisplayOutput             = new Mock <IDisplayOutput>();
            _mockDictionaryParameterParser = new Mock <IDictionaryParameterParser>();

            var containerBuilder = new ContainerBuilder();

            containerBuilder
            .RegisterInstance(instance: _mockFileSystem.Object)
            .As <IFileSystem>();

            containerBuilder
            .RegisterInstance(instance: _mockDisplayOutput.Object)
            .As <IDisplayOutput>();

            containerBuilder
            .RegisterInstance(instance: _mockDictionaryParameterParser.Object)
            .As <IDictionaryParameterParser>();

            containerBuilder
            .RegisterType <DictionaryFileLoader>();

            _systemUnderTest = containerBuilder
                               .Build()
                               .Resolve <DictionaryFileLoader>();
        }
コード例 #2
0
ファイル: IndexOutput.cs プロジェクト: andrekirst/WordCount
        public void OutputIndex(IndexOutputRequest indexOutputRequest)
        {
            IndexParameter      indexParameter      = IndexParameterParser.ParseIndexParameter();
            DictionaryParameter dictionaryParameter = DictionaryParameterParser.ParseDictionaryParameter();

            if (indexParameter.IsPresent)
            {
                List <string> dictionaryWords = DictionaryFileLoader.ReadWords();

                int unknwonWordsCount = EnumerableHelpers.CountUnknownWords(
                    distinctWords: indexOutputRequest.DistinctWords,
                    dictionaryWords: dictionaryWords);

                if (dictionaryParameter.IsPresent)
                {
                    DisplayOutput.WriteResourceLine(
                        resourceIdent: "INDEX_WITH_UNKNOWN",
                        placeholderValues: unknwonWordsCount);
                }
                else
                {
                    DisplayOutput.WriteResourceLine(
                        resourceIdent: "INDEX");
                }

                DisplayWords(
                    distinctWords: indexOutputRequest.DistinctWords,
                    dictionaryWords: dictionaryWords);
            }
        }