Exemplo n.º 1
0
        public void TextFileReader_ThrowsAllFileNotFoundException_IfNotFile()
        {
            var textFileReader = new TextFileReader(fileName);

            var linesResult = textFileReader.GetLines();

            linesResult.IsSuccess.Should().BeFalse();
            linesResult.Error.Should().BeEquivalentTo(string.Format("Text file {0} is not found.\n" +
                                                                    "Check if file path is correct.", fileName));
        }
Exemplo n.º 2
0
        public void TextFileReader_ReadsAllTheLines()
        {
            var text = "123\nHi\nHello";

            File.WriteAllText(fileName, text);
            var textFileReader = new TextFileReader(fileName);
            var str            = "";

            foreach (var line in textFileReader.GetLines().Value)
            {
                if (str.Length != 0)
                {
                    str += "\n";
                }
                str += line;
            }

            str.Should().BeEquivalentTo(text);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Parser.Default.ParseArguments <Options>(args).WithParsed(o =>
            {
                var source = new DocumentReader(o.Filename);
                var excludedWordsSource = new TextFileReader(o.Exclude);
                var cloudOptions        = new CloudOptions(o.Color, o.FontFamilyName, o.Format, o.Height, o.Width);

                var builder = new ContainerBuilder();
                builder.RegisterType <WordsPreprocessor>().As <IWordsPreprocessor>();
                builder.RegisterType <SimpleCloudConfigurator>().As <ICloudConfigurator>();
                builder.RegisterType <CloudVisualizer>().As <ICloudVisualizer>();
                builder.RegisterInstance(source).As <ISource>();
                builder.RegisterInstance(excludedWordsSource).As <TextFileReader>();
                builder.RegisterInstance(cloudOptions).As <CloudOptions>();

                var container = builder.Build();
                var client    = container.Resolve <ICloudVisualizer>();

                client.VisualizeCloud();
            });
        }
Exemplo n.º 4
0
 public WordsPreprocessor(ISource source, TextFileReader excludedWordsSource)
 {
     words         = source.GetWords();
     excludedWords = excludedWordsSource.GetWords();
 }