public int CreatePaymentBatch(string batchName, DateTime setupDateTime, decimal batchTotalAmount, int itemCount, int batchEntryType, int?depositId, DateTime finalizedDateTime, string processorTransferId) { var apiToken = _apiUserRepository.GetToken(); var batchRecord = new MpBatch { BatchName = batchName, SetupDate = setupDateTime, BatchTotal = batchTotalAmount, ItemCount = itemCount, BatchEntryTypeId = batchEntryType, DepositId = depositId, FinalizeDate = finalizedDateTime, ProcessorTransferId = processorTransferId }; try { var batchId = _ministryPlatformRest.UsingAuthenticationToken(apiToken).PostWithReturn <MpBatch, MpBatch>(new List <MpBatch>() { batchRecord }).FirstOrDefault().BatchId; return(batchId); } catch (Exception e) { throw new ApplicationException($"CreatPaymentBatch failed. batchName: {batchName}, setupDateTime: {setupDateTime}, batchTotalAmount: {batchTotalAmount}, itemCount: {itemCount}, batchEntryType: {batchEntryType}, depositId: {depositId}, finalizedDateTime: {finalizedDateTime}", e); } }
public void CreatePaymentBatchShouldThrow() { const string batchName = "name"; var setupDate = DateTime.Now; var batchRecord = new MpBatch { BatchName = batchName, SetupDate = setupDate, BatchTotal = (decimal)123.45, ItemCount = 2, BatchEntryTypeId = 1, DepositId = 777, FinalizeDate = setupDate, ProcessorTransferId = "philiscool" }; _ministryPlatformRest.Setup(p => p.PostWithReturn <MpBatch, MpBatch>(new List <MpBatch>() { batchRecord })).Returns(new List <MpBatch>()); Assert.Throws <ApplicationException>(() => _fixture.CreatePaymentBatch(batchName, setupDate, (decimal)123.45, 2, 1, 777, DateTime.Now, "philiscool")); }