Пример #1
0
 public void SetUp()
 {
     textReader            = A.Fake <ITextReader>();
     wordsFilter           = A.Fake <IWordsFilter>();
     wordsCounter          = A.Fake <IWordsCounter>();
     wordsToSizesConverter = A.Fake <IWordsToSizesConverter>();
     ccl        = A.Fake <ICloudLayouter>();
     visualiser = A.Fake <IVisualiser>();
     imageSaver = A.Fake <IFileSaver>();
 }
Пример #2
0
        private void OnSelectedAlgorithmChanged()
        {
            var strategyKey = SelectedAlgorithm == WordCounterAlgorithm.Dict
                ? TypesConsts.DictStrategy
                : TypesConsts.LinqStrategy;
            _wordsCounter = ServiceLocator.Current.GetInstance<IWordsCounter>(strategyKey);

            if (Result == null)
            {
                return;
            }
            CheckSentence.Execute(Sentence);
        }
Пример #3
0
 public TagCloudGenerator(
     IWordsLayouter wordsLayouter,
     IWordsDrawer wordsDrawer,
     IWordsFileReader wordsFileReader,
     IEnumerable <IWordsProcessor> processors,
     IWordsCounter counter,
     IEnumerable <IImageSaver> savers)
 {
     this.wordsLayouter   = wordsLayouter;
     this.wordsDrawer     = wordsDrawer;
     this.wordsFileReader = wordsFileReader;
     this.processors      = processors;
     this.counter         = counter;
     this.savers          = savers;
 }
Пример #4
0
 public TagsCloudContainer(ITextReader textReader, IWordsFilter wordsFilter, IWordsCounter wordsCounter,
                           IWordsToSizesConverter wordsToSizesConverter,
                           ICloudLayouter ccl, IVisualiser visualiser, IFileSaver fileSaver,
                           string output,
                           string input
                           )
 {
     this.textReader            = textReader;
     this.wordsFilter           = wordsFilter;
     this.wordsCounter          = wordsCounter;
     this.wordsToSizesConverter = wordsToSizesConverter;
     CCL             = ccl;
     this.visualiser = visualiser;
     outputFile      = output;
     inputFile       = input;
     imageSaver      = fileSaver;
 }
Пример #5
0
 public TagsCloudController(
     IConfiguration configuration,
     IDataReader reader,
     IPreprocessor preprocessor,
     IWordsCounter wordsCounter,
     ITagsGenerator tagsGenerator,
     IVisualizer visualizer,
     IImageWriter imageWriter)
 {
     this.configuration = configuration;
     this.reader        = reader;
     this.preprocessor  = preprocessor;
     this.wordsCounter  = wordsCounter;
     this.tagsGenerator = tagsGenerator;
     this.visualizer    = visualizer;
     this.imageWriter   = imageWriter;
 }
Пример #6
0
        private void SentenceWithDifferentSeparatorsTest(IWordsCounter wordsCounter)
        {
            const string SampleString = "This,is;a/sentence\\it(is<simple.";

            wordsCounter.Count(SampleString);

            wordsCounter.CheckIfResultIsProvidedAndNotEmpty();
            wordsCounter.CheckWordInResult("this", 1);
            wordsCounter.CheckWordInResult("is", 2);
            wordsCounter.CheckWordInResult("a", 1);
            wordsCounter.CheckWordInResult("sentence", 1);
            wordsCounter.CheckWordInResult("it", 1);
            wordsCounter.CheckWordInResult("simple", 1);
            wordsCounter.CheckWordInResult(",", 0);
            wordsCounter.CheckWordInResult(".", 0);
            wordsCounter.CheckResultCount(6);
        }
 private void MoreThanOneSentenceTest2(IWordsCounter counter)
 {
     counter.Count("This is first sentence! This is second sentence.");
 }
Пример #8
0
 public WordsCounterViewModel()
 {
     AvailableAlgorithms = new[] {WordCounterAlgorithm.Dict, WordCounterAlgorithm.Linq};
     CheckSentence = new RelayCommand<string>(ExecuteCheckSentence, CanCheckSentence);
     _wordsCounter = ServiceLocator.Current.GetInstance<IWordsCounter>(TypesConsts.DictStrategy);
 }
