public async Task Add_user_Notification_success() { //Arrange var model = new NotificationEventModel { Data = new NotificationData { AppointmentDateTime = "23/01/2020", FirstName = "Romio", OrganisationName = "Little Runners", Reason = "Healthy" }, Type = "AppointmentCancelled", UserId = Guid.NewGuid() }; //Act var catalogContext = new NotificationsDbContext(_dbOptions); var accessServ = new NotificationsAccess(catalogContext); var NotificationServ = new NotificationsService(accessServ); var testController = new NotificationsController(NotificationServ); var actionResult = await testController.AddUserNotification(model).ConfigureAwait(false); //Assert Assert.IsType <OkObjectResult>(actionResult); var result = Assert.IsAssignableFrom <NotificationModel>(((OkObjectResult)actionResult).Value); Assert.Contains("Healthy", result.Message); }
public async Task Get_user_Notification_Failed() { //Arrange var userId = new Guid(); //Act var catalogContext = new NotificationsDbContext(_dbOptions); var accessServ = new NotificationsAccess(catalogContext); var NotificationServ = new NotificationsService(accessServ); var testController = new NotificationsController(NotificationServ); var actionResult = await testController.GetUserCancelledAppointmentNotification(userId).ConfigureAwait(false); //Assert Assert.IsType <NotFoundObjectResult>(actionResult); var result = ((NotFoundObjectResult)actionResult).Value; Assert.Null(result); }
public async Task Get_user_Notification_success() { //Arrange var userId = testUserId; //Act var catalogContext = new NotificationsDbContext(_dbOptions); var accessServ = new NotificationsAccess(catalogContext); var NotificationServ = new NotificationsService(accessServ); var testController = new NotificationsController(NotificationServ); var actionResult = await testController.GetUserCancelledAppointmentNotification(userId).ConfigureAwait(false); //Assert Assert.IsType <OkObjectResult>(actionResult); var result = Assert.IsAssignableFrom <List <NotificationModel> >(((OkObjectResult)actionResult).Value); Assert.Equal(3, result.Count); Assert.Equal(EventType.AppointmentCancelled.ToString(), result[0].EventType); Assert.Contains("Hi Firstname, your appointment with OrganisationName at AppointmentDateTime has been cancelled for the following reason: Reason.", result[0].Message); }