Beispiel #1
0
        public void Arrange()
        {
            _mediator = new Mock <IMediator>();
            _mediator.Setup(m => m.SendAsync(It.IsAny <GetDataLockEventsQueryRequest>()))
            .ReturnsAsync(new GetDataLockEventsQueryResponse
            {
                IsValid = true,
                Result  = new PageOfResults <DataLockEvent>
                {
                    PageNumber         = 1,
                    TotalNumberOfPages = 10,
                    Items = new[]
                    {
                        CreateDomainDataLockEvent(),
                        CreateDomainDataLockEvent(EventStatus.Removed)
                    }
                }
            });

            _mapper = new Mock <IMapper>();
            _mapper.Setup(m => m.Map <PageOfResults <DataLockEvent> >(It.IsAny <PageOfResults <DataLockEvent> >()))
            .Returns((PageOfResults <DataLockEvent> source) => CreateV2Event(source));

            _mapper.Setup(m => m.Map <DataLockEventV1[]>(It.IsAny <DataLockEvent[]>()))
            .Returns((DataLockEvent[] source) => CreateV1Event(source));

            _logger = new Mock <ILogger>();

            _controller = new Api.Controllers.DataLockController(_mediator.Object, _mapper.Object, _logger.Object);
        }
        public void Arrange()
        {
            _mediator = new Mock <IMediator>();
            _mediator.Setup(m => m.SendAsync(It.IsAny <GetDataLockEventsQueryRequest>()))
            .ReturnsAsync(new GetDataLockEventsQueryResponse
            {
                IsValid = true,
                Result  = new PageOfResults <DataLockEvent>
                {
                    PageNumber         = 1,
                    TotalNumberOfPages = 10,
                    Items = new[]
                    {
                        new DataLockEvent
                        {
                            Id     = 123,
                            Errors = new []
                            {
                                new DataLockEventError
                                {
                                    ErrorCode         = "Err1",
                                    SystemDescription = "Error 1"
                                }
                            },
                            Periods = new []
                            {
                                new DataLockEventPeriod
                                {
                                    ApprenticeshipVersion = "1-015",
                                    Period = new NamedCalendarPeriod
                                    {
                                        Id    = "1617-R09",
                                        Month = 4,
                                        Year  = 2017
                                    },
                                    IsPayable       = true,
                                    TransactionType = TransactionType.Learning
                                }
                            },
                            Apprenticeships = new []
                            {
                                new DataLockEventApprenticeship
                                {
                                    Version         = "19",
                                    StartDate       = new DateTime(2017, 5, 1),
                                    StandardCode    = 27,
                                    NegotiatedPrice = 17500m,
                                    EffectiveDate   = new DateTime(2017, 5, 1)
                                }
                            }
                        }
                    }
                }
            });

            _mapper = new Mock <IMapper>();
            _mapper.Setup(m => m.Map <PageOfResults <DataLockEvent> >(It.IsAny <PageOfResults <DataLockEvent> >()))
            .Returns((PageOfResults <DataLockEvent> source) =>
            {
                return(new PageOfResults <DataLockEvent>
                {
                    PageNumber = source.PageNumber,
                    TotalNumberOfPages = source.TotalNumberOfPages,
                    Items = source.Items.Select(e => new DataLockEvent
                    {
                        Id = e.Id,
                        Errors = new []
                        {
                            new DataLockEventError
                            {
                                ErrorCode = e.Errors[0].ErrorCode,
                                SystemDescription = e.Errors[0].SystemDescription
                            }
                        },
                        Periods = new []
                        {
                            new DataLockEventPeriod
                            {
                                ApprenticeshipVersion = e.Periods[0].ApprenticeshipVersion,
                                Period = new NamedCalendarPeriod
                                {
                                    Id = e.Periods[0].Period.Id,
                                    Month = e.Periods[0].Period.Month,
                                    Year = e.Periods[0].Period.Year
                                },
                                IsPayable = e.Periods[0].IsPayable
                            }
                        },
                        Apprenticeships = new []
                        {
                            new DataLockEventApprenticeship
                            {
                                Version = e.Apprenticeships[0].Version,
                                StartDate = e.Apprenticeships[0].StartDate,
                                StandardCode = e.Apprenticeships[0].StandardCode,
                                ProgrammeType = e.Apprenticeships[0].ProgrammeType,
                                FrameworkCode = e.Apprenticeships[0].FrameworkCode,
                                PathwayCode = e.Apprenticeships[0].PathwayCode,
                                NegotiatedPrice = e.Apprenticeships[0].NegotiatedPrice,
                                EffectiveDate = e.Apprenticeships[0].EffectiveDate
                            }
                        }
                    }).ToArray()
                });
            });

            _logger = new Mock <ILogger>();

            _controller = new Api.Controllers.DataLockController(_mediator.Object, _mapper.Object, _logger.Object);
        }