public async Task <IActionResult> CheckFromFile(IFormFile file, TextToCheck textToCheck, Frequencies freq)
        {
            if (file == null || file.Length == 0)
            {
                return(View("Error", "Nie wybrano pliku"));
            }
            var path = Path.Combine(
                Directory.GetCurrentDirectory(), "wwwroot",
                file.FileName);

            using (var stream = new FileStream(path, FileMode.Create))
            {
                await file.CopyToAsync(stream);
            }

            string text = await file.ReadAsStringAsync();

            string extension = Path.GetExtension(path);

            if (extension != ".txt")
            {
                return(View("Error", "Wprowadzono niepoprawny format pliku! Aplikacja obsługuje pliki .txt."));
            }

            textToCheck.Text       = text.ToLower();
            textToCheck.TextLength = textToCheck.Text.Length;

            // Counting instances of letters in the text
            textToCheck = textToCheck.MakeFrequency(textToCheck);

            textToCheck = freq.ComparingLanguage(textToCheck, freq);

            return(View("Score", textToCheck));
        }
        public void Index_MakeFrequency_IsMaked(string TestText)
        {
            textToCheck.Text = TestText;
            textToCheck      = textToCheck.MakeFrequency(textToCheck);

            double[] CorrectFrequency = new double[] { 3, 3, 0, 0, 1, 0, 0, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 3, 0, 0, 1, 0, 0, 0, 2, 1, 5 };

            Assert.AreEqual(CorrectFrequency, textToCheck.Frequency);
        }
        public ViewResult Index(TextToCheck textToCheck, FrequencyOfLetters frequencyOfLetters, Frequencies freq)
        {
            if (string.IsNullOrEmpty(textToCheck.Text))
            {
                return(View("Error", "Należy podać tekst do przetłumaczenia!"));
            }

            textToCheck.TextLength = textToCheck.Text.Length;
            textToCheck.Text       = textToCheck.Text.ToLower();

            // Counting instances of letters in the text
            textToCheck = textToCheck.MakeFrequency(textToCheck);

            textToCheck = freq.ComparingLanguage(textToCheck, freq);

            return(View("Score", textToCheck));
        }
 public void Setup()
 {
     controller  = new HomeController();
     textToCheck = new TextToCheck();
 }