public async Task ShouldCreate_FinancierAddress_Using_CreateFinancierAddressInfoWriteModel() { Financier financier = await _dbContext.Financiers.FindAsync(new Guid("94b1d516-a1c3-4df8-ae85-be1f34966601")); var model = new CreateFinancierAddressInfo { FinancierId = financier.Id, AddressLine1 = "32145 Main Street", AddressLine2 = "3rd Floor", City = "Dallas", StateCode = "TX", Zipcode = "75021" }; await _financierCmdHdlr.Handle(model); var address = (from item in financier.Addresses() where item.AddressDetails.AddressLine1.Equals(model.AddressLine1) && item.AddressDetails.AddressLine2.Equals(model.AddressLine2) && item.AddressDetails.City.Equals(model.City) && item.AddressDetails.StateCode.Equals(model.StateCode) && item.AddressDetails.Zipcode.Equals(model.Zipcode) select item).SingleOrDefault(); Assert.NotNull(address); }
public static async Task Execute ( CreateLoanAgreementInfo model, ILoanAgreementAggregateRepository loanAgreementRepo, IFinancierAggregateRepository financierRepo, IUnitOfWork unitOfWork ) { if (await loanAgreementRepo.Exists(model.Id)) { throw new InvalidOperationException($"This loan agreement already exists!"); } string errMsg = $"Unable to create loan agreement info, a financier with id {model.FinancierId} could not be found!"; Financier financier = await financierRepo.GetByIdAsync(model.FinancierId) ?? throw new InvalidOperationException(errMsg); LoanAgreement loanAgreement = new LoanAgreement ( new EconomicEvent(model.Id, EventType.CashReceiptFromLoanAgreement), FinancierId.Create(financier.Id), LoanAmount.Create(model.LoanAmount), InterestRate.Create(model.InterestRate), LoanDate.Create(model.LoanDate), MaturityDate.Create(model.MaturityDate), PaymentsPerYear.Create(model.PaymentsPerYear), model.UserId ); await loanAgreementRepo.AddAsync(loanAgreement); await unitOfWork.Commit(); }
public async Task ShouldUpdate_FinancierContact_Using_EditFinancierContactInfoWriteModel() { Financier financier = await _dbContext.Financiers.FindAsync(new Guid("94b1d516-a1c3-4df8-ae85-be1f34966601")); var model = new EditFinancierContactInfo { PersonId = 12, FinancierId = financier.Id, FirstName = "Jane", LastName = "DoeZoe", MiddleInitial = "Z", Telephone = "555-555-5555", Notes = "Hello world" }; await _financierCmdHdlr.Handle(model); var contact = (from item in financier.ContactPersons() where item.ContactName.FirstName == model.FirstName && item.ContactName.LastName == model.LastName && item.ContactName.MiddleInitial == model.MiddleInitial && item.Telephone == model.Telephone select item).SingleOrDefault(); Assert.NotNull(contact); }
public async Task ShouldUpdate_FinancierAddress_Using_UpdateFinancierAddressInfoCommand() { Financier financier = await _dbContext.Financiers.FindAsync(new Guid("12998229-7ede-4834-825a-0c55bde75695")); var model = new EditFinancierAddressInfo { AddressId = 10, FinancierId = financier.Id, AddressLine1 = "32145 Main Street", AddressLine2 = "3rd Floor", City = "Oxnard", StateCode = "CA", Zipcode = "93035" }; await _financierCmdHdlr.Handle(model); var address = (from item in financier.Addresses() where item.AddressDetails.AddressLine1.Equals(model.AddressLine1) && item.AddressDetails.AddressLine2.Equals(model.AddressLine2) && item.AddressDetails.City.Equals(model.City) && item.AddressDetails.StateCode.Equals(model.StateCode) && item.AddressDetails.Zipcode.Equals(model.Zipcode) select item).SingleOrDefault(); Assert.NotNull(address); }
private static void DoWork() { var secretary = new ModernSecretary(); var financier = new Financier(secretary); var king = new King(financier); king.RuleTheCastle(); }
public async Task ShouldUpdate_LoanAgreement_UsingFinancierRepo() { Financier financier = await _financierRepo.GetByIdAsync(new Guid("12998229-7ede-4834-825a-0c55bde75695")); LoanAgreement agreement = financier.LoanAgreements.FirstOrDefault(p => p.Id == new Guid("41ca2b0a-0ed5-478b-9109-5dfda5b2eba1")); Assert.NotNull(agreement); }
public void ShouldRaiseError_NewFinancier_WithNullExternalAgent() { Assert.Throws <ArgumentNullException>(() => { Financier financier = new Financier ( null, OrganizationName.Create("First Bank and Trust"), PhoneNumber.Create("555-555-5555"), IsActive.Create(true), new Guid("660bb318-649e-470d-9d2b-693bfb0b2744") ); }); }
public void ShouldReturn_NewFinancier() { var financierAgent = new ExternalAgent(Guid.NewGuid(), AgentType.Financier); Financier financier = new Financier ( financierAgent, OrganizationName.Create("First Bank and Trust"), PhoneNumber.Create("555-555-5555"), IsActive.Create(true), new Guid("660bb318-649e-470d-9d2b-693bfb0b2744") ); Assert.IsType <Financier>(financier); }
public void ShouldRaiseError_NewFinancier_WithInvalidExternalAgentType() { var agent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee); Assert.Throws <InvalidOperationException>(() => { Financier financier = new Financier ( agent, OrganizationName.Create("First Bank and Trust"), PhoneNumber.Create("555-555-5555"), IsActive.Create(true), new Guid("660bb318-649e-470d-9d2b-693bfb0b2744") ); }); }
public async Task ShouldDelete_Financier_UsingDeleteFinancierInfoModel() { Financier financier = await _dbContext.Financiers.FindAsync(new Guid("b49471a0-5c1e-4a4d-97e7-288fb0f6338a")); Assert.NotNull(financier); var model = new DeleteFinancierInfo { Id = financier.Id, }; await _financierCmdHdlr.Handle(model); Financier result = await _dbContext.Financiers.FindAsync(model.Id); Assert.Null(result); }
public async Task ShouldUpdate_Financier_UsingEditFinancierInfoWriteModel() { var model = new EditFinancierInfo { Id = new Guid("01da50f9-021b-4d03-853a-3fd2c95e207d"), FinancierName = "ABC Financiers, Inc.", Telephone = "214-654-9874", IsActive = true, UserId = new Guid("660bb318-649e-470d-9d2b-693bfb0b2744") }; await _financierCmdHdlr.Handle(model); Financier result = await _dbContext.Financiers.FindAsync(model.Id); Assert.Equal(model.FinancierName, result.FinancierName); Assert.Equal(model.Telephone, result.Telephone);; }
public async Task ShouldInsert_Financier_UsingCreateFinancierInfoWriteModel() { Guid id = Guid.NewGuid(); var model = new CreateFinancierInfo { Id = id, FinancierName = "ABC Financiers, Inc.", Telephone = "214-654-9874", IsActive = true, UserId = new Guid("660bb318-649e-470d-9d2b-693bfb0b2744") }; await _financierCmdHdlr.Handle(model); Financier result = await _dbContext.Financiers.FindAsync(id); Assert.NotNull(result); }
public async Task ShouldDelete_FinancierContact_Using_DeleteFinancierContactInfoWriteModel() { Financier financier = await _dbContext.Financiers.FindAsync(new Guid("94b1d516-a1c3-4df8-ae85-be1f34966601")); var model = new DeleteFinancierContactInfo { PersonId = 12, FinancierId = financier.Id }; await _financierCmdHdlr.Handle(model); var contact = (from item in financier.ContactPersons() where item.Id.Equals(model.PersonId) select item).SingleOrDefault(); Assert.Null(contact); }
public async Task ShouldDelete_FinancierAddress_Using_DeleteFinancierAddressInfoCommand() { Financier financier = await _dbContext.Financiers.FindAsync(new Guid("12998229-7ede-4834-825a-0c55bde75695")); var model = new DeleteFinancierAddressInfo { AddressId = 10, FinancierId = new Guid("12998229-7ede-4834-825a-0c55bde75695"), UserId = new Guid("660bb318-649e-470d-9d2b-693bfb0b2744") }; await _financierCmdHdlr.Handle(model); var address = (from item in financier.Addresses() where item.Id.Equals(model.AddressId) select item).SingleOrDefault(); Assert.Null(address); }
public void ShouldReturn_NewLoanAgreement() { var economicEvent = new EconomicEvent(Guid.NewGuid(), EventType.CashReceiptFromLoanAgreement); Financier financier = GetFinancier(); LoanAgreement agreement = new LoanAgreement ( economicEvent, FinancierId.Create(financier.Id), LoanAmount.Create(10000), InterestRate.Create(.006), LoanDate.Create(new DateTime(2020, 12, 31)), MaturityDate.Create(new DateTime(2021, 12, 31)), PaymentsPerYear.Create(12), UserId.Create(new Guid("660bb318-649e-470d-9d2b-693bfb0b2744")) ); Assert.IsType <LoanAgreement>(agreement); }
public void ShouldRaiseError_DefaultLoanDate() { var economicEvent = new EconomicEvent(Guid.NewGuid(), EventType.CashReceiptFromLoanAgreement); Financier financier = GetFinancier(); Assert.Throws <ArgumentNullException>(() => { new LoanAgreement ( economicEvent, FinancierId.Create(financier.Id), LoanAmount.Create(10000), InterestRate.Create(.006), LoanDate.Create(new DateTime()), MaturityDate.Create(new DateTime(2021, 12, 31)), PaymentsPerYear.Create(12), UserId.Create(new Guid("660bb318-649e-470d-9d2b-693bfb0b2744")) ); }); }