public async void RemoveCommentNotificationShouldDeleteTheCorrectNotification() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var notificationRepository = new EfDeletableEntityRepository <Notification>(new ApplicationDbContext(options.Options)); var userRepository = new EfDeletableEntityRepository <ApplicationUser>(new ApplicationDbContext(options.Options)); var notificationsService = new NotificationsService(notificationRepository, userRepository); var notification = new Notification(); var notification2 = new Notification { Content = "True", }; await notificationRepository.AddAsync(notification); await notificationRepository.AddAsync(notification2); await notificationRepository.SaveChangesAsync(); await notificationsService.RemoveCommentNotification(notification.Id); var notifFromDb = await notificationRepository.AllAsNoTracking().FirstAsync(); Assert.Equal(notification2.Content, notifFromDb.Content); }
/// <summary> /// Initializes a new instance of the <see cref="TodoistClient" /> class. /// </summary> /// <param name="token">The token.</param> /// <param name="restClient">The rest client.</param> /// <exception cref="System.ArgumentException">Value cannot be null or empty - token</exception> public TodoistClient(string token, ITodoistRestClient restClient) { if (string.IsNullOrEmpty(token)) { throw new ArgumentException("Value cannot be null or empty.", nameof(token)); } _token = token; _restClient = restClient; Projects = new ProjectsService(this); Templates = new TemplateService(this); Items = new ItemsService(this); Labels = new LabelsService(this); Notes = new NotesService(this); Uploads = new UploadService(this); Filters = new FiltersService(this); Activity = new ActivityService(this); Notifications = new NotificationsService(this); Backups = new BackupService(this); Reminders = new RemindersService(this); Users = new UsersService(this); Sharing = new SharingService(this); Emails = new EmailService(this); Sections = new SectionService(this); }
public async Task GetNotificationsAsync_WithValidUserId_ShouldReturnAllUserNotifications() { // Arrange this.InitilaizeMapper(); var context = InMemoryDbContext.Initiliaze(); var notificationsRepository = new EfRepository <Notification>(context); var service = new NotificationsService(notificationsRepository); await this.SeedUsersAndPost(context); await this.SeedNotifications(context); int takeCount = 2; // Act var notifications = await service.GetNotificationsAsync("userId", 0, takeCount); bool notificationOneExists = context.Notifications.Any(x => x.Id == 26); // Valid id bool notificationTwoExists = context.Notifications.Any(x => x.Id == 27); // Valid id bool notificationThreeExists = context.Notifications.Any(x => x.Id == 257); // Invalid id // Assert Assert.True(notificationOneExists); Assert.True(notificationTwoExists); Assert.False(notificationThreeExists); }
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 GetUserNotifications_ReturnsAllUserNotifications_ForThatUserOnly() { var userId = Guid.NewGuid(); var userNotifications = new List <NotificationModel> { new NotificationModel { UserId = userId, Id = Guid.NewGuid() }, new NotificationModel { UserId = userId, Id = Guid.NewGuid() } }; notificationModels.AddRange(userNotifications); mockNotificationsAccess.Setup(x => x.GetUserNotifications(userId)).ReturnsAsync(userNotifications); var sut = new NotificationsService(mockNotificationsAccess.Object, mockNotificationTemplatesAccess.Object); var result = await sut.GetUserNotifications(userId); Assert.All(userNotifications, model => Assert.Contains(model, result)); Assert.Equal(userNotifications.Count, result.Count); }
protected override void LoadWorkerDoWork(object sender, DoWorkEventArgs e) { Utils.EnsureCulture(); OnReloading = true; Dispatcher.Invoke(new Action(() => { aiLoader.Visibility = Visibility.Visible; })); e.Result = NotificationsService.GetAll(); }
/// <summary> /// Initializes a new instance of the <see cref="StartupConfiguration"/> class. /// </summary> /// <param name="logger">The service logger.</param> /// <param name="applicationOptions">The application configuration to validate.</param> /// <param name="yamlConfigurationService">The configuration service to read user configuration.</param> /// <param name="gitService">The git service to configure and check repositories.</param> /// <param name="notificationsService">The notifications service to configure with the repositories.</param> public StartupConfiguration(ILogger <StartupConfiguration> logger, IOptions <ApplicationOptions> applicationOptions, YamlConfigurationService yamlConfigurationService, GitService gitService, NotificationsService notificationsService) { Logger = logger; ApplicationOptions = applicationOptions.Value; YamlConfigurationService = yamlConfigurationService; GitService = gitService; NotificationsService = notificationsService; }
public int CountUnreadedMessages() { NotificationsService service = new NotificationsService(services); string login = HttpContext.Session.GetString("User_Login"); int result = service.GetCountUnreadedMessages(login); return(result); }
public async Task GetAllNotifications_ReturnsAllNotifications() { mockNotificationsAccess.Setup(x => x.GetAllNotifications()).ReturnsAsync(notificationModels); var sut = new NotificationsService(mockNotificationsAccess.Object, mockNotificationTemplatesAccess.Object); var result = await sut.GetAllNotifications(); Assert.All(notificationModels, model => Assert.Contains(model, result)); }
private async Task LoadParticipatingNotifications() { ParticipatingNotifications = await NotificationsService.GetAllNotificationsForCurrentUser(false, true); IsloadingParticipating = false; if (ParticipatingNotifications != null) { ZeroParticipatingCount = (ParticipatingNotifications.Count == 0) ? true : false; } }
public async void NotificationsListView_ItemClick(object sender, ItemClickEventArgs e) { Notification notif = e.ClickedItem as Notification; await SimpleIoc.Default.GetInstance <IAsyncNavigationService>().NavigateAsync(typeof(RepoDetailView), "Repository", notif.Repository.FullName); if (notif.Unread) { await NotificationsService.MarkNotificationAsRead(notif.Id); } }
private async Task LoadUnreadNotifications() { UnreadNotifications = await NotificationsService.GetAllNotificationsForCurrentUser(false, false); IsLoadingUnread = false; if (UnreadNotifications != null) { ZeroUnreadCount = (UnreadNotifications.Count == 0) ? true : false; } }
private async Task LoadAllNotifications() { AllNotifications = await NotificationsService.GetAllNotificationsForCurrentUser(true, false); IsLoadingAll = false; if (AllNotifications != null) { ZeroAllCount = (AllNotifications.Count == 0) ? true : false; } }
private void DispatchPlayerStateUpdate(ZwiftPacketMonitor.PlayerState state) { var telemetry = JsonConvert.SerializeObject(new TelemetryModel() { PlayerId = state.Id, Power = state.Power, HeartRate = state.Heartrate }); NotificationsService.SendNotificationAsync(telemetry, false).Wait(); }
public async void Email_Notification_On_Every_Bad_Response() { var options = Options.Create(new NotificationsOptions() { HoursToIgnoreContinuousError = 0 }); var mockOptions = new Mock <IOptions <NotificationsOptions> >(); mockOptions.Setup(o => o.Value).Returns(options.Value); var portal = new Portal() { Id = Guid.NewGuid(), Name = "Test Portal", Type = PortalType.WebApp, URL = "http://www.delfi.lt", Parameters = "", Status = PortalStatus.Active, Email = "*****@*****.**", CheckInterval = 20, ResponseTimeThreshold = 20, Method = RequestMethod.GET, BasicAuth = false, LastNotificationSent = DateTime.Now.AddHours(-2) }; var portalResponse = new PortalResponse() { Id = Guid.NewGuid(), RequestDateTime = DateTime.Now.AddHours(-1), Status = 404, ResponseTime = 230, StatusPageId = portal.Id, StatusPage = portal, ErrorMessage = "Test error message" }; var portalUpdated = portal; portalUpdated.LastNotificationSent = portalResponse.RequestDateTime; _mockPortalService.Setup(x => x.SetLastNotificationSentAsync(It.IsAny <Guid>(), It.IsAny <DateTime>())).ReturnsAsync(portalUpdated); _mockSendGridService.Setup(x => x.SendEmailAsync(It.IsAny <Portal>(), It.IsAny <PortalResponse>())).ReturnsAsync(HttpStatusCode.Accepted); var notificationsService = new NotificationsService(_mockLogger.Object, _mockSendGridService.Object, _mockPortalService.Object, mockOptions.Object); var responseFromService = await notificationsService.SendNotificationEmailAsync(portal, portalResponse); Assert.Equal(HttpStatusCode.Accepted, responseFromService); _mockPortalService.Verify(x => x.SetLastNotificationSentAsync(It.IsAny <Guid>(), It.IsAny <DateTime>()), Times.Once); _mockSendGridService.Verify(x => x.SendEmailAsync(It.IsAny <Portal>(), It.IsAny <PortalResponse>()), Times.Once); }
private static PostsController MakePostsController(MissioContext missioContext = null) { if (missioContext == null) { missioContext = Utils.MakeMissioContext(); } var usersService = new UsersService(missioContext, new MockPasswordService(), Substitute.For <IWebClientService>()); var postsService = new PostsService(missioContext, usersService, new FakeTimeService()); var notificationsService = new NotificationsService(missioContext); return(new PostsController(usersService, postsService, notificationsService)); }
public async Task GetUserNotifications_ReturnsEmptyList_WhenNoMatchesAreFound() { var userId = Guid.NewGuid(); mockNotificationsAccess.Setup(x => x.GetUserNotifications(userId)) .ReturnsAsync(new List <NotificationModel>()); var sut = new NotificationsService(mockNotificationsAccess.Object, mockNotificationTemplatesAccess.Object); var result = await sut.GetUserNotifications(userId); Assert.Equal(0, result.Count); }
public ActionResult DeleteUser(int UserId) { string message = ""; if (NotificationsService.DeleteUser(UserId, out message)) { return(RedirectToAction("Index")); } else { return(RedirectToAction("DeleteUser", new { UserId = UserId, message = message })); } }
public NotificationsPageViewModel(INavigationService navigationService, IPageDialogService dialogService) { _navigation = navigationService; _dialogService = dialogService; Title = "NOTIFICATIONS"; _notificationService = new NotificationsService(); BackCommand = new Command(async() => { await OnBack(); }); GetNotifications(); //PromotionsCommand = new Command(async () => { await OnPromotions(); }); //UpdatesCommand = new Command(async () => { await OnUpdates(); }); //TierCommand = new Command(async () => { await OnTier(); }); //RemindersCommand = new Command(async () => { await OnReminders(); }); }
public ActionResult EditUser(Notifications user) { string message = ""; if (NotificationsService.EditUser(user, out message)) { return(RedirectToAction("Index")); } else { return(RedirectToAction("EditUser", new { user = user, message = message })); } }
protected override void OnActivated() { base.OnActivated(); // Perform various tasks depending on the target View. service = Application.Modules.FindModule <NotificationsModule>().NotificationsService; NotificationsDialogViewController notificationsDialogViewController = Frame.GetController <NotificationsDialogViewController>(); if (service != null && notificationsDialogViewController != null) { notificationsDialogViewController.Dismiss.Executing += Dismiss_Executing; notificationsDialogViewController.Dismiss.Executed += Dismiss_Executed; } }
/// <inheritdoc/> public override async void OnReceive(Context context, Intent intent) { LogHelper.Info("Notification receiver called!"); try { var notificationService = new NotificationsService(context); await notificationService.HandleNotificationBroadcastAsync(intent); } catch (Exception e) { LogHelper.Error($"ERROR! Message: `{e.Message}` StackTrace: `{e.StackTrace}`"); } }
public IHttpActionResult AddNotification([FromBody] List <string> param) { NotificationModel notificationModel = new NotificationModel(param[0], param[1], param[2], param[3]); NotificationsService notificationsService = NotificationsService.GetInstance; notificationsService.AddNotification(notificationModel); var userNameKey = notificationsService.ConnectedUsers.FirstOrDefault(x => x.Value == param[1]).Key; if (userNameKey != null) { context.Clients.Client(notificationsService.ConnectedUsers[userNameKey]).GetNotification(param[1]); } return(Ok()); }
public SystemService( SystemStatusService systemStatusService, SystemLaunchArguments systemLaunchArguments, SystemCancellationToken systemCancellationToken, NotificationsService notificationsService, MessageBusService messageBusService, ILogger <SystemService> logger) { _systemStatusService = systemStatusService ?? throw new ArgumentNullException(nameof(systemStatusService)); _systemLaunchArguments = systemLaunchArguments ?? throw new ArgumentNullException(nameof(systemLaunchArguments)); _notificationsService = notificationsService ?? throw new ArgumentNullException(nameof(notificationsService)); _messageBusService = messageBusService ?? throw new ArgumentNullException(nameof(messageBusService)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _creationTimestamp = DateTime.Now; }
public async Task CheckForUnreadNotifications() { var unread = await NotificationsService.GetAllNotificationsForCurrentUser(false, false); if (unread != null) { if (unread.Count > 0) { UpdateUnreadNotificationIndicator(true); } else { UpdateUnreadNotificationIndicator(false); } } }
private static async Task NotificationsService() { var notificationService = new NotificationsService(); var addressNotifications = await notificationService.GetAddressNotifications("AGfGWQeM6md6RtEsTUivQNXhp8p4ytkDMR", 1, null, 13, 2691913, 500); var blockNotifications = await notificationService.GetBlockNotifications(10); var contractNotifications = await notificationService.GetContractNotifications("0x67a5086bac196b67d5fd20745b0dc9db4d2930ed"); var tokenList = await notificationService.GetTokens(); var transaction = await notificationService.GetTransactionNotifications( "1db9ad15febbf7b9cfa11603ecbe52aad5be6137a9e1d29e83465fa664c2a6ed"); }
public async Task UpdateReadStatusAsync_WithNoNewNotifications_ShouldReturnMessage() { // Arrange var context = InMemoryDbContext.Initiliaze(); var notificationsRepository = new EfRepository <Notification>(context); var service = new NotificationsService(notificationsRepository); await this.SeedUsersAndPost(context); // Act string expectedResult = "There are no new notifications"; string actualResult = await service.UpdateReadStatusAsync("userId"); // Assert Assert.Equal(expectedResult, actualResult); }
public async void MarkAllNotificationsAsRead() { if (!GlobalHelper.IsInternet()) { //Sending NoInternet message to all viewModels Messenger.Default.Send(new GlobalHelper.NoInternet().SendMessage()); } else { IsLoadingAll = IsLoadingUnread = IsloadingParticipating = true; await NotificationsService.MarkAllNotificationsAsRead(); IsLoadingAll = IsLoadingUnread = IsloadingParticipating = false; await LoadUnreadNotifications(); } }
public async void MarkAllNotificationsAsRead() { if (!GlobalHelper.IsInternet()) { //Sending NoInternet message to all viewModels Messenger.Default.Send(new GlobalHelper.LocalNotificationMessageType { Message = "No Internet", Glyph = "\uE704" }); } else { IsLoadingAll = IsLoadingUnread = IsloadingParticipating = true; await NotificationsService.MarkAllNotificationsAsRead(); IsLoadingAll = IsLoadingUnread = IsloadingParticipating = false; } }
public async Task GetUnreadNotificationsAsync_WithValidUserId_ShouldReturnUnreadNotificationsCount() { // Arrange var context = InMemoryDbContext.Initiliaze(); var notificationsRepository = new EfRepository <Notification>(context); var service = new NotificationsService(notificationsRepository); await this.SeedUsersAndPost(context); await this.SeedNotifications(context); // Act int expectedResult = context.Notifications.Where(x => x.UserId == "userId" && x.Read == false).Count(); int actualResult = await service.GetUnreadNotificationsCountAsync("userId"); // Assert Assert.Equal(expectedResult, actualResult); }