public void WhenPendingPaymentMessageWithMECodeRecipientUriProcessedWithKnownRecipientTwoTransactionsAreCreated() { Guid messageId = Guid.NewGuid(); Guid apiKey = Guid.NewGuid(); Guid senderId = Guid.NewGuid(); Guid senderAccountId = Guid.NewGuid(); _ctx = new FakeDbContext(); var application = _ctx.Applications.Add(new Domain.Application() { ApiKey = apiKey, ApplicationName = "Test App", IsActive = true, Url = "http:\\test.paidthx.com" }); var sender = _ctx.Users.Add(new Domain.User() { Application = application, ApiKey = apiKey, CreateDate = System.DateTime.Now, EmailAddress = "*****@*****.**", Limit = 100, MobileNumber = "8043550001", Password = "******", PaymentAccounts = new System.Collections.ObjectModel.Collection <Domain.PaymentAccount>(), IsConfirmed = true, SecurityPin = "1234", SetupPassword = true, SetupSecurityPin = true, UserStatus = Domain.UserStatus.Verified }); var recipient = _ctx.Users.Add(new Domain.User() { Application = application, ApiKey = apiKey, CreateDate = System.DateTime.Now, EmailAddress = "*****@*****.**", Limit = 100, MobileNumber = "7082504915", Password = "******", PaymentAccounts = new System.Collections.ObjectModel.Collection <Domain.PaymentAccount>(), IsConfirmed = true, SecurityPin = "1234", SetupPassword = true, SetupSecurityPin = true, UserStatus = Domain.UserStatus.Verified, DeviceToken = "6b0bf548627aecffe1a87b3febf62c9f6eda50c35b6acce067a21b365dcc94b4", MECodes = new System.Collections.ObjectModel.Collection <Domain.MECode>() }); _ctx.SaveChanges(); var senderAccount = new Domain.PaymentAccount() { AccountNumber = "1234123412", AccountType = Domain.PaymentAccountType.Checking, IsActive = true, CreateDate = System.DateTime.Now, Id = senderAccountId, NameOnAccount = "James Rhodes", RoutingNumber = "053000219", }; var recipientAccount = new Domain.PaymentAccount() { AccountNumber = "1010202030", AccountType = Domain.PaymentAccountType.Savings, IsActive = true, CreateDate = System.DateTime.Now, Id = senderAccountId, NameOnAccount = "James Rhodes", RoutingNumber = "053000211", }; sender.PaymentAccounts.Add(senderAccount); recipient.PaymentAccounts.Add(recipientAccount); var meCode = new Domain.MECode() { ApprovedDate = System.DateTime.Now, CreateDate = System.DateTime.Now, Id = Guid.NewGuid(), IsActive = true, IsApproved = true, LastUpdatedDate = System.DateTime.Now, MeCode = "$jrhodes", User = recipient }; _ctx.MECodes.Add(meCode); recipient.MECodes.Add(meCode); _ctx.SaveChanges(); var message = _ctx.Messages.Add(new Domain.Message() { Amount = 1, Application = application, ApiKey = apiKey, Comments = "Test Payment", CreateDate = System.DateTime.Now, Id = messageId, MessageStatus = Domain.MessageStatus.Pending, MessageType = Domain.MessageType.Payment, RecipientUri = "$jrhodes", Sender = sender, SenderId = senderId, SenderAccount = senderAccount, SenderAccountId = senderAccountId, SenderUri = "7082504915", Transactions = new System.Collections.ObjectModel.Collection <Domain.Transaction>(), }); _ctx.SaveChanges(); SubmittedPaymentMessageProcessor processor = new SubmittedPaymentMessageProcessor(_ctx); processor.Process(message); Assert.AreEqual(2, _ctx.Transactions.Count()); }
public void WhenPendingPaymentMessageWithMECodeRecipientUriProcessedWithKnownRecipientTwoTransactionsAreCreated() { Guid messageId = Guid.NewGuid(); Guid apiKey = Guid.NewGuid(); Guid senderId = Guid.NewGuid(); Guid senderAccountId = Guid.NewGuid(); _ctx = new FakeDbContext(); var application = _ctx.Applications.Add(new Domain.Application() { ApiKey = apiKey, ApplicationName = "Test App", IsActive = true, Url = "http:\\test.paidthx.com" }); var sender = _ctx.Users.Add(new Domain.User() { Application = application, ApiKey = apiKey, CreateDate = System.DateTime.Now, EmailAddress = "*****@*****.**", Limit = 100, MobileNumber = "8043550001", Password = "******", PaymentAccounts = new System.Collections.ObjectModel.Collection<Domain.PaymentAccount>(), IsConfirmed = true, SecurityPin = "1234", SetupPassword = true, SetupSecurityPin = true, UserStatus = Domain.UserStatus.Verified }); var recipient = _ctx.Users.Add(new Domain.User() { Application = application, ApiKey = apiKey, CreateDate = System.DateTime.Now, EmailAddress = "*****@*****.**", Limit = 100, MobileNumber = "7082504915", Password = "******", PaymentAccounts = new System.Collections.ObjectModel.Collection<Domain.PaymentAccount>(), IsConfirmed = true, SecurityPin = "1234", SetupPassword = true, SetupSecurityPin = true, UserStatus = Domain.UserStatus.Verified, DeviceToken = "6b0bf548627aecffe1a87b3febf62c9f6eda50c35b6acce067a21b365dcc94b4", MECodes = new System.Collections.ObjectModel.Collection<Domain.MECode>() }); _ctx.SaveChanges(); var senderAccount = new Domain.PaymentAccount() { AccountNumber = "1234123412", AccountType = Domain.PaymentAccountType.Checking, IsActive = true, CreateDate = System.DateTime.Now, Id = senderAccountId, NameOnAccount = "James Rhodes", RoutingNumber = "053000219", }; var recipientAccount = new Domain.PaymentAccount() { AccountNumber = "1010202030", AccountType = Domain.PaymentAccountType.Savings, IsActive = true, CreateDate = System.DateTime.Now, Id = senderAccountId, NameOnAccount = "James Rhodes", RoutingNumber = "053000211", }; sender.PaymentAccounts.Add(senderAccount); recipient.PaymentAccounts.Add(recipientAccount); var meCode = new Domain.MECode() { ApprovedDate = System.DateTime.Now, CreateDate = System.DateTime.Now, Id = Guid.NewGuid(), IsActive = true, IsApproved = true, LastUpdatedDate= System.DateTime.Now, MeCode = "$jrhodes", User = recipient }; _ctx.MECodes.Add(meCode); recipient.MECodes.Add(meCode); _ctx.SaveChanges(); var message = _ctx.Messages.Add(new Domain.Message() { Amount = 1, Application = application, ApiKey = apiKey, Comments = "Test Payment", CreateDate = System.DateTime.Now, Id = messageId, MessageStatus = Domain.MessageStatus.Pending, MessageType = Domain.MessageType.Payment, RecipientUri = "$jrhodes", Sender = sender, SenderId = senderId, SenderAccount = senderAccount, SenderAccountId = senderAccountId, SenderUri = "7082504915", Transactions = new System.Collections.ObjectModel.Collection<Domain.Transaction>(), }); _ctx.SaveChanges(); SubmittedPaymentMessageProcessor processor = new SubmittedPaymentMessageProcessor(_ctx); processor.Process(message); Assert.AreEqual(2, _ctx.Transactions.Count()); }