From 1a9fd65482e3e01dcdfdabdc66d83e361dc19e48 Mon Sep 17 00:00:00 2001 From: Bj Date: Tue, 11 Sep 2018 18:12:05 -0400 Subject: [PATCH] Remove `DocumentData`, instead use `ResourceObject` --- .../JsonApiDeserializer_Benchmarks.cs | 2 +- .../Controllers/TodoItemsCustomController.cs | 2 +- .../Services/TodoItemService.cs | 2 +- .../Builders/DocumentBuilder.cs | 33 +++++++++---------- .../Builders/IDocumentBuilder.cs | 4 +-- .../Controllers/BaseJsonApiController.cs | 2 +- .../Controllers/JsonApiCmdController.cs | 2 +- .../Controllers/JsonApiController.cs | 2 +- src/JsonApiDotNetCore/Models/Document.cs | 2 +- src/JsonApiDotNetCore/Models/DocumentBase.cs | 2 +- src/JsonApiDotNetCore/Models/DocumentData.cs | 5 --- src/JsonApiDotNetCore/Models/Documents.cs | 2 +- .../Models/Operations/Operation.cs | 12 +++---- .../Serialization/IJsonApiDeSerializer.cs | 2 +- .../Serialization/JsonApiDeSerializer.cs | 18 +++++----- .../Contract/IUpdateRelationshipService.cs | 2 +- .../Services/EntityResourceService.cs | 2 +- .../Operations/Processors/GetOpProcessor.cs | 8 ++--- .../Helpers/Extensions/DocumentExtensions.cs | 6 ++-- .../Serialization/JsonApiDeSerializerTests.cs | 21 ++++-------- .../Processors/CreateOpProcessorTests.cs | 4 +-- 21 files changed, 61 insertions(+), 74 deletions(-) delete mode 100644 src/JsonApiDotNetCore/Models/DocumentData.cs diff --git a/benchmarks/Serialization/JsonApiDeserializer_Benchmarks.cs b/benchmarks/Serialization/JsonApiDeserializer_Benchmarks.cs index c490bee362..5487a38666 100644 --- a/benchmarks/Serialization/JsonApiDeserializer_Benchmarks.cs +++ b/benchmarks/Serialization/JsonApiDeserializer_Benchmarks.cs @@ -17,7 +17,7 @@ namespace Benchmarks.Serialization { public class JsonApiDeserializer_Benchmarks { private const string TYPE_NAME = "simple-types"; private static readonly string Content = JsonConvert.SerializeObject(new Document { - Data = new DocumentData { + Data = new ResourceObject { Type = TYPE_NAME, Id = "1", Attributes = new Dictionary { diff --git a/src/Examples/JsonApiDotNetCoreExample/Controllers/TodoItemsCustomController.cs b/src/Examples/JsonApiDotNetCoreExample/Controllers/TodoItemsCustomController.cs index f5f3e111d9..ca2e860fa9 100644 --- a/src/Examples/JsonApiDotNetCoreExample/Controllers/TodoItemsCustomController.cs +++ b/src/Examples/JsonApiDotNetCoreExample/Controllers/TodoItemsCustomController.cs @@ -126,7 +126,7 @@ public virtual async Task PatchAsync(TId id, [FromBody] T entity) } [HttpPatch("{id}/relationships/{relationshipName}")] - public virtual async Task PatchRelationshipsAsync(TId id, string relationshipName, [FromBody] List relationships) + public virtual async Task PatchRelationshipsAsync(TId id, string relationshipName, [FromBody] List relationships) { await _resourceService.UpdateRelationshipsAsync(id, relationshipName, relationships); return Ok(); diff --git a/src/Examples/NoEntityFrameworkExample/Services/TodoItemService.cs b/src/Examples/NoEntityFrameworkExample/Services/TodoItemService.cs index e07aeed3ab..d43007400c 100644 --- a/src/Examples/NoEntityFrameworkExample/Services/TodoItemService.cs +++ b/src/Examples/NoEntityFrameworkExample/Services/TodoItemService.cs @@ -84,7 +84,7 @@ public Task UpdateAsync(int id, TodoItem entity) throw new NotImplementedException(); } - public Task UpdateRelationshipsAsync(int id, string relationshipName, List relationships) + public Task UpdateRelationshipsAsync(int id, string relationshipName, List relationships) { throw new NotImplementedException(); } diff --git a/src/JsonApiDotNetCore/Builders/DocumentBuilder.cs b/src/JsonApiDotNetCore/Builders/DocumentBuilder.cs index 15e46ffd6f..6afa13e029 100644 --- a/src/JsonApiDotNetCore/Builders/DocumentBuilder.cs +++ b/src/JsonApiDotNetCore/Builders/DocumentBuilder.cs @@ -58,7 +58,7 @@ public Documents Build(IEnumerable entities) var enumeratedEntities = entities as IList ?? entities.ToList(); var documents = new Documents { - Data = new List(), + Data = new List(), Meta = GetMeta(enumeratedEntities.FirstOrDefault()) }; @@ -95,7 +95,7 @@ private Dictionary GetMeta(IIdentifiable entity) private bool ShouldIncludePageLinks(ContextEntity entity) => entity.Links.HasFlag(Link.Paging); - private List AppendIncludedObject(List includedObject, ContextEntity contextEntity, IIdentifiable entity) + private List AppendIncludedObject(List includedObject, ContextEntity contextEntity, IIdentifiable entity) { var includedEntities = GetIncludedEntities(includedObject, contextEntity, entity); if (includedEntities?.Count > 0) @@ -107,13 +107,12 @@ private List AppendIncludedObject(List includedObjec } [Obsolete("You should specify an IResourceDefinition implementation using the GetData/3 overload.")] - public DocumentData GetData(ContextEntity contextEntity, IIdentifiable entity) + public ResourceObject GetData(ContextEntity contextEntity, IIdentifiable entity) => GetData(contextEntity, entity, resourceDefinition: null); - public DocumentData GetData(ContextEntity contextEntity, IIdentifiable entity, IResourceDefinition resourceDefinition = null) + public ResourceObject GetData(ContextEntity contextEntity, IIdentifiable entity, IResourceDefinition resourceDefinition = null) { - var data = new DocumentData - { + var data = new ResourceObject { Type = contextEntity.EntityName, Id = entity.StringId }; @@ -151,7 +150,7 @@ private bool OmitNullValuedAttribute(AttrAttribute attr, object attributeValue) return attributeValue == null && _documentBuilderOptions.OmitNullValuedAttributes; } - private void AddRelationships(DocumentData data, ContextEntity contextEntity, IIdentifiable entity) + private void AddRelationships(ResourceObject data, ContextEntity contextEntity, IIdentifiable entity) { data.Relationships = new Dictionary(); contextEntity.Relationships.ForEach(r => @@ -192,9 +191,9 @@ private RelationshipData GetRelationshipData(RelationshipAttribute attr, Context return relationshipData; } - private List GetIncludedEntities(List included, ContextEntity rootContextEntity, IIdentifiable rootResource) + private List GetIncludedEntities(List included, ContextEntity rootContextEntity, IIdentifiable rootResource) { - if(_jsonApiContext.IncludedRelationships != null) + if (_jsonApiContext.IncludedRelationships != null) { foreach(var relationshipName in _jsonApiContext.IncludedRelationships) { @@ -209,8 +208,8 @@ private List GetIncludedEntities(List included, Cont return included; } - private List IncludeRelationshipChain( - List included, ContextEntity parentEntity, IIdentifiable parentResource, string[] relationshipChain, int relationshipChainIndex) + private List IncludeRelationshipChain( + List included, ContextEntity parentEntity, IIdentifiable parentResource, string[] relationshipChain, int relationshipChainIndex) { var requestedRelationship = relationshipChain[relationshipChainIndex]; var relationship = parentEntity.Relationships.FirstOrDefault(r => r.PublicRelationshipName == requestedRelationship); @@ -232,10 +231,10 @@ private List IncludeRelationshipChain( return included; } - private List IncludeSingleResourceRelationships( - List included, IIdentifiable navigationEntity, RelationshipAttribute relationship, string[] relationshipChain, int relationshipChainIndex) + private List IncludeSingleResourceRelationships( + List included, IIdentifiable navigationEntity, RelationshipAttribute relationship, string[] relationshipChain, int relationshipChainIndex) { - if(relationshipChainIndex < relationshipChain.Length) + if (relationshipChainIndex < relationshipChain.Length) { var nextContextEntity = _jsonApiContext.ContextGraph.GetContextEntity(relationship.Type); var resource = (IIdentifiable)navigationEntity; @@ -248,12 +247,12 @@ private List IncludeSingleResourceRelationships( } - private List AddIncludedEntity(List entities, IIdentifiable entity) + private List AddIncludedEntity(List entities, IIdentifiable entity) { var includedEntity = GetIncludedEntity(entity); if (entities == null) - entities = new List(); + entities = new List(); if (includedEntity != null && entities.Any(doc => string.Equals(doc.Id, includedEntity.Id) && string.Equals(doc.Type, includedEntity.Type)) == false) @@ -264,7 +263,7 @@ private List AddIncludedEntity(List entities, IIdent return entities; } - private DocumentData GetIncludedEntity(IIdentifiable entity) + private ResourceObject GetIncludedEntity(IIdentifiable entity) { if (entity == null) return null; diff --git a/src/JsonApiDotNetCore/Builders/IDocumentBuilder.cs b/src/JsonApiDotNetCore/Builders/IDocumentBuilder.cs index dccd6f753a..70f5746d2b 100644 --- a/src/JsonApiDotNetCore/Builders/IDocumentBuilder.cs +++ b/src/JsonApiDotNetCore/Builders/IDocumentBuilder.cs @@ -11,7 +11,7 @@ public interface IDocumentBuilder Documents Build(IEnumerable entities); [Obsolete("You should specify an IResourceDefinition implementation using the GetData/3 overload.")] - DocumentData GetData(ContextEntity contextEntity, IIdentifiable entity); - DocumentData GetData(ContextEntity contextEntity, IIdentifiable entity, IResourceDefinition resourceDefinition = null); + ResourceObject GetData(ContextEntity contextEntity, IIdentifiable entity); + ResourceObject GetData(ContextEntity contextEntity, IIdentifiable entity, IResourceDefinition resourceDefinition = null); } } diff --git a/src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs b/src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs index aec2d16cfe..0423b76ac0 100644 --- a/src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs +++ b/src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs @@ -181,7 +181,7 @@ public virtual async Task PatchAsync(TId id, [FromBody] T entity) return Ok(updatedEntity); } - public virtual async Task PatchRelationshipsAsync(TId id, string relationshipName, [FromBody] List relationships) + public virtual async Task PatchRelationshipsAsync(TId id, string relationshipName, [FromBody] List relationships) { if (_updateRelationships == null) throw Exceptions.UnSupportedRequestMethod; diff --git a/src/JsonApiDotNetCore/Controllers/JsonApiCmdController.cs b/src/JsonApiDotNetCore/Controllers/JsonApiCmdController.cs index 82c0fe40c4..16ab4aa74a 100644 --- a/src/JsonApiDotNetCore/Controllers/JsonApiCmdController.cs +++ b/src/JsonApiDotNetCore/Controllers/JsonApiCmdController.cs @@ -35,7 +35,7 @@ public override async Task PatchAsync(TId id, [FromBody] T entity [HttpPatch("{id}/relationships/{relationshipName}")] public override async Task PatchRelationshipsAsync( - TId id, string relationshipName, [FromBody] List relationships) + TId id, string relationshipName, [FromBody] List relationships) => await base.PatchRelationshipsAsync(id, relationshipName, relationships); [HttpDelete("{id}")] diff --git a/src/JsonApiDotNetCore/Controllers/JsonApiController.cs b/src/JsonApiDotNetCore/Controllers/JsonApiController.cs index 929e76e5aa..a77c03da06 100644 --- a/src/JsonApiDotNetCore/Controllers/JsonApiController.cs +++ b/src/JsonApiDotNetCore/Controllers/JsonApiController.cs @@ -88,7 +88,7 @@ public override async Task PatchAsync(TId id, [FromBody] T entity [HttpPatch("{id}/relationships/{relationshipName}")] public override async Task PatchRelationshipsAsync( - TId id, string relationshipName, [FromBody] List relationships) + TId id, string relationshipName, [FromBody] List relationships) => await base.PatchRelationshipsAsync(id, relationshipName, relationships); [HttpDelete("{id}")] diff --git a/src/JsonApiDotNetCore/Models/Document.cs b/src/JsonApiDotNetCore/Models/Document.cs index 71922e5573..5d0d10d188 100644 --- a/src/JsonApiDotNetCore/Models/Document.cs +++ b/src/JsonApiDotNetCore/Models/Document.cs @@ -5,6 +5,6 @@ namespace JsonApiDotNetCore.Models public class Document : DocumentBase { [JsonProperty("data")] - public DocumentData Data { get; set; } + public ResourceObject Data { get; set; } } } diff --git a/src/JsonApiDotNetCore/Models/DocumentBase.cs b/src/JsonApiDotNetCore/Models/DocumentBase.cs index eb38f9582d..8812d301e5 100644 --- a/src/JsonApiDotNetCore/Models/DocumentBase.cs +++ b/src/JsonApiDotNetCore/Models/DocumentBase.cs @@ -9,7 +9,7 @@ public class DocumentBase public RootLinks Links { get; set; } [JsonProperty("included", NullValueHandling = NullValueHandling.Ignore)] - public List Included { get; set; } + public List Included { get; set; } [JsonProperty("meta", NullValueHandling = NullValueHandling.Ignore)] public Dictionary Meta { get; set; } diff --git a/src/JsonApiDotNetCore/Models/DocumentData.cs b/src/JsonApiDotNetCore/Models/DocumentData.cs deleted file mode 100644 index ba1ce646c0..0000000000 --- a/src/JsonApiDotNetCore/Models/DocumentData.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace JsonApiDotNetCore.Models -{ - // TODO: deprecate DocumentData in favor of ResourceObject - public class DocumentData : ResourceObject { } -} diff --git a/src/JsonApiDotNetCore/Models/Documents.cs b/src/JsonApiDotNetCore/Models/Documents.cs index 5ba8203bc4..8e1dcbb36e 100644 --- a/src/JsonApiDotNetCore/Models/Documents.cs +++ b/src/JsonApiDotNetCore/Models/Documents.cs @@ -6,6 +6,6 @@ namespace JsonApiDotNetCore.Models public class Documents : DocumentBase { [JsonProperty("data")] - public List Data { get; set; } + public List Data { get; set; } } } diff --git a/src/JsonApiDotNetCore/Models/Operations/Operation.cs b/src/JsonApiDotNetCore/Models/Operations/Operation.cs index 38c544eabc..604643d231 100644 --- a/src/JsonApiDotNetCore/Models/Operations/Operation.cs +++ b/src/JsonApiDotNetCore/Models/Operations/Operation.cs @@ -32,18 +32,18 @@ private void SetData(object data) if (data is JArray jArray) { DataIsList = true; - DataList = jArray.ToObject>(); + DataList = jArray.ToObject>(); } - else if (data is List dataList) + else if (data is List dataList) { DataIsList = true; DataList = dataList; } else if (data is JObject jObject) { - DataObject = jObject.ToObject(); + DataObject = jObject.ToObject(); } - else if (data is DocumentData dataObject) + else if (data is ResourceObject dataObject) { DataObject = dataObject; } @@ -53,10 +53,10 @@ private void SetData(object data) public bool DataIsList { get; private set; } [JsonIgnore] - public List DataList { get; private set; } + public List DataList { get; private set; } [JsonIgnore] - public DocumentData DataObject { get; private set; } + public ResourceObject DataObject { get; private set; } public string GetResourceTypeName() { diff --git a/src/JsonApiDotNetCore/Serialization/IJsonApiDeSerializer.cs b/src/JsonApiDotNetCore/Serialization/IJsonApiDeSerializer.cs index 57b28c6087..6b6f41fbf7 100644 --- a/src/JsonApiDotNetCore/Serialization/IJsonApiDeSerializer.cs +++ b/src/JsonApiDotNetCore/Serialization/IJsonApiDeSerializer.cs @@ -9,6 +9,6 @@ public interface IJsonApiDeSerializer TEntity Deserialize(string requestBody); object DeserializeRelationship(string requestBody); List DeserializeList(string requestBody); - object DocumentToObject(DocumentData data, List included = null); + object DocumentToObject(ResourceObject data, List included = null); } } diff --git a/src/JsonApiDotNetCore/Serialization/JsonApiDeSerializer.cs b/src/JsonApiDotNetCore/Serialization/JsonApiDeSerializer.cs index bd2a25b0ad..28fc9c1ae2 100644 --- a/src/JsonApiDotNetCore/Serialization/JsonApiDeSerializer.cs +++ b/src/JsonApiDotNetCore/Serialization/JsonApiDeSerializer.cs @@ -80,9 +80,9 @@ public object DeserializeRelationship(string requestBody) var data = JToken.Parse(requestBody)["data"]; if (data is JArray) - return data.ToObject>(); + return data.ToObject>(); - return new List { data.ToObject() }; + return new List { data.ToObject() }; } catch (Exception e) { @@ -111,7 +111,7 @@ public List DeserializeList(string requestBody) } } - public object DocumentToObject(DocumentData data, List included = null) + public object DocumentToObject(ResourceObject data, List included = null) { if (data == null) throw new JsonApiException(422, "Failed to deserialize document as json:api."); @@ -175,7 +175,7 @@ private object SetRelationships( object entity, ContextEntity contextEntity, Dictionary relationships, - List included = null) + List included = null) { if (relationships == null || relationships.Count == 0) return entity; @@ -197,7 +197,7 @@ private object SetHasOneRelationship(object entity, HasOneAttribute attr, ContextEntity contextEntity, Dictionary relationships, - List included = null) + List included = null) { var relationshipName = attr.PublicRelationshipName; @@ -254,7 +254,7 @@ private void SetHasOneForeignKeyValue(object entity, HasOneAttribute hasOneAttr, /// If the resource has been included, all attributes will be set. /// If the resource has not been included, only the id will be set. /// - private void SetHasOneNavigationPropertyValue(object entity, HasOneAttribute hasOneAttr, ResourceIdentifierObject rio, List included) + private void SetHasOneNavigationPropertyValue(object entity, HasOneAttribute hasOneAttr, ResourceIdentifierObject rio, List included) { // if the resource identifier is null, there should be no reason to instantiate an instance if (rio != null && rio.Id != null) @@ -277,7 +277,7 @@ private object SetHasManyRelationship(object entity, RelationshipAttribute attr, ContextEntity contextEntity, Dictionary relationships, - List included = null) + List included = null) { var relationshipName = attr.PublicRelationshipName; @@ -303,7 +303,7 @@ private object SetHasManyRelationship(object entity, return entity; } - private IIdentifiable GetIncludedRelationship(ResourceIdentifierObject relatedResourceIdentifier, List includedResources, RelationshipAttribute relationshipAttr) + private IIdentifiable GetIncludedRelationship(ResourceIdentifierObject relatedResourceIdentifier, List includedResources, RelationshipAttribute relationshipAttr) { // at this point we can be sure the relationshipAttr.Type is IIdentifiable because we were able to successfully build the ContextGraph var relatedInstance = relationshipAttr.Type.New(); @@ -326,7 +326,7 @@ private IIdentifiable GetIncludedRelationship(ResourceIdentifierObject relatedRe return relatedInstance; } - private DocumentData GetLinkedResource(ResourceIdentifierObject relatedResourceIdentifier, List includedResources) + private ResourceObject GetLinkedResource(ResourceIdentifierObject relatedResourceIdentifier, List includedResources) { try { diff --git a/src/JsonApiDotNetCore/Services/Contract/IUpdateRelationshipService.cs b/src/JsonApiDotNetCore/Services/Contract/IUpdateRelationshipService.cs index c7b2fd77bf..a942cc0f74 100644 --- a/src/JsonApiDotNetCore/Services/Contract/IUpdateRelationshipService.cs +++ b/src/JsonApiDotNetCore/Services/Contract/IUpdateRelationshipService.cs @@ -11,6 +11,6 @@ public interface IUpdateRelationshipService : IUpdateRelationshipService where T : class, IIdentifiable { - Task UpdateRelationshipsAsync(TId id, string relationshipName, List relationships); + Task UpdateRelationshipsAsync(TId id, string relationshipName, List relationships); } } diff --git a/src/JsonApiDotNetCore/Services/EntityResourceService.cs b/src/JsonApiDotNetCore/Services/EntityResourceService.cs index 1e8dc249a2..1c8dabb74b 100644 --- a/src/JsonApiDotNetCore/Services/EntityResourceService.cs +++ b/src/JsonApiDotNetCore/Services/EntityResourceService.cs @@ -157,7 +157,7 @@ public virtual async Task UpdateAsync(TId id, TResource resource) return MapOut(entity); } - public virtual async Task UpdateRelationshipsAsync(TId id, string relationshipName, List relationships) + public virtual async Task UpdateRelationshipsAsync(TId id, string relationshipName, List relationships) { var entity = await _entities.GetAndIncludeAsync(id, relationshipName); if (entity == null) diff --git a/src/JsonApiDotNetCore/Services/Operations/Processors/GetOpProcessor.cs b/src/JsonApiDotNetCore/Services/Operations/Processors/GetOpProcessor.cs index 954bfadd55..6e0ad06b51 100644 --- a/src/JsonApiDotNetCore/Services/Operations/Processors/GetOpProcessor.cs +++ b/src/JsonApiDotNetCore/Services/Operations/Processors/GetOpProcessor.cs @@ -96,7 +96,7 @@ private async Task GetAllAsync(Operation operation) { var result = await _getAll.GetAsync(); - var operations = new List(); + var operations = new List(); foreach (var resource in result) { var doc = _documentBuilder.GetData( @@ -153,14 +153,14 @@ private async Task GetRelationshipAsync(Operation operation) detail: $"Type '{result.GetType()} does not implement {nameof(IIdentifiable)} nor {nameof(IEnumerable)}'"); } - private DocumentData GetData(ContextEntity contextEntity, IIdentifiable singleResource) + private ResourceObject GetData(ContextEntity contextEntity, IIdentifiable singleResource) { return _documentBuilder.GetData(contextEntity, singleResource); } - private List GetData(ContextEntity contextEntity, IEnumerable multipleResults) + private List GetData(ContextEntity contextEntity, IEnumerable multipleResults) { - var resources = new List(); + var resources = new List(); foreach (var singleResult in multipleResults) { if (singleResult is IIdentifiable resource) diff --git a/test/JsonApiDotNetCoreExampleTests/Helpers/Extensions/DocumentExtensions.cs b/test/JsonApiDotNetCoreExampleTests/Helpers/Extensions/DocumentExtensions.cs index f467e17f5b..298b86812c 100644 --- a/test/JsonApiDotNetCoreExampleTests/Helpers/Extensions/DocumentExtensions.cs +++ b/test/JsonApiDotNetCoreExampleTests/Helpers/Extensions/DocumentExtensions.cs @@ -13,7 +13,7 @@ namespace JsonApiDotNetCoreExampleTests.Helpers.Extensions { public static class DocumentExtensions { - public static DocumentData FindResource(this List included, string type, TId id) + public static ResourceObject FindResource(this List included, string type, TId id) { var document = included.Where(documentData => ( documentData.Type == type @@ -23,8 +23,8 @@ public static DocumentData FindResource(this List included, s return document; } - public static int CountOfType(this List included, string type) { + public static int CountOfType(this List included, string type) { return included.Where(documentData => documentData.Type == type).Count(); } } -} \ No newline at end of file +} diff --git a/test/UnitTests/Serialization/JsonApiDeSerializerTests.cs b/test/UnitTests/Serialization/JsonApiDeSerializerTests.cs index bf003bcecf..9ea44cd6dd 100644 --- a/test/UnitTests/Serialization/JsonApiDeSerializerTests.cs +++ b/test/UnitTests/Serialization/JsonApiDeSerializerTests.cs @@ -36,8 +36,7 @@ public void Can_Deserialize_Complex_Types() var content = new Document { - Data = new DocumentData - { + Data = new ResourceObject { Type = "test-resource", Id = "1", Attributes = new Dictionary @@ -75,8 +74,7 @@ public void Can_Deserialize_Complex_List_Types() var content = new Document { - Data = new DocumentData - { + Data = new ResourceObject { Type = "test-resource", Id = "1", Attributes = new Dictionary @@ -116,8 +114,7 @@ public void Can_Deserialize_Complex_Types_With_Dasherized_Attrs() var content = new Document { - Data = new DocumentData - { + Data = new ResourceObject { Type = "test-resource", Id = "1", Attributes = new Dictionary @@ -160,8 +157,7 @@ public void Immutable_Attrs_Are_Not_Included_In_AttributesToUpdate() var content = new Document { - Data = new DocumentData - { + Data = new ResourceObject { Type = "test-resource", Id = "1", Attributes = new Dictionary @@ -209,8 +205,7 @@ public void Can_Deserialize_Independent_Side_Of_One_To_One_Relationship() var property = Guid.NewGuid().ToString(); var content = new Document { - Data = new DocumentData - { + Data = new ResourceObject { Type = "independents", Id = "1", Attributes = new Dictionary { { "property", property } } @@ -250,8 +245,7 @@ public void Can_Deserialize_Independent_Side_Of_One_To_One_Relationship_With_Rel var property = Guid.NewGuid().ToString(); var content = new Document { - Data = new DocumentData - { + Data = new ResourceObject { Type = "independents", Id = "1", Attributes = new Dictionary { { "property", property } }, @@ -304,8 +298,7 @@ public void Sets_The_DocumentMeta_Property_In_JsonApiContext() var content = new Document { Meta = new Dictionary() { { "foo", "bar" } }, - Data = new DocumentData - { + Data = new ResourceObject { Type = "independents", Id = "1", Attributes = new Dictionary { { "property", property } }, diff --git a/test/UnitTests/Services/Operations/Processors/CreateOpProcessorTests.cs b/test/UnitTests/Services/Operations/Processors/CreateOpProcessorTests.cs index aa76f2dc17..274fda556b 100644 --- a/test/UnitTests/Services/Operations/Processors/CreateOpProcessorTests.cs +++ b/test/UnitTests/Services/Operations/Processors/CreateOpProcessorTests.cs @@ -33,7 +33,7 @@ public async Task ProcessAsync_Deserializes_And_Creates() Name = "some-name" }; - var data = new DocumentData { + var data = new ResourceObject { Type = "test-resources", Attributes = new Dictionary { { "name", testResource.Name } @@ -48,7 +48,7 @@ public async Task ProcessAsync_Deserializes_And_Creates() .AddResource("test-resources") .Build(); - _deserializerMock.Setup(m => m.DocumentToObject(It.IsAny(), It.IsAny>())) + _deserializerMock.Setup(m => m.DocumentToObject(It.IsAny(), It.IsAny>())) .Returns(testResource); var opProcessor = new CreateOpProcessor(