public async Task <IActionResult> AddNews(NotificationContext news) { var user = await _userManager.GetUserAsync(HttpContext.User); NotificationContext data = new NotificationContext(news.Title, news.Message, user.UserName); notifyRepo.Add(data); return(RedirectToAction("Index", "Home")); }
public void NotificationRepository_GetById_ThrowsExceptionWhenIdNotFound() { //arrange INotificationRepo nr = GetInMemoryNotificationRepository(); //act nr.Add(notification); //assert Assert.ThrowsAny <ArgumentNullException>(() => nr.GetById(0)); }
public void NotificationRepository_GetByUserId_ReturnsIEnumerable() { //arrange INotificationRepo nr = GetInMemoryNotificationRepository(); Notification notification2 = new Notification { Type = "like", ReceiverId = 1, SenderId = 3, Status = true, ReviewId = 2 }; //act nr.Add(notification); nr.Add(notification2); //assert Assert.IsAssignableFrom <IEnumerable <Notification> >(nr.GetByReceiverId(1)); }
public void NotificationRepository_DeleteById_DeletesNotification() { //arrange INotificationRepo nr = GetInMemoryNotificationRepository(); //act nr.Add(notification); nr.DeleteById(1); //NotificationId should be 1 //assert Assert.ThrowsAny <ArgumentNullException>(() => nr.GetById(1)); }
public Notification Add(string Description, DateTime date, string userid) { Notification p = new Notification() { Description = Description, Date = date, AspNetUsersId = userid }; Repository.Add(p); return(p); }
public void NotificationRepository_DeleteByUserId_DeletesNotifications() { //arrange INotificationRepo nr = GetInMemoryNotificationRepository(); Notification notification2 = new Notification { Type = "like", ReceiverId = 1, SenderId = 3, Status = true, ReviewId = 2 }; //act nr.Add(notification); nr.Add(notification2); nr.DeleteByUserId(1); //both notifications have same receiver id //assert Assert.ThrowsAny <ArgumentNullException>(() => nr.GetById(1)); Assert.ThrowsAny <ArgumentNullException>(() => nr.GetById(2)); }
public void NotificationRepository_Add_AddsNotification() { //arrange INotificationRepo nr = GetInMemoryNotificationRepository(); //act nr.Add(notification); var savedNotification = nr.GetById(1); //assert Assert.Equal(1, savedNotification.ReceiverId); Assert.Equal(2, savedNotification.SenderId); Assert.Equal("like", savedNotification.Type); Assert.Equal(1, savedNotification.ReviewId); Assert.True(savedNotification.Status); }
public IActionResult AddFakeNews() { notifyRepo.Add(new NotificationContext("Demo title", "Demo tekst demo tekst demo tekst demo tekst demo tekst", "Admin")); return(View("Index")); }