Example #1
0
        public async Task GetEventTypesToRemind_DifferentOrganizations_ReturnsCorrectAmountEventTypes(int orgId, int amount)
        {
            MockEventTypes();

            var eventTypes = (await _eventUtilitiesService.GetEventTypesToRemindAsync(orgId)).ToList();

            Assert.AreEqual(amount, eventTypes.Count);
        }
Example #2
0
        public async Task SendNotificationsAsync(string orgName)
        {
            var userOrg = await _organizationService.GetOrganizationByNameAsync(orgName);

            var typesToNotifyAbout   = (await _eventUtilitiesService.GetEventTypesToRemindAsync(userOrg.Id)).ToList();
            var typeIdsToNotifyAbout = typesToNotifyAbout.Select(e => e.Id).ToList();

            if (!typesToNotifyAbout.Any())
            {
                return;
            }

            var anythingToJoin = await _eventUtilitiesService.AnyEventsThisWeekByTypeAsync(typeIdsToNotifyAbout);

            if (!anythingToJoin)
            {
                return;
            }

            var usersToNotifyInApp = (await _userEventsService.GetUsersWithAppRemindersAsync(typeIdsToNotifyAbout)).ToList();
            var usersToNotifyEmail = (await _userEventsService.GetUsersWithEmailRemindersAsync(typeIdsToNotifyAbout)).ToList();

            if (usersToNotifyInApp.Any())
            {
                await _notificationService.CreateForEventJoinReminderAsync(usersToNotifyInApp, userOrg.Id);
            }

            if (usersToNotifyEmail.Any())
            {
                await _eventNotificationService.RemindUsersToJoinEventAsync(typesToNotifyAbout, usersToNotifyEmail, userOrg.Id);
            }
        }
        public async Task SendNotifications_NoneTypesToRemind_DoesNothing()
        {
            _eventUtilitiesService.GetEventTypesToRemindAsync(1).Returns(new List <EventTypeDto>());
            _organizationService.GetOrganizationByNameAsync("visma").Returns(GetOrganization());

            await _sut.SendNotificationsAsync("visma");

            await _eventUtilitiesService.Received().GetEventTypesToRemindAsync(1);

            await _eventUtilitiesService.DidNotReceiveWithAnyArgs().AnyEventsThisWeekByTypeAsync(default);