public void addNotificationTest() { db.addUser(testUser); int numUsers = db.retrieveAllUsers().Count; Notification testN = new Notification() { Title = "TestTitle", Description = "TestDescription", isSeen = false, TimeStamp = DateTime.UtcNow, URL = "www.google.com" }; int initialNumNotifications = db.retrieveAllNotifications().Count; db.addNotification(testN, numUsers); int finalNumNotifications = db.retrieveAllNotifications().Count; Assert.AreEqual(initialNumNotifications + 1, finalNumNotifications, "Notification Add Failed"); User toDelete = db.retrieveUser(numUsers); db.deleteUser(toDelete); int postDeleteUsers = db.retrieveAllUsers().Count; Assert.AreEqual(numUsers - 1, postDeleteUsers, "User Delete Failed"); }
public void updateNotificationTest() { db.addUser(testUser); int numUsers = db.retrieveAllUsers().Count; int initialNumNotifications = db.retrieveAllNotifications().Count; db.addNotification(testNotification, numUsers); int finalNumNotifications = db.retrieveAllNotifications().Count; Assert.AreEqual(initialNumNotifications + 1, finalNumNotifications, "Notification Add Failed"); var k = db.retrieveAllNotifications().Last().Id; int lastUserID = db.retrieveAllUserIds().Last(); Notification testEdit = new Notification() { Title = "EditedTitle", Description = "EditedDescription", isSeen = true, TimeStamp = DateTime.UtcNow, URL = "www.edited.com", Id = k, NotificationType = 2, UserId = lastUserID }; db.updateNotification(testEdit, lastUserID); Notification updatedNotification = db.retrieveNotification(k); Assert.AreEqual(testEdit.Title, updatedNotification.Title, "Notification Update Failed (Title)"); Assert.AreEqual(testEdit.Description, updatedNotification.Description, "Notification Update Failed (Description)"); Assert.IsTrue(testEdit.TimeStamp == updatedNotification.TimeStamp, "Notification Update Failed (TimeStamp)"); }
public void addNotificationTest() { Notification testN = new Notification() { Title = "TestTitle", Description = "TestDescription", isSeen = false, TimeStamp = DateTime.UtcNow, URL = "www.google.com" }; int initialNumNotifications = db.retrieveAllNotifications().Count; db.addNotification(testN, 5); int finalNumNotifications = db.retrieveAllNotifications().Count; Assert.AreEqual(initialNumNotifications + 1, finalNumNotifications, "Notification Add Failed"); }