Пример #9
0
        private void SimpleSentenceWithoutDotTest(IWordsCounter wordsCounter)
        {
            const string SampleString = "This is a sentence, it is simple";

            wordsCounter.Count(SampleString);

            wordsCounter.CheckIfResultIsProvidedAndNotEmpty();
            wordsCounter.CheckWordInResult("this", 1);
            wordsCounter.CheckWordInResult("is", 2);
            wordsCounter.CheckWordInResult("a", 1);
            wordsCounter.CheckWordInResult("sentence", 1);
            wordsCounter.CheckWordInResult("it", 1);
            wordsCounter.CheckWordInResult("simple", 1);
            wordsCounter.CheckWordInResult(",", 0);
            wordsCounter.CheckWordInResult(".", 0);
            wordsCounter.CheckResultCount(6);
        }
Пример #10
0
 public CloudMaker(IWordsCounter counter, IWeightScaler scaler, CloudDrawer drawer)
 {
     this.counter = counter;
     this.scaler  = scaler;
     this.drawer  = drawer;
 }
Пример #11
0
        private void SentenceWithDifferentSpacingTest(IWordsCounter wordsCounter)
        {
            const string SampleString = "\t ,  It \nis a sentence,     it \r   \t is simple.";

            wordsCounter.Count(SampleString);

            wordsCounter.CheckIfResultIsProvidedAndNotEmpty();
            wordsCounter.CheckWordInResult("it", 2);
            wordsCounter.CheckWordInResult("is", 2);
            wordsCounter.CheckWordInResult("a", 1);
            wordsCounter.CheckWordInResult("sentence", 1);
            wordsCounter.CheckWordInResult("simple", 1);
            wordsCounter.CheckWordInResult(",", 0);
            wordsCounter.CheckWordInResult(".", 0);
            wordsCounter.CheckResultCount(5);
        }
Пример #12
0
        private void SentenceWithSeparatorsOnlyTest(IWordsCounter wordsCounter)
        {
            const string SampleString = ".;  \t , ()\\~/;";

            wordsCounter.Count(SampleString);

            wordsCounter.CheckIfResultIsEmpty();
        }
Пример #13
0
        private void SentenceWithDifferentBracketsTest(IWordsCounter wordsCounter)
        {
            const string SampleString = "This (is) <a> [sentence], it {is} simple.";

            wordsCounter.Count(SampleString);

            wordsCounter.CheckIfResultIsProvidedAndNotEmpty();
            wordsCounter.CheckWordInResult("this", 1);
            wordsCounter.CheckWordInResult("is", 2);
            wordsCounter.CheckWordInResult("a", 1);
            wordsCounter.CheckWordInResult("sentence", 1);
            wordsCounter.CheckWordInResult("it", 1);
            wordsCounter.CheckWordInResult("simple", 1);
            wordsCounter.CheckWordInResult(",", 0);
            wordsCounter.CheckWordInResult(".", 0);
            wordsCounter.CheckResultCount(6);
        }
 private void EmptySentenceTest(IWordsCounter counter)
 {
     counter.Count(string.Empty);
 }
Пример #15
0
        private void SentenceDifferentCaseTest(IWordsCounter wordsCounter)
        {
            const string SampleString = "IT Is a sentence, it iS simple.";

            wordsCounter.Count(SampleString);

            wordsCounter.CheckIfResultIsProvidedAndNotEmpty();
            wordsCounter.CheckWordInResult("it", 2);
            wordsCounter.CheckWordInResult("is", 2);
            wordsCounter.CheckWordInResult("a", 1);
            wordsCounter.CheckWordInResult("sentence", 1);
            wordsCounter.CheckWordInResult("simple", 1);
            wordsCounter.CheckWordInResult(",", 0);
            wordsCounter.CheckWordInResult(".", 0);
            wordsCounter.CheckResultCount(5);
        }
 private void WhitespaceSentenceTest5(IWordsCounter counter)
 {
     counter.Count(" \t\t  \r\n   ");
 }
 private void WhitespaceSentenceTest4(IWordsCounter counter)
 {
     counter.Count("\r");
 }
 private void NullSentenceTest(IWordsCounter counter)
 {
     counter.Count(null);
 }
 private void MoreThanOneSentenceTest3(IWordsCounter counter)
 {
     counter.Count("This is first sentence. Is there a second sentence?");
 }