Esempio n. 1
0
        public void Arrange()
        {
            _request = new GetSubmissionEventsQueryRequest
            {
                PageNumber   = 0,
                SinceEventId = 1,
                SinceTime    = DateTime.Now
            };

            _pageNumberMustBeAtLeastOneRule = new Mock <PageNumberMustBeAtLeastOneRule>();
            _pageNumberMustBeAtLeastOneRule.Setup(r => r.Validate(It.IsAny <int>()))
            .ReturnsAsync(PageNumberMessage);

            _validator = new Application.Submissions.GetSubmissionEventsQuery.GetSubmissionEventsQueryRequestValidator(_pageNumberMustBeAtLeastOneRule.Object);
        }
Esempio n. 2
0
        public async Task AndNoRulesFailThenItShouldReturnAValidResponse()
        {
            // Arrange
            _pageNumberMustBeAtLeastOneRule.Setup(r => r.Validate(It.IsAny <int>()))
            .ReturnsAsync(null);
            _request = new GetSubmissionEventsQueryRequest
            {
                PageNumber = 1
            };

            // Act
            var actual = await _validator.Validate(_request);

            // Assert
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.IsValid);
        }
Esempio n. 3
0
        public void Arrange()
        {
            _validator = new Mock <IValidator <GetSubmissionEventsQueryRequest> >(); _validator.Setup(v => v.Validate(It.IsAny <GetSubmissionEventsQueryRequest>()))
            .ReturnsAsync(new ValidationResult());

            _submissionEventsRepository = new Mock <ISubmissionEventsRepository>();
            _submissionEventsRepository
            .Setup(r => r.GetSubmissionEventsSinceId(It.IsAny <long>(), It.IsAny <int>(), It.IsAny <int>()))
            .ReturnsAsync(new PageOfResults <SubmissionEventEntity>
            {
                PageNumber         = 1,
                TotalNumberOfPages = 2,
                Items = new[]
                {
                    new SubmissionEventEntity {
                        Id = 1
                    }
                }
            });
            _submissionEventsRepository
            .Setup(r => r.GetSubmissionEventsSinceTime(It.IsAny <DateTime>(), It.IsAny <int>(), It.IsAny <int>()))
            .ReturnsAsync(new PageOfResults <SubmissionEventEntity>
            {
                PageNumber         = 2,
                TotalNumberOfPages = 3,
                Items = new[]
                {
                    new SubmissionEventEntity {
                        Id = 2
                    }
                }
            });
            _submissionEventsRepository
            .Setup(r => r.GetSubmissionEventsForProviderSinceId(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <int>(), It.IsAny <int>()))
            .ReturnsAsync(new PageOfResults <SubmissionEventEntity>
            {
                PageNumber         = 3,
                TotalNumberOfPages = 4,
                Items = new[]
                {
                    new SubmissionEventEntity {
                        Id = 3
                    }
                }
            });
            _submissionEventsRepository
            .Setup(r => r.GetSubmissionEventsForProviderSinceTime(It.IsAny <long>(), It.IsAny <DateTime>(), It.IsAny <int>(), It.IsAny <int>()))
            .ReturnsAsync(new PageOfResults <SubmissionEventEntity>
            {
                PageNumber         = 4,
                TotalNumberOfPages = 5,
                Items = new[]
                {
                    new SubmissionEventEntity {
                        Id = 4
                    }
                }
            });

            _mapper = new Mock <IMapper>();
            _mapper.Setup(m => m.Map <PageOfResults <SubmissionEvent> >(It.IsAny <PageOfResults <SubmissionEventEntity> >()))
            .Returns((PageOfResults <SubmissionEventEntity> source) =>
            {
                return(new PageOfResults <SubmissionEvent>
                {
                    PageNumber = source.PageNumber,
                    TotalNumberOfPages = source.TotalNumberOfPages,
                    Items = source.Items.Select(e => new SubmissionEvent
                    {
                        Id = e.Id
                    }).ToArray()
                });
            });

            _handler = new Application.Submissions.GetSubmissionEventsQuery.GetSubmissionEventsQueryHandler(_validator.Object, _submissionEventsRepository.Object, _mapper.Object);

            _request = new GetSubmissionEventsQueryRequest();
        }