Beispiel #1
0
        public void SmsDaoTest_ApplyOutBoundCacheRuleAsync_StopRequestExistInCache()
        {
            //Arrange
            var sms = new Sms {
                Text = "STOP\r\n123"
            };

            _mockSmsCacheProvider.Setup(x => x.KeyExistsAsync(It.IsAny <string>())).ReturnsAsync(true);

            //Act
            Func <Task> fun = async() => await _smsDao.ApplyOutBoundCacheRuleAsync(sms);

            //Assert
            fun.Should().Throw <SmsOutBoundException>().WithMessage($"Sms from '{sms.From}' to '{sms.To}' is blocked by STOP request.");
        }
Beispiel #2
0
        public async Task <CommandResult> Handle(OutBoundSmsCommand command, CancellationToken cancellationToken)
        {
            // Validate the command
            var commandResult = new CommandResult {
                ValidationResult = await _validator.ValidateAsync(command, cancellationToken)
            };

            if (!commandResult.IsValid)
            {
                return(commandResult);
            }

            //Apply rules
            var sms = new Sms();

            sms.Update(command);
            await _smsDao.ApplyOutBoundCacheRuleAsync(sms);

            return(commandResult);
        }