public void IsReserveWithNonZeroMovementsPresentTest()
 {
     List<XiapClaim.ClaimTransactionDetail> ctds = new List<XiapClaim.ClaimTransactionDetail>();
     XiapClaim.ClaimTransactionDetail ctd1 = new XiapClaim.ClaimTransactionDetail() { AmountType = (short)StaticValues.AmountType.Payment, TransactionAmountOriginal = 0, MovementType = "A" };
     ctds.Add(ctd1);
     XiapClaim.ClaimTransactionDetail ctd2 = new XiapClaim.ClaimTransactionDetail() { AmountType = (short)StaticValues.AmountType.Reserve, MovementAmountOriginal = 1, MovementType = "B" };
     ctds.Add(ctd2);
     Assert.AreEqual(true, ClaimTransferDataTransform.IsReserveWithNonZeroMovementsPresent(ctds));
 }
		public void GetFirstNonFundedTransactionDetail_MisMatchedReceiptAndReserve_FirstReceiptAndReserveCTDReturned()
		{
			List<XiapClaim.ClaimTransactionDetail> ctdList = new List<XiapClaim.ClaimTransactionDetail>();

			XiapClaim.ClaimTransactionDetail ctd1 = new XiapClaim.ClaimTransactionDetail();
			ctd1.AmountType = (short)StaticValues.AmountType.Payment;
			ctd1.MovementType = "1";

			XiapClaim.ClaimTransactionDetail ctd2 = new XiapClaim.ClaimTransactionDetail();
			ctd2.AmountType = (short)StaticValues.AmountType.RecoveryReceipt;
			ctd2.MovementType = "A";

			XiapClaim.ClaimTransactionDetail ctd3 = new XiapClaim.ClaimTransactionDetail();
			ctd3.AmountType = (short)StaticValues.AmountType.RecoveryReserve;
			ctd3.MovementType = "X";

			ctdList.Add(ctd1);
			ctdList.Add(ctd2);
			ctdList.Add(ctd3);

			List<XiapClaim.ClaimTransactionDetail> results = ClaimTransferDataTransform.GetFirstNonFundedTransactionDetail(ctdList, (short)StaticValues.ClaimTransactionSource.RecoveryReceipt, 10, 20, 30, 40);

			Assert.AreEqual(2, results.Count);

			XiapClaim.ClaimTransactionDetail ctdResult = results.Where(a => a.AmountType == (short)StaticValues.AmountType.RecoveryReceipt).First();
			Assert.AreEqual(10, ctdResult.CalculationSourceAmountOriginal);
			Assert.AreEqual(10, ctdResult.TransactionAmountOriginal);
			Assert.AreEqual(30, ctdResult.MovementAmountOriginal);
			Assert.AreEqual("A", ctdResult.MovementType);

			ctdResult = results.Where(a => a.AmountType == (short)StaticValues.AmountType.RecoveryReserve).First();
			Assert.AreEqual(20, ctdResult.CalculationSourceAmountOriginal);
			Assert.AreEqual(20, ctdResult.TransactionAmountOriginal);
			Assert.AreEqual(40, ctdResult.MovementAmountOriginal);
			Assert.AreEqual("X", ctdResult.MovementType);
		}
		public void ExtractDeductibleTransactions_MultipleDeductibleCTDOneCTGDeductibleOneNoCTG_DeductibleReturned()
		{
			Dictionary<string, string> fundedDeductibles = new Dictionary<string, string>();
			fundedDeductibles.Add("A", "Deductible01");
			fundedDeductibles.Add("B", "Deductible02");

			Dictionary<string, string> fundedDeductiblePolicies = new Dictionary<string, string>();
			fundedDeductiblePolicies.Add("Deductible01", "Policy1");
			fundedDeductiblePolicies.Add("Deductible02", "Policy2");

			string XmlClaim = @"<?xml version='1.0' encoding='utf-16'?>
								<ClaimHeader xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'
								xmlns='http://www.xchanging.com/Xiap/Claims/Data/XML/2011/9'>
								<ClaimTransactionHeaders>
								 </ClaimTransactionHeaders>
								</ClaimHeader>";

			XmlDocument document = new XmlDocument();
			XmlElement xmlNode = null;

			xmlNode = document.CreateElement("Claims");
			XmlDocument doc = new XmlDocument();
			doc.LoadXml(XmlClaim);
			XmlNode newNode = document.ImportNode(doc.DocumentElement, true);
			xmlNode.AppendChild(newNode);

			XiapClaim.ClaimTransactionHeader cth = new XiapClaim.ClaimTransactionHeader();
			List<XiapClaim.ClaimTransactionGroup> ctgs = new List<XiapClaim.ClaimTransactionGroup>();

			XiapClaim.ClaimTransactionGroup ctg1 = new XiapClaim.ClaimTransactionGroup();
			ctg1.ClaimTransactionGroupID = 1;
			ctgs.Add(ctg1);

			List<XiapClaim.ClaimTransactionDetail> ctds1 = new List<XiapClaim.ClaimTransactionDetail>();

			XiapClaim.ClaimTransactionDetail ctd2 = new XiapClaim.ClaimTransactionDetail();
			ctd2.ClaimTransactionDetailID = 2;
			ctd2.MovementType = "B";
			ctds1.Add(ctd2);

			XiapClaim.ClaimTransactionDetail ctd4 = new XiapClaim.ClaimTransactionDetail();
			ctd4.ClaimTransactionDetailID = 4;
			ctd4.MovementType = "C";
			ctds1.Add(ctd4);

			ctg1.ClaimTransactionDetails = ctds1.ToArray();

			XiapClaim.ClaimTransactionGroup ctg2 = new XiapClaim.ClaimTransactionGroup();
			ctg2.ClaimTransactionGroupID = 2;
			ctgs.Add(ctg2);

			List<XiapClaim.ClaimTransactionDetail> ctds2 = new List<XiapClaim.ClaimTransactionDetail>();

			XiapClaim.ClaimTransactionDetail ctd6 = new XiapClaim.ClaimTransactionDetail();
			ctd6.ClaimTransactionDetailID = 5;
			ctd6.MovementType = "B";
			ctds2.Add(ctd6);

			ctg2.ClaimTransactionDetails = ctds2.ToArray();

			cth.ClaimTransactionGroups = ctgs.ToArray();

            XmlNode deductibles = ClaimTransferDataTransform.ExtractDeductibleTransactions(cth, fundedDeductibles, fundedDeductiblePolicies, liabClaimProduct, -1);

			Assert.IsNotNull(deductibles);

			XmlNamespaceManager nsmgr = new XmlNamespaceManager(document.NameTable);
			nsmgr.AddNamespace("XIAP", "http://www.xchanging.com/Xiap/Claims/Data/XML/2011/9");

			XmlNode subNode = deductibles.SelectSingleNode("Deductible01");
			Assert.IsNotNull(subNode);
			XmlAttribute attribute = subNode.Attributes["PolicyReference"];
			Assert.AreEqual("Policy1", attribute.Value);

			XmlNodeList details = subNode.SelectNodes("descendant::XIAP:ClaimTransactionDetail", nsmgr);
			Assert.AreEqual(0, details.Count);

			subNode = deductibles.SelectSingleNode("Deductible02");
			Assert.IsNotNull(subNode);
			attribute = subNode.Attributes["PolicyReference"];
			Assert.AreEqual("Policy2", attribute.Value);

			details = subNode.SelectNodes("descendant::XIAP:ClaimTransactionDetail", nsmgr);
			Assert.AreEqual(2, details.Count);

			foreach (XmlNode detail in details)
			{
				XmlNode temp = detail.SelectSingleNode("XIAP:MovementType", nsmgr);
				Assert.IsNotNull(temp);
				Assert.AreEqual("B", temp.InnerText);
			}
		}
		public void GetFirstNonFundedTransactionDetail_ReserveOnly_FirstReserveCTDReturned()
		{
			List<XiapClaim.ClaimTransactionDetail> ctdList = new List<XiapClaim.ClaimTransactionDetail>();

			XiapClaim.ClaimTransactionDetail ctd1 = new XiapClaim.ClaimTransactionDetail();
			ctd1.AmountType = (short)StaticValues.AmountType.RecoveryReserve;
			ctd1.MovementType = "X";
			
			ctdList.Add(ctd1);

			List<XiapClaim.ClaimTransactionDetail> results = ClaimTransferDataTransform.GetFirstNonFundedTransactionDetail(ctdList, (short)StaticValues.ClaimTransactionSource.RecoveryReceipt, 10, 20, 30, 40);

			Assert.AreEqual(1, results.Count);
			XiapClaim.ClaimTransactionDetail ctdResult = results.First();
			Assert.AreEqual(20, ctdResult.CalculationSourceAmountOriginal);
			Assert.AreEqual(20, ctdResult.TransactionAmountOriginal);
			Assert.AreEqual(40, ctdResult.MovementAmountOriginal);
			Assert.AreEqual("X", ctdResult.MovementType);
		}