public void GetEventCustomerByIdReturnsEventCustomerAggregateForKnownEventCustomer() { const long knownCustomerId = 12879; EventCustomerAggregate eventCustomerAggregate = _eventCustomerAggregateRepository.GetEventCustomerById(knownCustomerId); Assert.IsNotNull(eventCustomerAggregate); }
public void GetEventCustomerByIdReturnsNullForUnknownEventCustomerId() { const long unknownCustomerId = 0; EventCustomerAggregate eventCustomerAggregate = _eventCustomerAggregateRepository.GetEventCustomerById(unknownCustomerId); Assert.IsNull(eventCustomerAggregate); }
public List <EventCustomerAggregate> CreateAggregatesFromTypedViewCollection (CustomerEventBasicInfoTypedView customerEventBasicInfoTypedView) { if (customerEventBasicInfoTypedView == null) { throw new ArgumentNullException("customerEventBasicInfoTypedView", "CustomerEventBasicInfoTypedView given cannot be null."); } var eventCustomers = new List <EventCustomerAggregate>(); if (customerEventBasicInfoTypedView.Count == 0) { return(eventCustomers); } var currentEventCustomerId = customerEventBasicInfoTypedView.First().EventCustomerId; var eventCustomersByEventCustomerId = new List <CustomerEventBasicInfoRow>(); foreach (var customerEventInfo in (customerEventBasicInfoTypedView.OrderBy(c => c.EventCustomerId))) { if (customerEventInfo.EventCustomerId != currentEventCustomerId) { eventCustomersByEventCustomerId.Clear(); currentEventCustomerId = customerEventInfo.EventCustomerId; } if (!customerEventInfo.IsPodActive) { continue; } bool skip = false; foreach (var customerEventBasicInfoRow in eventCustomersByEventCustomerId) { if (customerEventInfo.EventName == customerEventBasicInfoRow.EventName && customerEventInfo.DrOrCr == customerEventBasicInfoRow.DrOrCr && customerEventInfo.PaymentTotalAmount == customerEventBasicInfoRow.PaymentTotalAmount) { skip = true; break; } } if (skip) { continue; } eventCustomersByEventCustomerId.Add(customerEventInfo); EventCustomerAggregate eventCustomer = GetEventCustomerAggregateFromTypedViewRow(customerEventInfo); var customerInfoForEventCustomerId = eventCustomers.Where(e => e.EventCustomerId == eventCustomer.EventCustomerId); int multiplier = customerEventInfo.DrOrCr ? -1 : 1; if (customerInfoForEventCustomerId.Count() > 0) { customerInfoForEventCustomerId.Single().PaymentAmount += eventCustomer.PaymentAmount * multiplier; continue; } eventCustomer.PaymentAmount *= multiplier; eventCustomers.Add(eventCustomer); } return(eventCustomers); }