public void Configure(EntityTypeBuilder <Financier> entity)
 {
     entity.ToTable("Financiers", schema: "Finance");
     entity.HasKey(e => e.Id);
     entity.Property(p => p.Id).HasColumnType("UNIQUEIDENTIFIER").HasColumnName("FinancierId");
     entity.Property(p => p.FinancierName)
     .HasConversion(p => p.Value, p => OrganizationName.Create(p))
     .HasColumnType("NVARCHAR(50)")
     .HasColumnName("FinancierName")
     .IsRequired();
     entity.Property(p => p.Telephone)
     .HasConversion(p => p.Value, p => PhoneNumber.Create(p))
     .HasColumnType("NVARCHAR(14)")
     .HasColumnName("Telephone")
     .IsRequired();
     entity.Property(p => p.IsActive)
     .HasConversion(p => p.Value, p => IsActive.Create(p))
     .HasColumnType("BIT")
     .HasColumnName("IsActive")
     .IsRequired();
     entity.Property(p => p.UserId)
     .HasColumnType("UNIQUEIDENTIFIER")
     .HasColumnName("UserId")
     .IsRequired();
     entity.Property(e => e.CreatedDate)
     .HasColumnType("datetime2(7)")
     .ValueGeneratedOnAdd()
     .HasDefaultValueSql("sysdatetime()");
     entity.Property(e => e.LastModifiedDate).HasColumnType("datetime2(7)");
 }
 private Financier GetFinancier() =>
 new Financier
 (
     new ExternalAgent(Guid.NewGuid(), AgentType.Financier),
     OrganizationName.Create("First Bank and Trust"),
     PhoneNumber.Create("555-555-5555"),
     IsActive.Create(true),
     new Guid("660bb318-649e-470d-9d2b-693bfb0b2744")
 );
 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")
                                      );
            });
        }