public async void NewsFunctionalityTest() { _token = await _accountManagementService.SignIn(TestingObjectProvider.Instance.Login); Assert.NotNull(_token); var news = TestingObjectProvider.Instance.News; Assert.NotNull(await _newsManagementService.GetAllNews(_token.Jwt)); Assert.NotNull(await _newsManagementService.GetNews(news.Id, _token.Jwt)); Assert.True(await _newsManagementService.CreateNews(news, _token.Jwt)); Assert.True(await _newsManagementService.DeleteNews(news, _token.Jwt)); var exception = Record.Exception(() => _newsManagementService.UpdateNews(null, _token.Jwt).Result); Assert.IsType(typeof(NullReferenceException), exception?.InnerException); Assert.False(await _newsManagementService.CreateNews(null, _token.Jwt)); }
public async Task <IActionResult> Add( [Bind("Title, Contents")] News news, string status, CancellationToken cancellationToken) { Enum.TryParse(status, out NewsStatus newsStatus); news.Type = newsStatus; if (ModelState.IsValid) { if (await _newsManagementService.CreateNews(news, CurrentCookiesToken, cancellationToken)) { return(Json(new { success = true })); } CheckUnexpectedErrors(); } return(PartialView(news)); }
public async void TestOfCreatingNewNews() { Assert.True(await _newsManagementService.CreateNews(_testingNews, _token.Jwt)); }