public async Task load_async_method_should_invoke_add_async_method_of_sentence_repository_class() { var sentenceRepositoryMock = new Mock <ISentenceRepository>(); var sentenceCreator = new SentenceCreator(); var sentenceService = new SentenceService(sentenceRepositoryMock.Object, sentenceCreator); await sentenceService.LoadAsync(_sentence); sentenceRepositoryMock.Verify(x => x.AddAsync(It.IsAny <Sentence>()), Times.Once); }
private async Task <Sentence> GetSentenceAsync(string sentence) { var sentenceRepository = new SentenceRepository(); var sentenceCreator = new SentenceCreator(); var sentenceService = new SentenceService(sentenceRepository, sentenceCreator); bool isLoaded = await sentenceService.LoadAsync(sentence); return((await sentenceRepository.GetAllAsync()).FirstOrDefault()); }
private async Task <string> ConvertBase(string text, Converter converter) { var sentenceRepository = new SentenceRepository(); var sentenceCreator = new SentenceCreator(); var sentenceService = new SentenceService(sentenceRepository, sentenceCreator); var isLoaded = await sentenceService.LoadAsync(text); await sentenceService.SortAsync(new SortAsc()); return(isLoaded ? await sentenceService.ConvertAsync(converter) : "Error!"); }
public async Task load_async_method_should_add_async_sentence_to_sentence_repository() { Sentence expected = new Sentence(new [] { "Mary", "had", "a", "little", "lamb" }); var sentenceRepository = new SentenceRepository(); var sentenceCreator = new SentenceCreator(); var sentenceService = new SentenceService(sentenceRepository, sentenceCreator); bool isLoaded = await sentenceService.LoadAsync(_sentence); var actual = (await sentenceRepository.GetAllAsync()).FirstOrDefault(); Assert.True(isLoaded); Assert.Equal(actual.Words, expected.Words); }