Пример #1
0
 public void Configure(EntityTypeBuilder <StockSubscription> entity)
 {
     entity.ToTable("StockSubscriptions", schema: "Finance");
     entity.HasKey(e => e.Id);
     entity.Property(p => p.Id).HasColumnType("UNIQUEIDENTIFIER").HasColumnName("StockId");
     entity.HasOne(p => p.EconomicEvent).WithOne().HasForeignKey <StockSubscription>(p => p.Id);
     entity.Property(p => p.FinancierId).HasColumnType("UNIQUEIDENTIFIER").HasColumnName("FinancierId");
     entity.Property(p => p.SharesIssured)
     .HasConversion(p => p.Value, p => SharesIssured.Create(p))
     .HasColumnType("INT")
     .HasColumnName("SharesIssured")
     .IsRequired();
     entity.Property(p => p.PricePerShare)
     .HasConversion(p => p.Value, p => PricePerShare.Create(p))
     .HasColumnType("DECIMAL(18,2)")
     .HasColumnName("PricePerShare")
     .IsRequired();
     entity.Property(p => p.StockIssueDate)
     .HasConversion(p => p.Value, p => StockIssueDate.Create(p))
     .HasColumnType("DATETIME2(0)")
     .HasColumnName("StockIssueDate")
     .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)");
 }
Пример #2
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);
        }
Пример #3
0
        public async Task ShouldUpdate_StockSubscription_UsingStockSubscrptionRepo()
        {
            StockSubscription stockSubscription = await _stockSubscriptionRepo.GetByIdAsync(new Guid("5997f125-bfca-4540-a144-01e444f6dc25"));

            stockSubscription.UpdatePricePerShare(PricePerShare.Create(.57M));
            stockSubscription.UpdateSharesIssured(SharesIssured.Create(666));
            stockSubscription.UpdateStockIssueDate(StockIssueDate.Create(new DateTime(2021, 11, 10)));

            await _unitOfWork.Commit();

            StockSubscription result = await _stockSubscriptionRepo.GetByIdAsync(new Guid("5997f125-bfca-4540-a144-01e444f6dc25"));

            Assert.Equal(.57M, result.PricePerShare);
            Assert.Equal(666, result.SharesIssured);
            Assert.Equal(new DateTime(2021, 11, 10), result.StockIssueDate);
        }
Пример #4
0
        public async Task ShouldInsert_StockSubscription_UsingStockSubscriptionRepo()
        {
            StockSubscription subscription = 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"))
                                             );

            await _stockSubscriptionRepo.AddAsync(subscription);

            await _unitOfWork.Commit();

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

            Assert.True(result);
        }