public void WHEN_CreateInt_GIVEN_Valid_Value_THEN_Get_Valid_UniqueId() { var id = int.MaxValue; var uniqueId = _factory.CreateInt(id); CheckId(uniqueId, id, IdTypeEnum.LongInt); }
public ModelEnvelope <FieldBoundary> Convert(FieldBoundaryDto fieldBoundaryDto) { var fieldBoundary = new FieldBoundary { TimeScopes = new List <TimeScope>() { new TimeScope { TimeStamp1 = new DateTime(fieldBoundaryDto.CropYear, 1, 1), TimeStamp2 = new DateTime(fieldBoundaryDto.CropYear, 12, 31) } }, Description = $"{fieldBoundaryDto.CropYear} Boundary" }; var fieldBoundaryUniqueId = fieldBoundary.Id; var boundaryUniqueId = _uniqueIdFactory.CreateInt(fieldBoundaryDto.Id); fieldBoundaryUniqueId.UniqueIds.Add(boundaryUniqueId); var selfLink = new ReferenceLink { Id = fieldBoundaryUniqueId, Rel = Relationships.Self, Link = $"/FieldBoundaries/{boundaryUniqueId.Source}/{boundaryUniqueId.Id}" }; var fieldUniqueId = _uniqueIdFactory.CreateGuid(fieldBoundaryDto.FieldUid); var fieldCompoundId = fieldUniqueId.ToCompoundIdentifier(); fieldBoundary.FieldId = fieldCompoundId.ReferenceId; var fieldLink = new ReferenceLink { Id = fieldCompoundId, Rel = typeof(Field).ObjectRel(), Link = $"/Fields/{fieldUniqueId.Source}/{fieldUniqueId.Id}" }; // NOTE: Skipped SpatialData to not introduce Spatial Dependencies in conversion. var fieldBoundaryEnvelope = new ModelEnvelope <FieldBoundary>(fieldBoundary); fieldBoundaryEnvelope.Links.Add(selfLink); fieldBoundaryEnvelope.Links.Add(fieldLink); return(fieldBoundaryEnvelope); }
public ModelEnvelope <CropZone> Convert(CropZoneDto cropZoneDto) { var cropZone = new CropZone() { Description = cropZoneDto.Name, TimeScopes = new List <TimeScope>() { new TimeScope { TimeStamp1 = new DateTime(cropZoneDto.CropYear, 1, 1), TimeStamp2 = new DateTime(cropZoneDto.CropYear, 12, 31) } } }; var cropZoneUniqueId = _uniqueIdFactory.CreateInt(cropZoneDto.Id); var cropZoneCompoundId = cropZone.Id; cropZone.Id.UniqueIds.Add(cropZoneUniqueId); var selfLink = new ReferenceLink { Id = cropZoneCompoundId, Rel = Relationships.Self, Link = $"/CropZones/{cropZoneUniqueId.Source}/{cropZoneUniqueId.Id}" }; var fieldUniqueId = _uniqueIdFactory.CreateGuid(cropZoneDto.FieldUid); var fieldCompoundId = fieldUniqueId.ToCompoundIdentifier(); var fieldLink = new ReferenceLink { Id = fieldCompoundId, Rel = typeof(Field).Name.ToLower(), Link = $"/Fields/{fieldUniqueId.Source}/{fieldUniqueId.Id}" }; cropZone.FieldId = fieldCompoundId.ReferenceId; // NOTE: Skipped BoundingRegion to not introduce Spatial Dependencies in conversion. var cropZoneEnvelope = new ModelEnvelope <CropZone>(cropZone); cropZoneEnvelope.Links.Add(selfLink); cropZoneEnvelope.Links.Add(fieldLink); return(cropZoneEnvelope); }