public void Should_Delete_Parameter_Value() { var entityDynamicParameter = CreateAndGetEntityDynamicParameter(); var parameterValue = new EntityDynamicParameterValue() { EntityDynamicParameterId = entityDynamicParameter.Id, EntityId = "123", Value = "TestValue", TenantId = AbpSession.TenantId }; WithUnitOfWork(() => { _entityDynamicParameterValueManager.Add(parameterValue); }); RunAndCheckIfPermissionControlled(() => { _entityDynamicParameterValueManager.Delete(parameterValue.Id); }); WithUnitOfWork(() => { try { var dynamicParameterValue = _entityDynamicParameterValueManager.Get(parameterValue.Id); dynamicParameterValue.ShouldBeNull(); } catch (EntityNotFoundException) { } }); }
public void Should_Add_Parameter_Value() { var entityDynamicParameter = CreateAndGetEntityDynamicParameter(); var val = new EntityDynamicParameterValue() { EntityDynamicParameterId = entityDynamicParameter.Id, EntityId = "123", Value = "TestValue", TenantId = AbpSession.TenantId }; RunAndCheckIfPermissionControlled(() => { _entityDynamicParameterValueManager.Add(val); }); WithUnitOfWork(() => { var val2 = _entityDynamicParameterValueManager.Get(val.Id); val.ShouldNotBeNull(); val2.ShouldNotBeNull(); val.EntityDynamicParameterId.ShouldBe(val2.EntityDynamicParameterId); val.EntityId.ShouldBe(val2.EntityId); val.Value.ShouldBe(val2.Value); }); }
public void Should_Update_Parameter_Value() { var entityDynamicParameter = CreateAndGetEntityDynamicParameter(); var parameterValue = new EntityDynamicParameterValue() { EntityDynamicParameterId = entityDynamicParameter.Id, EntityId = "123", Value = "TestValue", TenantId = AbpSession.TenantId }; WithUnitOfWork(() => { _entityDynamicParameterValueManager.Add(parameterValue); }); parameterValue.Value = "TestValue2"; RunAndCheckIfPermissionControlled(() => { _entityDynamicParameterValueManager.Update(parameterValue); }); WithUnitOfWork(() => { var parameterValueLatest = _entityDynamicParameterValueManager.Get(parameterValue.Id); parameterValueLatest.Value.ShouldBe("TestValue2"); parameterValueLatest.EntityId.ShouldBe(parameterValue.EntityId); parameterValueLatest.EntityDynamicParameterId.ShouldBe(parameterValue.EntityDynamicParameterId); }); }
private (EntityDynamicParameter entityDynamicParameter, List <EntityDynamicParameterValue> values) AddTestItems(int loop = 3, string rowId = "123") { var entityDynamicParameter = CreateAndGetEntityDynamicParameter(); var user = AsyncHelper.RunSync(() => UserManager.FindByIdAsync(AbpSession.UserId.Value)); AsyncHelper.RunSync(() => GrantPermissionAsync(user, TestPermission)); var items = new List <EntityDynamicParameterValue>(); for (int i = 0; i < loop; i++) { WithUnitOfWork(() => { var item = new EntityDynamicParameterValue() { EntityDynamicParameterId = entityDynamicParameter.Id, EntityId = rowId, Value = "TestValue", TenantId = AbpSession.TenantId }; _entityDynamicParameterValueManager.Add(item); items.Add(item); }); } return(entityDynamicParameter, items); }
public async Task Should_Delete_Parameter_Value_Async() { var entityDynamicParameter = CreateAndGetEntityDynamicParameter(); var parameterValue = new EntityDynamicParameterValue() { EntityDynamicParameterId = entityDynamicParameter.Id, EntityId = "123", Value = "TestValue", TenantId = AbpSession.TenantId }; await WithUnitOfWorkAsync(async() => { await _entityDynamicParameterValueManager.AddAsync(parameterValue); }); await RunAndCheckIfPermissionControlledAsync(async() => { await _entityDynamicParameterValueManager.DeleteAsync(parameterValue.Id); }); await WithUnitOfWorkAsync(async() => { try { var dynamicParameterValue = await _entityDynamicParameterValueManager.GetAsync(parameterValue.Id); dynamicParameterValue.ShouldBeNull(); } catch (EntityNotFoundException) { } }); }
public async Task Should_Update_Parameter_Value_Async() { var entityDynamicParameter = CreateAndGetEntityDynamicParameter(); var parameterValue = new EntityDynamicParameterValue() { EntityDynamicParameterId = entityDynamicParameter.Id, EntityId = "123", Value = "TestValue", TenantId = AbpSession.TenantId }; await WithUnitOfWorkAsync(async() => { await _entityDynamicParameterValueManager.AddAsync(parameterValue); }); await RunAndCheckIfPermissionControlledAsync(async() => { parameterValue.Value = "TestValue2"; await _entityDynamicParameterValueManager.UpdateAsync(parameterValue); }); await WithUnitOfWorkAsync(async() => { var parameterValueLatest = await _entityDynamicParameterValueManager.GetAsync(parameterValue.Id); parameterValueLatest.Value.ShouldBe("TestValue2"); parameterValueLatest.EntityId.ShouldBe(parameterValue.EntityId); parameterValueLatest.EntityDynamicParameterId.ShouldBe(parameterValue.EntityDynamicParameterId); }); }
private void CheckEquality(EntityDynamicParameterValue value1, EntityDynamicParameterValue value2) { value1.ShouldNotBeNull(); value2.ShouldNotBeNull(); value1.Id.ShouldBe(value2.Id); value1.EntityDynamicParameterId.ShouldBe(value2.EntityDynamicParameterId); value1.EntityId.ShouldBe(value2.EntityId); value1.Value.ShouldBe(value2.Value); value1.TenantId.ShouldBe(value2.TenantId); }
public async Task Should_Add_Parameter_Value_Async() { var entityDynamicParameter = CreateAndGetEntityDynamicParameter(); var val = new EntityDynamicParameterValue() { EntityDynamicParameterId = entityDynamicParameter.Id, EntityId = "123", Value = "TestValue", TenantId = AbpSession.TenantId }; await RunAndCheckIfPermissionControlledAsync(() => _entityDynamicParameterValueManager.AddAsync(val)); await WithUnitOfWorkAsync(async() => { var val2 = await _entityDynamicParameterValueManager.GetAsync(val.Id); val.ShouldNotBeNull(); val2.ShouldNotBeNull(); val.EntityDynamicParameterId.ShouldBe(val2.EntityDynamicParameterId); val.EntityId.ShouldBe(val2.EntityId); val.Value.ShouldBe(val2.Value); }); }