public void Should_Not_Set_CreatorId_If_Current_User_Is_Not_Available() { AuditPropertySetter.SetCreationProperties(TargetObject); TargetObject.CreationTime.ShouldBe(Now); TargetObject.CreatorId.ShouldBe(null); }
public void Should_Set_CreatorId() { CurrentUserId = Guid.NewGuid(); AuditPropertySetter.SetCreationProperties(TargetObject); TargetObject.CreationTime.ShouldBe(Now); TargetObject.CreatorId.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_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); }
public void Should_Set_CreatorId_If_Entity_Tenant_Is_Same_With_Current_User_Tenant() { CurrentTenantId = Guid.NewGuid(); CurrentUserId = Guid.NewGuid(); CurrentUserTenantId = CurrentTenantId; TargetObject.TenantId = CurrentTenantId; AuditPropertySetter.SetCreationProperties(TargetObject); TargetObject.CreationTime.ShouldBe(Now); TargetObject.CreatorId.ShouldBe(CurrentUserId); }
/// <summary> /// 设置<paramref name="entry"/>的创建者,创建时间属性 /// </summary> /// <param name="entry"></param> protected virtual void SetCreationAuditProperties(EntityEntry entry) { AuditPropertySetter?.SetCreationProperties(entry.Entity); }
protected virtual void SetCreationAuditProperties(TEntity entity) { AuditPropertySetter.SetCreationProperties(entity); }
public void Should_Do_Nothing_For_Non_Audited_Entity() { AuditPropertySetter.SetCreationProperties(new MyEmptyObject()); }
public void Should_Set_CreationTime() { AuditPropertySetter.SetCreationProperties(TargetObject); TargetObject.CreationTime.ShouldBe(Now); }