public void Should_Set_LastModifierId_Again_Even_If_It_Is_Set_Before()
    {
        CurrentUserId = Guid.NewGuid();
        TargetObject.LastModifierId = Guid.NewGuid();

        AuditPropertySetter.SetModificationProperties(TargetObject);

        TargetObject.LastModificationTime.ShouldBe(Now);
        TargetObject.LastModifierId.ShouldBe(CurrentUserId);
    }
    public void Should_Not_Set_CreatorId_If_It_Is_Already_Set()
    {
        var oldCreatorUserId = Guid.NewGuid();

        CurrentUserId          = Guid.NewGuid();
        TargetObject.CreatorId = oldCreatorUserId;

        AuditPropertySetter.SetCreationProperties(TargetObject);

        TargetObject.CreationTime.ShouldBe(Now);
        TargetObject.CreatorId.ShouldBe(oldCreatorUserId);
    }
    public void Should_Clear_LastModifierId_If_Entity_Tenant_Is_Different_From_Current_User_Tenant()
    {
        CurrentTenantId             = Guid.NewGuid();
        CurrentUserId               = Guid.NewGuid();
        CurrentUserTenantId         = CurrentTenantId;
        TargetObject.TenantId       = Guid.NewGuid();
        TargetObject.LastModifierId = Guid.NewGuid();

        AuditPropertySetter.SetModificationProperties(TargetObject);

        TargetObject.LastModificationTime.ShouldBe(Now);
        TargetObject.LastModifierId.ShouldBe(null);
    }
    public void Should_Set_LastModifierId_If_Entity_Tenant_Is_Same_With_Current_User_Tenant()
    {
        CurrentTenantId = Guid.NewGuid();
        CurrentUserId   = Guid.NewGuid();

        CurrentUserTenantId   = CurrentTenantId;
        TargetObject.TenantId = CurrentTenantId;

        AuditPropertySetter.SetModificationProperties(TargetObject);

        TargetObject.LastModificationTime.ShouldBe(Now);
        TargetObject.LastModifierId.ShouldBe(CurrentUserId);
    }
    public void Should_Not_Set_CreatorId_If_Entity_Tenant_Is_Different_From_Current_User_Tenant()
    {
        CurrentTenantId = Guid.NewGuid();
        CurrentUserId   = Guid.NewGuid();

        CurrentUserTenantId   = CurrentTenantId;
        TargetObject.TenantId = Guid.NewGuid();

        AuditPropertySetter.SetCreationProperties(TargetObject);

        TargetObject.CreationTime.ShouldBe(Now);
        TargetObject.CreatorId.ShouldBe(null);
    }
示例#6
0
 protected virtual void SetDeletionAuditProperties(EntityEntry entry)
 {
     AuditPropertySetter?.SetDeletionProperties(entry.Entity);
 }
示例#7
0
 protected virtual void SetModificationAuditProperties(EntityEntry entry)
 {
     AuditPropertySetter.SetModificationProperties(entry.Entity);
 }
示例#8
0
 protected virtual void SetDeletionAuditProperties(TEntity entity)
 {
     AuditPropertySetter.SetDeletionProperties(entity);
 }
示例#9
0
 public AuditPropertySetterTestBase()
 {
     AuditPropertySetter = CreateAuditPropertySetter();
     TargetObject        = new MyAuditedObject();
 }
 public void Should_Do_Nothing_For_Non_Audited_Entity()
 {
     AuditPropertySetter.SetModificationProperties(new MyEmptyObject());
 }
    public void Should_Set_LastModificationTime()
    {
        AuditPropertySetter.SetModificationProperties(TargetObject);

        TargetObject.LastModificationTime.ShouldBe(Now);
    }
    public void Should_Set_CreationTime()
    {
        AuditPropertySetter.SetCreationProperties(TargetObject);

        TargetObject.CreationTime.ShouldBe(Now);
    }