public void SetUp()
        {
            _mockSettingsRepo = new Mock <IUserSettingsRepository>();
            _mockValidator    = new Mock <IValidator <UpdateUserNotificationSettingsCommand> >();

            _sut = new UpdateUserNotificationSettingsHandler(_mockSettingsRepo.Object, _mockValidator.Object, Mock.Of <IProviderCommitmentsLogger>());

            _command = new UpdateUserNotificationSettingsCommand {
                UserRef = UserRef, ReceiveNotifications = true
            };
        }
示例#2
0
        public void ThenUserRefMustBeSupplied()
        {
            //Arrange
            var command = new UpdateUserNotificationSettingsCommand
            {
                Settings = new List <UserNotificationSetting>()
            };

            //Act
            var result = _validator.Validate(command);

            //Assert
            Assert.IsFalse(result.IsValid());
            Assert.IsTrue(result.ValidationDictionary.ContainsKey(nameof(command.UserRef)));
        }
示例#3
0
        public async Task ThenTheCommandIsValidated()
        {
            //Arrange
            var command = new UpdateUserNotificationSettingsCommand
            {
                UserRef  = "REF",
                Settings = new List <UserNotificationSetting>()
            };

            //Act
            await _handler.Handle(command);

            //Assert
            _validator.Verify(x => x.Validate(It.IsAny <UpdateUserNotificationSettingsCommand>()), Times.Once);
        }
示例#4
0
        public async Task ThenTheRepositoryIsCalledToUpdateSettings()
        {
            //Arrange
            var command = new UpdateUserNotificationSettingsCommand
            {
                UserRef  = "REF",
                Settings = new List <UserNotificationSetting>()
            };

            //Act
            await _handler.Handle(command);

            //Assert
            _repository.Verify(x => x.UpdateUserAccountSettings(
                                   It.Is <string>(s => s == "REF"),
                                   It.IsAny <List <UserNotificationSetting> >()
                                   ), Times.Once);
        }