public async Task CreateAsync_Ok() { var createText = new CreateText("words", "title", "lang"); var textRepository = CreateTextRepositoryMock() .MockExistByTileAsync("title", false) .Resolve(); var text = new TextBusiness(textRepository, EmptyUserRepository); await text.CreateAsync(createText); }
public async Task CreateAsync_InvalidTitle() { var textRepository = CreateTextRepositoryMock() .MockExistByTileAsync("title", true) .Resolve(); var text = new TextBusiness(textRepository, EmptyUserRepository); var invalidParamException = await ThrowsAsync <InvalidParamException>(() => text.CreateAsync(new CreateText("words", "title", "lang"))); Equal("Title", invalidParamException.ParamName); Equal("A text with this title is already stored", invalidParamException.Message); }
public async Task FillDatabaseWithBigData() { foreach (var source in Feeds) { var posts = await _rssFeedRepository.RetrieveAsync(source.Url, source.FeedType); foreach (var post in posts) { try { await _textBusiness.CreateAsync(new CreateText(post.MainContent, post.Title, source.Lang)); } catch (InvalidParamException) { //TODO: ignoring this error } } } }
public Task SaveText([FromBody] CreateTextRequest createTextRequest) { return(_textBusiness.CreateAsync(new CreateText(createTextRequest.Words, createTextRequest.Title, createTextRequest.Language))); }