示例#1
0
        public async Task <IActionResult> CreateEvent(Guid contactId, InvoiceItem invoiceItem)
        {
            var contact = MockContacts.GetMockContacts().FirstOrDefault(x => x.Id == contactId);

            if (contact == null)
            {
                return(NotFound($"ContactId {contactId} not found"));
            }

            var eventData = await _facebookService.CreateFacebookEvent(contact, invoiceItem);

            return(Ok(new
            {
                NrOfEvents = eventData.events_received,
                FbTraceId = eventData.fbtrace_id
            }));
        }
        public Mock <PaymentPlanProcessor> CreateMockModelForQueue()
        {
            ProcessCalled = new List <int>();
            var mockModel = new Mock <PaymentPlanProcessor>(MockProcessor.Object, MockContacts.Object, MockPlans.Object, new RandomGenerator(), Config)
            {
                CallBase = true
            };

            mockModel.Setup(x => x.ProcessAsync(It.IsAny <ApiCustomContact>(), It.IsAny <IEnumerable <ApiPaymentPlan> >(), It.IsAny <DateTimeOffset>()))
            .Returns <ApiCustomContact, IEnumerable <ApiPaymentPlan>, DateTimeOffset>((contact, planList, currentDate) =>
            {
                ProcessCalled.Add(contact.Id !.Value);
                return(Task.FromResult(new PaymentResult()));
            });
            MockContacts.Setup(x => x.SelectAsync(It.IsAny <int>()))
            .Returns <int>((id) => Task.FromResult(new ApiCustomContact()
            {
                Id = id
            }));
            MockPlans.Setup(x => x.SelectAsync(It.IsAny <ApiSearchOptions>()))
            .Returns(Task.FromResult <IList <ApiPaymentPlan> >(new List <ApiPaymentPlan>()));
            return(mockModel);
        }