Esempio n. 1
0
        public async Task Should_SendNotifications()
        {
            //Arrange
            List <UserNotificationSetting> userNotificationSettings      = new BranchUserDefaults().GetUserNotificationSettings();
            MainNotificationTemplateModel  mainNotificationTemplateModel = new UserNotificationSettingBuilder().ReturnMainNotificationTemplateModel();

            _iNotificationQuerie.Setup(q => q.GetNotificationSettingByUserIdAndUserType(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>()))
            .Returns(() =>
            {
                return(Task.FromResult <List <UserNotificationSetting> >(userNotificationSettings));
            });
            _idmProxy.Setup(q => q.GetMonafasatUsersByAgencyTypeAndRoleName(It.IsAny <UsersSearchCriteriaModel>()))
            .Returns(() =>
            {
                return(Task.FromResult <QueryResult <EmployeeIntegrationModel> >(It.IsAny <QueryResult <EmployeeIntegrationModel> >()));
            });
            _iNotificationQuerie.Setup(q => q.GetNotificationSettingByRoleAndOperationCode(It.IsAny <List <int> >(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>()))
            .Returns(() =>
            {
                return(Task.FromResult <List <UserNotificationSetting> >(userNotificationSettings));
            });
            //Act
            await _sut.SendNotifications(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), mainNotificationTemplateModel, It.IsAny <string>());

            //Assert
        }
Esempio n. 2
0
        public async Task Should_SendNotificationByUserId(int notificationCodeId, int userId, string userName)
        {
            //Arrange
            MainNotificationTemplateModel mainNotificationTemplateModel = new UserNotificationSettingBuilder().ReturnMainNotificationTemplateModel();
            UserAPIModel userAPIModel = new UserAPIModel()
            {
                Email = "*****@*****.**", PhoneNumber = "0505050500"
            };

            _iNotificationQuerie.Setup(q => q.GetNotificationSettingByUserId(It.IsAny <int>(), It.IsAny <int>()))
            .Returns(() =>
            {
                return(Task.FromResult <UserNotificationSetting>(new NotificationsDefaults().GetUserNotificationSettingWithProfileId()[0]));
            });

            _idmProxy.Setup(q => q.GetUserbyUserName(It.IsAny <string>()))
            .Returns(() =>
            {
                return(Task.FromResult <UserAPIModel>(userAPIModel));
            });

            var entryMock = new Mock <ICacheEntry>();

            _cache.Setup(m => m.CreateEntry(It.IsAny <object>()))
            .Returns(entryMock.Object);



            _iNotificationQuerie.Setup(q => q.FindAllNotificationOperationCode())
            .Returns(() =>
            {
                return(Task.FromResult <List <NotificationOperationCode> >(new NotificationsDefaults().GetNotificationOperationCode()));
            });



            //Act
            await _sut.SendNotificationByUserId(notificationCodeId, userId, userName, mainNotificationTemplateModel);

            //Assert
            _notifayCommands.Verify(m => m.SaveChangesAsync(), Times.Once);
        }