Exemplo n.º 1
0
        public void Should_Set_CreatorId()
        {
            CurrentUserId = Guid.NewGuid();

            AuditPropertySetter.SetCreationProperties(TargetObject);

            TargetObject.CreationTime.Subtract(Now).TotalSeconds.ShouldBeLessThanOrEqualTo(TimeSubtractSeconds);
            TargetObject.CreatorId.ShouldBe(CurrentUserId);
        }
Exemplo n.º 2
0
        public void Should_Not_Set_CreatorId_If_Entity_Tenant_Is_Different_From_Current_User_Tenant()
        {
            CurrentUserId = Guid.NewGuid();

            AuditPropertySetter.SetCreationProperties(TargetObject);

            TargetObject.CreationTime.Subtract(Now).TotalSeconds.ShouldBeLessThanOrEqualTo(TimeSubtractSeconds);
            TargetObject.CreatorId.ShouldBe(null);
        }
        public void Should_Set_LastModifierId_Again_Even_If_It_Is_Set_Before()
        {
            CurrentUserId = Guid.NewGuid();
            TargetObject.LastModifierId = Guid.NewGuid();

            AuditPropertySetter.SetModificationProperties(TargetObject);

            TargetObject.LastModificationTime.Value.Subtract(Now).TotalSeconds.ShouldBeLessThanOrEqualTo(TimeSubtractSeconds);
            TargetObject.LastModifierId.ShouldBe(CurrentUserId);
        }
Exemplo n.º 4
0
        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.Subtract(Now).TotalSeconds.ShouldBeLessThanOrEqualTo(TimeSubtractSeconds);
            TargetObject.CreatorId.ShouldBe(oldCreatorUserId);
        }
        public void Should_Set_LastModificationTime()
        {
            AuditPropertySetter.SetModificationProperties(TargetObject);

            TargetObject.LastModificationTime.Value.Subtract(Now).TotalSeconds.ShouldBeLessThanOrEqualTo(TimeSubtractSeconds);
        }
 public void Should_Do_Nothing_For_Non_Audited_Entity()
 {
     AuditPropertySetter.SetModificationProperties(new MyEmptyObject());
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AuditPropertySetterTestBase"/> class.
 /// </summary>
 public AuditPropertySetterTestBase()
 {
     AuditPropertySetter = CreateAuditPropertySetter();
     TargetObject        = new MyAuditedObject();
 }