Пример #1
0
        public async Task CreateAvailabilityRecordCommandHandler_Handle_AvailabilityRecordCreated()
        {
            var accountId = Guid.NewGuid();

            var claimsIdentity = new ClaimsIdentity();

            claimsIdentity.AddClaim(new Claim(ClaimTypes.NameIdentifier, accountId.ToString()));
            var claimsPrincipal = new ClaimsPrincipal();

            claimsPrincipal.AddIdentity(claimsIdentity);

            var createAvailabilityRecordCommandHandler = new CreateAvailabilityRecordCommandHandler(_availabilityRecordRepository,
                                                                                                    _claimConverter);

            await createAvailabilityRecordCommandHandler.Handle(new CreateAvailabilityRecordCommand(claimsPrincipal,
                                                                                                    "test name",
                                                                                                    "http://google.com/",
                                                                                                    200,
                                                                                                    "{}",
                                                                                                    12), CancellationToken.None).ConfigureAwait(false);

            var records = await _availabilityRecordRepository.GetByAccountId(accountId, CancellationToken.None)
                          .ConfigureAwait(false);

            Assert.Single(records);
            Assert.Equal(accountId, records.First().AccountId);
            Assert.Equal("test name", records.First().Name);
            Assert.Equal("http://google.com/", records.First().Url);
            Assert.Equal(200, records.First().ExpectedStatusCode);
            Assert.Equal("{}", records.First().ExpectedResponse);
            Assert.Equal(12, records.First().LogLifetimeThresholdInHours);
        }
Пример #2
0
        public async Task <List <AvailabilityListItemDto> > Handle(GetAvailabilityListItemsCommand request, CancellationToken cancellationToken)
        {
            var accountId = _claimConverter.GetAccountId(request.ClaimsPrincipal);

            var availabilityRecords = await _availabilityRecordRepository.GetByAccountId(accountId, cancellationToken);

            return(availabilityRecords.Select(_mapper.Map <AvailabilityListItemDto>).ToList());
        }