Example #1
0
        public async Task TestAddPushNotificationSubscriptionAsync()
        {
            //Setup
            TestingContext testingContext = new TestingContext();

            SetUpTestingContext(testingContext);

            INotificationService        notificationService = testingContext.GetService <NotificationService>();
            NotificationSubscriptionDto dto = new NotificationSubscriptionDto()
            {
                Endpoint = "Test",
                Keys     = new KeyDto()
                {
                    Auth   = "TestAut",
                    P256dh = "testp256",
                },
                ExpirationTime = DateTime.Today.AddYears(3),
            };

            //Act
            await notificationService.AddPushNotificationSubscriptionAsync(dto);

            //Assert
            ApplicationDbContext     dbContext = testingContext.GetSimple <ApplicationDbContext>();
            NotificationSubscription sub       = await dbContext.Notifications.LastAsync();

            Assert.Equal(dto.Endpoint, sub.Endpoint);
            Assert.True(sub.Id > 0);
        }
Example #2
0
        public async Task <JsonResult> AddPushRegistration([FromBody] NotificationSubscriptionDto dto)
        {
            await _notificationService.AddPushNotificationSubscriptionAsync(dto);

            return(Json(OkReturnString));
        }