public void Arrange() { _request = new GetPeriodsQueryRequest(); _periodEntity1 = new PeriodEntity { Period = 12, AcademicYear = 1671, ReferenceDataValidationDate = new DateTime(2017, 8, 31), CompletionDate = new DateTime(2017, 9, 5, 19, 27, 34) }; _periodEntity2 = new PeriodEntity { //Id = "1718-R01", Period = 1, AcademicYear = 1718, ReferenceDataValidationDate = new DateTime(2017, 10, 2), CompletionDate = new DateTime(2017, 10, 4, 23, 34, 10) }; _periodRepository = new Mock <IPeriodRepository>(); _periodRepository.Setup(r => r.GetPeriods()) .Returns(Task.FromResult(new[] { _periodEntity1, _periodEntity2 })); _mapper = new AutoMapperMapper(AutoMapperConfigurationFactory.CreateMappingConfig()); _handler = new Application.Period.GetPeriodsQuery.GetPeriodsQueryHandler(_periodRepository.Object, _mapper); }
public void Arrange() { _request = new GetPeriodsQueryRequest(); _periodEntity1 = new PeriodEntity { Id = "1617-R12", CalendarMonth = 8, CalendarYear = 2017, AccountDataValidAt = new DateTime(2017, 8, 31), CommitmentDataValidAt = new DateTime(2017, 9, 1), CompletionDateTime = new DateTime(2017, 9, 5, 19, 27, 34) }; _periodEntity2 = new PeriodEntity { Id = "1718-R01", CalendarMonth = 9, CalendarYear = 2017, AccountDataValidAt = new DateTime(2017, 10, 2), CommitmentDataValidAt = new DateTime(2017, 9, 30), CompletionDateTime = new DateTime(2017, 10, 4, 23, 34, 10) }; _periodRepository = new Mock <IPeriodRepository>(); _periodRepository.Setup(r => r.GetPeriods()) .Returns(Task.FromResult(new[] { _periodEntity1, _periodEntity2 })); _mapper = new Mock <IMapper>(); _mapper.Setup(m => m.Map <Data.Period[]>(It.IsAny <PeriodEntity[]>())) .Returns((PeriodEntity[] source) => { return(source.Select(e => new Data.Period { Id = e.Id, CalendarMonth = e.CalendarMonth, CalendarYear = e.CalendarYear, AccountDataValidAt = e.AccountDataValidAt, CommitmentDataValidAt = e.CommitmentDataValidAt, CompletionDateTime = e.CompletionDateTime }).ToArray()); }); _handler = new Application.Period.GetPeriodsQuery.GetPeriodsQueryHandler(_periodRepository.Object, _mapper.Object); }