|  |  |  | @ -6,12 +6,27 @@ namespace Volo.Abp.Auditing | 
			
		
	
		
			
				
					|  |  |  |  | { | 
			
		
	
		
			
				
					|  |  |  |  |     public class AuditPropertySetter_CreationAudit_Tests : AuditPropertySetterTestBase | 
			
		
	
		
			
				
					|  |  |  |  |     { | 
			
		
	
		
			
				
					|  |  |  |  |         [Fact] | 
			
		
	
		
			
				
					|  |  |  |  |         public void Should_Do_Nothing_For_Non_Audited_Entity() | 
			
		
	
		
			
				
					|  |  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  |  |             AuditPropertySetter.SetCreationAuditProperties(new MyEmptyObject()); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         [Fact] | 
			
		
	
		
			
				
					|  |  |  |  |         public void Should_Set_CreationTime() | 
			
		
	
		
			
				
					|  |  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  |  |             AuditPropertySetter.SetCreationAuditProperties(TargetObject); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             TargetObject.CreationTime.ShouldNotBe(default); | 
			
		
	
		
			
				
					|  |  |  |  |             TargetObject.CreationTime.ShouldBe(Now); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         [Fact] | 
			
		
	
		
			
				
					|  |  |  |  |         public void Should_Not_Set_CreatorId_If_Current_User_Is_Not_Available() | 
			
		
	
		
			
				
					|  |  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  |  |             AuditPropertySetter.SetCreationAuditProperties(TargetObject); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             TargetObject.CreationTime.ShouldBe(Now); | 
			
		
	
		
			
				
					|  |  |  |  |             TargetObject.CreatorId.ShouldBe(null); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         [Fact] | 
			
		
	
	
		
			
				
					|  |  |  | @ -21,8 +36,52 @@ namespace Volo.Abp.Auditing | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             AuditPropertySetter.SetCreationAuditProperties(TargetObject); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             TargetObject.CreationTime.ShouldNotBe(default); | 
			
		
	
		
			
				
					|  |  |  |  |             TargetObject.CreationTime.ShouldBe(Now); | 
			
		
	
		
			
				
					|  |  |  |  |             TargetObject.CreatorId.ShouldBe(CurrentUserId); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         [Fact] | 
			
		
	
		
			
				
					|  |  |  |  |         public void Should_Not_Set_CreatorId_If_It_Is_Already_Set() | 
			
		
	
		
			
				
					|  |  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  |  |             var oldCreatorUserId = Guid.NewGuid(); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             CurrentUserId = Guid.NewGuid(); | 
			
		
	
		
			
				
					|  |  |  |  |             TargetObject.CreatorId = oldCreatorUserId; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             AuditPropertySetter.SetCreationAuditProperties(TargetObject); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             TargetObject.CreationTime.ShouldBe(Now); | 
			
		
	
		
			
				
					|  |  |  |  |             TargetObject.CreatorId.ShouldBe(oldCreatorUserId); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         [Fact] | 
			
		
	
		
			
				
					|  |  |  |  |         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.SetCreationAuditProperties(TargetObject); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             TargetObject.CreationTime.ShouldBe(Now); | 
			
		
	
		
			
				
					|  |  |  |  |             TargetObject.CreatorId.ShouldBe(CurrentUserId); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         [Fact] | 
			
		
	
		
			
				
					|  |  |  |  |         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.SetCreationAuditProperties(TargetObject); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             TargetObject.CreationTime.ShouldBe(Now); | 
			
		
	
		
			
				
					|  |  |  |  |             TargetObject.CreatorId.ShouldBe(null); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | } |