public void InsertValidRecordWithRequiredFieldsTest(TestCoreFramework.Enums.ResourceType resourceId, int ownerId, ResourceFields.ValidPhase phase, ResourceFields.ValidDateTime time) { var fieldHandler = new FieldManager(); var fields = fieldHandler.GetFieldGuid(ResourceFields.RequireFields[resourceId], new[] { resourceId }) .Result.Result.ToDictionary(x => $"{char.ToUpper(x.Resource[0]) + x.Resource.Substring(1)}.{x.Alias}", x => (int)UuidUtil.GetId(x.Id)); var recordHandler = new RecordManager(); var request = RecordRequestComposer.ComposeCreateRequest() .Append(resourceId, CreateResourceRequiredFieldData(fields, resourceId, ownerId, phase, time)) .Result; var response = recordHandler.WriteRecords(request); PrAssert.That(response, PrIs.SuccessfulResponse()); PrAssert.That(response.Result, PrIs.Not.Null); PrAssert.That(response.Result.Ids[0][0], PrIs.Not.Null); cleaner.Delete(resourceId.ToPrivateApiResource(), response.Result.Ids[0][0].ToString()); }
private Dictionary <int, object> CreateResourceOptionalFieldData(Dictionary <string, int> fields, TestCoreFramework.Enums.ResourceType resourceId, int ownerId, ResourceFields.ValidPhase phase, ResourceFields.ValidDateTime time, string optionField) { var result = CreateResourceRequiredFieldData(fields, resourceId, ownerId, phase, time); result.Add(fields[$"{optionField}"], ResourceFields.FieldsDictionary[resourceId][optionField] == ResourceFields.InputType.Option ? OptionForAlias.Data[optionField.Split('.')[1]] : ResourceFields.ValueDictionary[ResourceFields.FieldsDictionary[resourceId][optionField]]); return(result); }
private Dictionary <int, object> CreateResourceUserFieldData(Dictionary <string, int> fields, TestCoreFramework.Enums.ResourceType resourceId, int ownerId, ResourceFields.ValidPhase phase, ResourceFields.ValidDateTime time, string optionField) { var result = CreateResourceRequiredFieldData(fields, resourceId, ownerId, phase, time); result.Add(fields[$"{optionField}"], "This is text line"); return(result); }
private Dictionary <int, object> CreateResourceRequiredFieldData(Dictionary <string, int> fields, TestCoreFramework.Enums.ResourceType resourceId, int ownerId, ResourceFields.ValidPhase phase, ResourceFields.ValidDateTime time) { var result = new Dictionary <int, object>(); foreach (var fieldName in ResourceFields.RequireFields[resourceId]) { result.Add(fields[$"{resourceId.ToResourceName()}.{fieldName}"], ResourceFields.DefaultValue[fieldName](resourceId, ownerId, resourceId != TestCoreFramework.Enums.ResourceType.Contract ? RootPhaseOption.Data[resourceId] : 0, ResourceFields.PhaseTimeMapper[time], RecordsCreator)); } return(result); }
public void UpdateValidRecordWithOwnerTest(TestCoreFramework.Enums.ResourceType resourceId, ResourceFields.ValidPhase phase, ResourceFields.ValidDateTime time) { var fieldHandler = new FieldManager(); var fields = fieldHandler.GetFieldGuid(new List <string>() { "P_Phase", "P_PhaseDate" }, new[] { resourceId }) .Result.Result.ToDictionary(x => $"{char.ToUpper(x.Resource[0]) + x.Resource.Substring(1)}.{x.Alias}", x => (int)UuidUtil.GetId(x.Id)); var recordHandler = new RecordManager(); var response = recordHandler.UpdateRecords( RecordRequestComposer.ComposeUpdateRequest().Append(item => item.ForResource(resourceId) .Append(x => x.WithId((int)RecordsCreator.Data[resourceId.ToPrivateApiResource()].Id) .AppendFields(new Dictionary <int, object> { [fields[$"{resourceId.ToResourceName()}.P_Phase"]] = RootPhaseOption.Data[resourceId], [fields[$"{resourceId.ToResourceName()}.P_PhaseDate"]] = ResourceFields.PhaseTimeMapper[time] }))).Result); PrAssert.That(response, PrIs.SuccessfulResponse()); PrAssert.That(response.Result, PrIs.Not.Null); PrAssert.That(response.Result.Ids[0][0], PrIs.Not.Null); }
public void InsertInvalidPhaseDateRecordTest(TestCoreFramework.Enums.ResourceType resourceId, int ownerId, ResourceFields.ValidPhase phase, ResourceFields.InvalidDateTime time) { var fieldHandler = new FieldManager(); var fields = fieldHandler.GetFieldGuid(ResourceFields.RequireFields[resourceId], new[] { resourceId }) .Result.Result.ToDictionary(x => $"{char.ToUpper(x.Resource[0]) + x.Resource.Substring(1)}.{x.Alias}", x => (int)UuidUtil.GetId(x.Id)); var recordHandler = new RecordManager(); var request = RecordRequestComposer.ComposeCreateRequest() .Append(resourceId, CreateResourceRequiredFieldData(fields, resourceId, ownerId, phase, time)) .Result; var response = recordHandler.WriteRecords(request); PrAssert.That(response, PrIs.ErrorResponse()); }