public void Setup()
        {
            _mockRepository = new Mock <IAnalysesRepository>();
            _mockSerializer = new Mock <IAnalyseResultSerializer>();
            _mockAlgorithm  = new Mock <ITextAnalyserAlgorithms>();

            _testingObject = new TextAnalyserService(
                repository: _mockRepository.Object,
                serializer: _mockSerializer.Object,
                algorithm: _mockAlgorithm.Object);
        }
        public void GetNegativeWordsCount_ShouldReturn_CorrectCount_ForThePhrase(string phrase, int expectedNegativeWords)
        {
            // arrange
            var textAnalyserService = new TextAnalyserService();

            var negativeWords = new[] { "swine", "bad", "nasty", "horrible" };

            // act
            var negativeWordsCount = textAnalyserService.GetNegativeWordsCount(phrase, negativeWords);

            // assert
            negativeWordsCount.ShouldBe(expectedNegativeWords);
        }
        public void FilterNegativeWords_ShouldReturn_FilteredText_ForThePhrase_ContainingNegativeWords(string phrase, string filteredPhrase)
        {
            // arrange
            // arrange
            var textAnalyserService = new TextAnalyserService();

            var negativeWords = new[] { "swine", "bad", "nasty", "horrible" };

            // act
            var filteredContent = textAnalyserService.FilterNegativeWords(phrase, negativeWords);

            // assert
            filteredContent.ShouldBe(filteredPhrase);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Text Analyser!");
            Console.WriteLine();

            string filePath;

            Console.WriteLine();
            Console.WriteLine("Inform the file path:");
            filePath = Console.ReadLine();

            if (!File.Exists(filePath))
            {
                Console.WriteLine("File not found.");
                return;
            }

            Console.WriteLine("Inform the analyse algorithm");
            Console.WriteLine(" 1: TextSubStringsAlgorithm");
            Console.WriteLine(" 2: CharacterTableMapAlgorithm");

            try
            {
                switch (int.Parse(Console.ReadLine()))
                {
                case 1:
                    _algorithm = new TextSubStringsAlgorithm();
                    break;

                case 2:
                    _algorithm = new CharacterTableMapAlgorithm();
                    break;

                default:
                    Console.WriteLine("Invalid option.");
                    return;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Erro: {ex.Message}");
                return;
            }

            Console.WriteLine();
            Console.WriteLine($"Great. Lets analyse file {filePath}");
            Console.WriteLine();

            var sqlServerRepository = new SqlServerAnalyseDbContext();
            var jsonSerializer      = new JsonSerializer();

            Console.WriteLine("-----------------------");
            Console.WriteLine($"Repository: {sqlServerRepository}");
            Console.WriteLine($"Serializer: {jsonSerializer}");
            Console.WriteLine($"Algorithm: {_algorithm}");
            Console.WriteLine();

            Console.WriteLine("Running analyser ...");
            var analyser = new TextAnalyserService(
                repository: sqlServerRepository,
                serializer: jsonSerializer,
                algorithm: _algorithm);

            var result = analyser.Analyse(new AnalyseCommand(filePath));

            Console.WriteLine(result);
        }
Exemplo n.º 5
0
 public void PrepareUnitTests()
 {
     this.textAnalyserService = new TextAnalyserService();
 }