Beispiel #1
0
        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));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(
            [Bind("Id, Title, Contents, Status, PublishingTime, AddingTime, LastEditTime")]
            News news, string status, CancellationToken cancellationToken)
        {
            Enum.TryParse(status, out NewsStatus newsStatus);
            news.Type = newsStatus;

            if (ModelState.IsValid)
            {
                if (await _newsManagementService.UpdateNews(news, CurrentCookiesToken, cancellationToken))
                {
                    return(Json(new { success = true }));
                }

                CheckUnexpectedErrors();
            }

            return(PartialView(news));
        }
Beispiel #3
0
 public async void TestOUpdatingNews()
 {
     Assert.True(await _newsManagementService.UpdateNews(_testingNews, _token.Jwt));
 }