private void HandleAddCommand() { Console.WriteLine("Enter the word"); var word = Console.ReadLine(); var complexity = ReadIntFromConsole(1, 5, "Enter the complexity"); Console.WriteLine("Enter the description"); var description = Console.ReadLine(); var phrase = new PhraseItem { Phrase = word, Complexity = complexity, Description = description, }; phrase.FormatPhrase(); phrase.UpdateAuthor(_selectedAuthor); var response = _service.AddPhraseAsync(_selectedPack.Id, phrase, _selectedAuthor).Result; //Исправить эту дичь if (response.Trim() == "{\"result\": true}") { Console.WriteLine($"Word {phrase.Phrase} was saved"); } else { Console.WriteLine($"Error on the word saving: {response}"); } }
private static PhraseItem GeneratePhrase() { var phrase = new PhraseItem { Phrase = RandomString(15), Description = RandomString(50), Complexity = Random.Next(1, 5) }; phrase.UpdateAuthor(_testAuthor); return(phrase); }
private static PhraseItem GenerateNewPhrase() { var phrase = new PhraseItem { Complexity = RandomNumber.Next(1, 5), Description = Lorem.Sentence(), Phrase = Name.First(), }; phrase.UpdateAuthor(TestAuthor); return(phrase); }
public void EditPhraseDescriptionTest() { var oldPhrase = GenerateNewPhrase(); _packService.AddPhrase(Id, oldPhrase); var newPhrase = new PhraseItem { Phrase = oldPhrase.Phrase, Description = $"{oldPhrase.Description} {Lorem.Sentence()}", Complexity = oldPhrase.Complexity % 5, }; newPhrase.UpdateAuthor(TestAuthor); _packService.EditPhrase(Id, oldPhrase, newPhrase, TestAuthor); var pack = _packService.GetPackById(Id); Assert.That(pack.Phrases.Any(p => p.Phrase == newPhrase.Phrase && p.Description == newPhrase.Description)); Assert.That(pack.Phrases.Select(p => p.Description), Is.Not.Contains(oldPhrase.Description)); _packService.DeletePhrase(Id, newPhrase.Phrase, TestAuthor); }