Esempio n. 1
0
        public async Task ShouldInsert_StockSubscriptionAndDividendDeclaration_UsingStockSubscriptionAggregate()
        {
            StockSubscription stockSubscription = new StockSubscription
                                                  (
                new EconomicEvent(Guid.NewGuid(), EventType.CashReceiptFromStockSubscription),
                FinancierId.Create(new Guid("84164388-28ff-4b47-bd63-dd9326d32236")),
                StockIssueDate.Create(new DateTime(2021, 11, 9)),
                SharesIssured.Create(33333),
                PricePerShare.Create(.33M),
                UserId.Create(new Guid("660bb318-649e-470d-9d2b-693bfb0b2744"))
                                                  );

            DividendPaymentRate dividendPayment = new DividendPaymentRate
                                                  (
                new EconomicEvent(Guid.NewGuid(), EventType.CashDisbursementForDividentPayment),
                stockSubscription,
                DividendDeclarationDate.Create(new DateTime(2021, 11, 22)),
                DividendPerShare.Create(.02M),
                UserId.Create(new Guid("660bb318-649e-470d-9d2b-693bfb0b2744"))
                                                  );

            stockSubscription.AddDividendPaymentRate(dividendPayment);
            await _stockSubscriptionRepo.AddAsync(stockSubscription);

            await _unitOfWork.Commit();

            var result = await _stockSubscriptionRepo.Exists(stockSubscription.Id);

            Assert.True(result);
        }
Esempio n. 2
0
 public void Configure(EntityTypeBuilder <DividendPaymentRate> entity)
 {
     entity.ToTable("DividendPymtRates", schema: "Finance");
     entity.HasKey(e => e.Id);
     entity.Property(p => p.Id).HasColumnType("UNIQUEIDENTIFIER").HasColumnName("DividendId");
     entity.HasOne(p => p.EconomicEvent).WithOne().HasForeignKey <DividendPaymentRate>(p => p.Id);
     entity.HasOne(p => p.StockSubscription).WithMany(p => p.DividendPaymentRates).HasForeignKey(p => p.StockId);
     entity.Property(p => p.StockId)
     .HasColumnType("UNIQUEIDENTIFIER")
     .HasColumnName("StockId")
     .IsRequired();
     entity.Property(p => p.DividendDeclarationDate)
     .HasConversion(p => p.Value, p => DividendDeclarationDate.Create(p))
     .HasColumnType("DATETIME2(0)")
     .HasColumnName("DividendDeclarationDate")
     .IsRequired();
     entity.Property(p => p.DividendPerShare)
     .HasConversion(p => p.Value, p => DividendPerShare.Create(p))
     .HasColumnType("DECIMAL(18,2)")
     .HasColumnName("DividendPerShare")
     .IsRequired();
     entity.Property(p => p.UserId)
     .HasConversion(p => p.Value, p => UserId.Create(p))
     .HasColumnType("UNIQUEIDENTIFIER")
     .HasColumnName("UserId")
     .IsRequired();
     entity.Property(e => e.CreatedDate)
     .HasColumnType("datetime2(7)")
     .ValueGeneratedOnAdd()
     .HasDefaultValueSql("sysdatetime()");
     entity.Property(e => e.LastModifiedDate).HasColumnType("datetime2(7)");
 }
Esempio n. 3
0
        public async Task ShouldUpdate_DividendDeclaration_UsingStockSubscriptionAggregate()
        {
            StockSubscription stockSubscription = await _stockSubscriptionRepo.GetByIdAsync(new Guid("264632b4-20bd-473f-9a9b-dd6f3b6ddbac"));

            DividendPaymentRate dividendPayment = stockSubscription.DividendPaymentRates.FirstOrDefault(p => p.Id == new Guid("24d6936a-beb5-451b-a950-0f30e3ad463d"));

            dividendPayment.UpdateDividendDeclarationDate(DividendDeclarationDate.Create(new DateTime(2021, 3, 16)));
            dividendPayment.UpdateDividendPerShare(DividendPerShare.Create(.035M));

            stockSubscription.UpdateDividendPaymentRate(dividendPayment);
            await _unitOfWork.Commit();

            DividendPaymentRate result = stockSubscription.DividendPaymentRates.FirstOrDefault(p => p.Id == new Guid("24d6936a-beb5-451b-a950-0f30e3ad463d"));

            Assert.Equal(new DateTime(2021, 3, 16), result.DividendDeclarationDate);
            Assert.Equal(.035M, result.DividendPerShare);
        }
Esempio n. 4
0
        public async Task ShouldInsert_DividendDeclaration_UsingStockSubscriptionAggregate()
        {
            StockSubscription stockSubscription = await _stockSubscriptionRepo.GetByIdAsync(new Guid("5997f125-bfca-4540-a144-01e444f6dc25"));

            EconomicEvent economicEvent = new EconomicEvent(Guid.NewGuid(), EventType.CashDisbursementForDividentPayment);
            await _stockSubscriptionRepo.AddEconomicEventAsync(economicEvent);

            DividendPaymentRate dividendPayment = new DividendPaymentRate
                                                  (
                economicEvent,
                stockSubscription,
                DividendDeclarationDate.Create(new DateTime(2021, 11, 22)),
                DividendPerShare.Create(.02M),
                UserId.Create(new Guid("660bb318-649e-470d-9d2b-693bfb0b2744"))
                                                  );

            stockSubscription.AddDividendPaymentRate(dividendPayment);
            _stockSubscriptionRepo.Update(stockSubscription);
            await _unitOfWork.Commit();

            DividendPaymentRate result = stockSubscription.DividendPaymentRates.FirstOrDefault(p => p.Id == dividendPayment.EconomicEvent.Id);

            Assert.NotNull(result);
        }