public void Arrange() { _mediator = new Mock <IMediator>(); _logger = new Mock <ILogger>(); _logger.Setup(l => l.Error(It.IsAny <Exception>(), It.IsAny <string>(), It.IsAny <object[]>())) .Callback <Exception, string, object[]>((ex, msg, args) => { Console.WriteLine($"Error Logged\n{msg}\n{ex}"); }); _controller = new Api.Controllers.PaymentsController(_mediator.Object, _logger.Object); }
public void Arrange() { _payment1 = new Payment { Id = Guid.NewGuid().ToString(), Ukprn = 123456, Uln = 987654, EmployerAccountId = EmployerAccountId, ApprenticeshipId = 147852, CollectionPeriod = new NamedCalendarPeriod { Id = "1718-R02", Month = 9, Year = 2017 }, DeliveryPeriod = new CalendarPeriod { Month = 8, Year = 2017 }, EvidenceSubmittedOn = DateTime.Today, EmployerAccountVersion = "20170601", ApprenticeshipVersion = "V1", FundingSource = FundingSource.Levy, FundingAccountId = 666, TransactionType = TransactionType.Learning, Amount = 1234.56m, StandardCode = 25, ContractType = ContractType.ContractWithEmployer }; _period = new Period { Id = PeriodId, CalendarMonth = 9, CalendarYear = 2017 }; _mediator = new Mock <IMediator>(); _mediator.Setup(m => m.SendAsync(It.Is <GetPeriodQueryRequest>(r => r.PeriodId == PeriodId))) .ReturnsAsync(new GetPeriodQueryResponse { IsValid = true, Result = _period }); _mediator.Setup(m => m.SendAsync(It.Is <GetPaymentsQueryRequest>(r => r.Period == _period && r.EmployerAccountId == EmployerAccountId && r.PageNumber == Page && r.PageSize == PageSize && r.Ukprn == Ukprn))) .ReturnsAsync(new GetPaymentsQueryResponse { IsValid = true, Result = new PageOfResults <Payment> { PageNumber = Page, TotalNumberOfPages = TotalNumberOfPages, Items = new[] { _payment1 } } }); _logger = new Mock <ILogger>(); _logger.Setup(l => l.Error(It.IsAny <Exception>(), It.IsAny <string>(), It.IsAny <object[]>())) .Callback <Exception, string, object[]>((ex, msg, args) => { Console.WriteLine($"Error Logged\n{msg}\n{ex}"); }); _controller = new Api.Controllers.PaymentsController(_mediator.Object, _logger.Object); }