Example #1
0
        private void TraceMismatch(OnProgrammeEarning[] expectedPaymentsEvents, CalculatedRequiredCoInvestedAmount[] receivedEvents)
        {
            for (var i = 0; i < expectedPaymentsEvents.Length; i++)
            {
                var expectedEvent = expectedPaymentsEvents[i];
                for (var k = 0; k < receivedEvents.Length; k++)
                {
                    var receivedEvent    = receivedEvents[k];
                    var mismatchedFields = new List <string>();
                    var learnerReference = TestSession.GenerateLearnerReference(expectedEvent.LearnerId);

                    if (expectedEvent.Amount != receivedEvent.AmountDue)
                    {
                        mismatchedFields.Add($" Amount({expectedEvent.Amount}!={receivedEvent.AmountDue})");
                    }
                    if (learnerReference != receivedEvent.Learner?.ReferenceNumber)
                    {
                        mismatchedFields.Add($"LearnRefNumber({learnerReference}!={receivedEvent.Learner?.ReferenceNumber})");
                    }
                    if (expectedEvent.Type != receivedEvent.OnProgrammeEarningType)
                    {
                        mismatchedFields.Add($"Type({expectedEvent.Type}!={receivedEvent.OnProgrammeEarningType})");
                    }
                    if (expectedEvent.DeliveryPeriod != receivedEvent.DeliveryPeriod)
                    {
                        mismatchedFields.Add($"Period({expectedEvent.DeliveryPeriod}!={receivedEvent.DeliveryPeriod})");
                    }
                    if (receivedEvent.CollectionPeriod.AcademicYear != AcademicYear)
                    {
                        mismatchedFields.Add($"CollectionPeriod({receivedEvent.CollectionPeriod.AcademicYear} does not contain {AcademicYear})");
                    }

                    if (mismatchedFields.Count == 0)
                    {
                        Debug.WriteLine($"Event {i + 1} of {expectedPaymentsEvents.Length}: match {k + 1}");
                    }
                    else
                    {
                        Debug.WriteLine($"Event {i + 1} of {expectedPaymentsEvents.Length}: mismatch {k + 1} on {string.Join(",", mismatchedFields)}");
                    }
                }
            }
        }