Example #1
0
        public async Task ThenWillSendRequestToApi()
        {
            //arrange
            var expectedId       = "123";
            var expectedRuleId   = 2567;
            var expectedRuleType = RuleType.GlobalRule;

            //act
            await _service.MarkRuleAsRead(expectedId, expectedRuleId, expectedRuleType);

            //assign
            _apiClient.Verify(c => c.Create <MarkRuleAsReadApiResponse>(It.Is <MarkRuleAsReadApiRequest>(
                                                                            r => r.Id.Equals(expectedId) &&
                                                                            r.RuleId.Equals(expectedRuleId) &&
                                                                            r.TypeOfRule.Equals(expectedRuleType))), Times.Once);
        }
Example #2
0
        public async Task <Unit> Handle(MarkRuleAsReadCommand command, CancellationToken cancellationToken)
        {
            var validationResult = await _validator.ValidateAsync(command);

            if (!validationResult.IsValid())
            {
                throw new ValidationException(validationResult.ConvertToDataAnnotationsValidationResult(), null, null);
            }

            await _service.MarkRuleAsRead(command.Id, command.RuleId, command.TypeOfRule);

            return(Unit.Value);
        }