diff --git a/.gitignore b/.gitignore deleted file mode 100644 index d9edd238..00000000 --- a/.gitignore +++ /dev/null @@ -1,184 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates -.vs/ - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -build/ -bld/ -[Bb]in/ -[Oo]bj/ - -# Roslyn cache directories -*.ide/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -#NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding addin-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -_NCrunch_* -.*crunch*.local.xml - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# If using the old MSBuild-Integrated Package Restore, uncomment this: -#!**/packages/repositories.config - -# Windows Azure Build Output -csx/ -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.pfx -*.publishsettings -node_modules/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config deleted file mode 100644 index 6a318ad9..00000000 --- a/.nuget/NuGet.Config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.nuget/NuGet.exe b/.nuget/NuGet.exe deleted file mode 100644 index c296edf1..00000000 Binary files a/.nuget/NuGet.exe and /dev/null differ diff --git a/.nuget/NuGet.targets b/.nuget/NuGet.targets deleted file mode 100644 index 428c8dad..00000000 --- a/.nuget/NuGet.targets +++ /dev/null @@ -1,144 +0,0 @@ - - - - $(MSBuildProjectDirectory)\..\ - - - false - - - false - - - true - - - false - - - - - - - - - - - $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) - - - - - $(SolutionDir).nuget - - - - $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config - $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config - - - - $(MSBuildProjectDirectory)\packages.config - $(PackagesProjectConfig) - - - - - $(NuGetToolsPath)\NuGet.exe - @(PackageSource) - - "$(NuGetExePath)" - mono --runtime=v4.0.30319 "$(NuGetExePath)" - - $(TargetDir.Trim('\\')) - - -RequireConsent - -NonInteractive - - "$(SolutionDir) " - "$(SolutionDir)" - - - $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir) - $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols - - - - RestorePackages; - $(BuildDependsOn); - - - - - $(BuildDependsOn); - BuildPackage; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/AcceptanceTestsBase.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/AcceptanceTestsBase.cs deleted file mode 100644 index d0594337..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/AcceptanceTestsBase.cs +++ /dev/null @@ -1,186 +0,0 @@ -using System; -using System.Data.Common; -using System.Globalization; -using System.IO; -using System.Net; -using System.Net.Http; -using System.Net.Http.Formatting; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using FluentAssertions; -using JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models; -using JSONAPI.Json; -using Microsoft.Owin.Testing; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using Owin; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests -{ - [TestClass] - public abstract class AcceptanceTestsBase - { - private const string JsonApiContentType = "application/vnd.api+json"; - private static readonly Regex GuidRegex = new Regex(@"\b[A-F0-9]{8}(?:-[A-F0-9]{4}){3}-[A-F0-9]{12}\b", RegexOptions.IgnoreCase); - //private static readonly Regex StackTraceRegex = new Regex(@"""stackTrace"":[\s]*""[\w\:\\\.\s\,\-]*"""); - private static readonly Regex StackTraceRegex = new Regex(@"""stackTrace""[\s]*:[\s]*"".*?"""); - protected static Uri BaseUri = new Uri("https://www.example.com"); - - protected static DbConnection GetEffortConnection() - { - return TestHelpers.GetEffortConnection(@"Data"); - } - - protected virtual async Task AssertResponseContent(HttpResponseMessage response, string expectedResponseTextResourcePath, HttpStatusCode expectedStatusCode, bool redactErrorData = false) - { - var responseContent = await response.Content.ReadAsStringAsync(); - - var expectedResponse = ExpectedResponse(expectedResponseTextResourcePath); - string actualResponse; - if (redactErrorData) - { - var redactedResponse = GuidRegex.Replace(responseContent, "{{SOME_GUID}}"); - actualResponse = StackTraceRegex.Replace(redactedResponse, "\"stackTrace\":\"{{STACK_TRACE}}\""); - actualResponse.Should().Be(expectedResponse); - } - else - { - actualResponse = responseContent; - JsonSerializerSettings settings = new JsonSerializerSettings - { - DateTimeZoneHandling = DateTimeZoneHandling.Utc, - DateFormatString = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffff+00:00", - Culture = CultureInfo.InvariantCulture, - Formatting = Formatting.Indented - }; - - var actualResponseJObject = JsonConvert.DeserializeObject(actualResponse) as JObject; - var expectedResponseJObject = JsonConvert.DeserializeObject(expectedResponse) as JObject; - var equals = JToken.DeepEquals(actualResponseJObject, expectedResponseJObject); - if (!equals) - { - Assert.Fail("should be: " + JsonConvert.SerializeObject(expectedResponseJObject, settings) + "\n but was: " + JsonConvert.SerializeObject(actualResponseJObject, settings)); - } - } - - response.Content.Headers.ContentType.MediaType.Should().Be(JsonApiContentType); - response.Content.Headers.ContentType.CharSet.Should().Be("utf-8"); - - response.StatusCode.Should().Be(expectedStatusCode); - } - - protected virtual string ExpectedResponse(string expectedResponseTextResourcePath) - { - var expectedResponse = - JsonHelpers.MinifyJson(TestHelpers.ReadEmbeddedFile(expectedResponseTextResourcePath)); - return expectedResponse; - } - - #region GET - - protected async Task SubmitGet(DbConnection effortConnection, string requestPath) - { - using (var server = TestServer.Create(app => - { - var startup = new Startup(() => new TestDbContext(effortConnection, false)); - StartupConfiguration(startup, app); - })) - { - var uri = new Uri(BaseUri, requestPath); - var response = await server.CreateRequest(uri.ToString()).AddHeader("Accept", JsonApiContentType).GetAsync(); - return response; - } - } - - #endregion - #region POST - - protected async Task SubmitPost(DbConnection effortConnection, string requestPath, string requestDataTextResourcePath) - { - using (var server = TestServer.Create(app => - { - var startup = new Startup(() => new TestDbContext(effortConnection, false)); - StartupConfiguration(startup, app); - })) - { - var uri = new Uri(BaseUri, requestPath); - var requestContent = TestHelpers.ReadEmbeddedFile(requestDataTextResourcePath); - var response = await server - .CreateRequest(uri.ToString()) - .AddHeader("Accept", JsonApiContentType) - .And(request => - { - request.Content = new StringContent(requestContent, Encoding.UTF8, "application/vnd.api+json"); - }) - .PostAsync(); - return response; - } - } - - #endregion - #region PATCH - - protected async Task SubmitPatch(DbConnection effortConnection, string requestPath, string requestDataTextResourcePath) - { - using (var server = TestServer.Create(app => - { - var startup = new Startup(() => new TestDbContext(effortConnection, false)); - StartupConfiguration(startup, app); - })) - { - var uri = new Uri(BaseUri, requestPath); - var requestContent = TestHelpers.ReadEmbeddedFile(requestDataTextResourcePath); - var response = await server - .CreateRequest(uri.ToString()) - .AddHeader("Accept", JsonApiContentType) - .And(request => - { - request.Content = new StringContent(requestContent, Encoding.UTF8, "application/vnd.api+json"); - }).SendAsync("PATCH"); - return response; - } - } - - #endregion - #region DELETE - - protected async Task SubmitDelete(DbConnection effortConnection, string requestPath) - { - using (var server = TestServer.Create(app => - { - var startup = new Startup(() => new TestDbContext(effortConnection, false)); - StartupConfiguration(startup, app); - })) - { - var uri = new Uri(BaseUri, requestPath); - var response = await server - .CreateRequest(uri.ToString()) - .AddHeader("Accept", JsonApiContentType) - .SendAsync("DELETE"); - return response; - } - } - - #endregion - - - - #region configure startup - - /// - /// Startup process was divided into 4 steps to support better acceptance tests. - /// This method can be overridden by subclass to change behavior of setup. - /// - /// - /// - protected virtual void StartupConfiguration(Startup startup, IAppBuilder app) - { - startup.Configuration(app); - } - - #endregion - } -} diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/App.config b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/App.config deleted file mode 100644 index da9a789a..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/App.config +++ /dev/null @@ -1,37 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/AttributeSerializationTests.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/AttributeSerializationTests.cs deleted file mode 100644 index fd06bda9..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/AttributeSerializationTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Net; -using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests -{ - [TestClass] - public class AttributeSerializationTests : AcceptanceTestsBase - { - [TestMethod] - public async Task Attributes_of_various_types_serialize_correctly() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "samples"); - - await AssertResponseContent(response, @"Fixtures\AttributeSerialization\Attributes_of_various_types_serialize_correctly.json", HttpStatusCode.OK); - } - } - } -} diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/BaseUrlTest.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/BaseUrlTest.cs deleted file mode 100644 index cda8ccf8..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/BaseUrlTest.cs +++ /dev/null @@ -1,166 +0,0 @@ -using System; -using System.Data.SqlTypes; -using System.Linq; -using System.Net; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using FluentAssertions; -using JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models; -using JSONAPI.Http; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Owin; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests -{ - [TestClass] - public class BaseUrlTest : AcceptanceTestsBase - { - [TestInitialize] - public void TestInit() - { - if (!BaseUri.AbsoluteUri.EndsWith("api/")) - { - BaseUri = new Uri(BaseUri.AbsoluteUri + "api/"); - } - } - [TestCleanup] - public void TestCleanup() - { - if (BaseUri.AbsoluteUri.EndsWith("api/")) - { - BaseUri = new Uri(BaseUri.AbsoluteUri.Substring(0,BaseUri.AbsoluteUri.Length -4)); - } - } - - // custom startup process for this test - protected override void StartupConfiguration(Startup startup, IAppBuilder app) - { - - var configuration = startup.BuildConfiguration(); - // here we add the custom BaseUrlServcie - configuration.CustomBaseUrlService = new BaseUrlService("api"); - var configurator = startup.BuildAutofacConfigurator(app); - var httpConfig = startup.BuildHttpConfiguration(); - startup.MergeAndSetupConfiguration(app, configurator, httpConfig, configuration); - } - - // custom expected response method - protected override string ExpectedResponse(string expectedResponseTextResourcePath) - { - var expected = base.ExpectedResponse(expectedResponseTextResourcePath); - return Regex.Replace(expected, @"www\.example\.com\/", @"www.example.com/api/"); - } - - // copied some tests in here - - // copied from ComputedIdTests - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Language.csv", @"Data")] - [DeploymentItem(@"Data\LanguageUserLink.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Get_resource_with_computed_id_by_id() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "language-user-links/9001_402"); - - await AssertResponseContent(response, @"Fixtures\ComputedId\Responses\Get_resource_with_computed_id_by_id_Response.json", HttpStatusCode.OK); - } - } - - - // copied from CreatingResourcesTests - - - [TestMethod] - [DeploymentItem(@"Data\PostLongId.csv", @"Data")] - public async Task PostLongId_with_client_provided_id() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPost(effortConnection, "post-long-ids", @"Fixtures\CreatingResources\Requests\PostLongId_with_client_provided_id_Request.json"); - - await AssertResponseContent(response, @"Fixtures\CreatingResources\Responses\PostLongId_with_client_provided_id_Response.json", HttpStatusCode.OK); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.PostsLongId.ToArray(); - allPosts.Length.Should().Be(5); - var actualPost = allPosts.First(t => t.Id == 205); - actualPost.Id.Should().Be(205); - actualPost.Title.Should().Be("Added post"); - actualPost.Content.Should().Be("Added post content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 03, 11, 04, 31, 0, new TimeSpan(0))); - } - } - } - - - - // copied from DeletingResourcesTests - - [TestMethod] - [DeploymentItem(@"Data\PostID.csv", @"Data")] - public async Task DeleteID() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitDelete(effortConnection, "post-i-ds/203"); - - var responseContent = await response.Content.ReadAsStringAsync(); - responseContent.Should().Be(""); - response.StatusCode.Should().Be(HttpStatusCode.NoContent); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.PostsID.ToArray(); - allPosts.Length.Should().Be(3); - var actualPosts = allPosts.FirstOrDefault(t => t.ID == "203"); - actualPosts.Should().BeNull(); - } - } - } - - - - // copied from FetchingResourcesTests - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task GetWithFilter() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "posts?filter[title]=Post 4"); - - await AssertResponseContent(response, @"Fixtures\FetchingResources\GetWithFilterResponse.json", HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task GetById() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "posts/202"); - - await AssertResponseContent(response, @"Fixtures\FetchingResources\GetByIdResponse.json", HttpStatusCode.OK); - } - } - - } -} diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/ComputedIdTests.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/ComputedIdTests.cs deleted file mode 100644 index 64c09347..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/ComputedIdTests.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Net; -using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests -{ - [TestClass] - public class ComputedIdTests : AcceptanceTestsBase - { - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Language.csv", @"Data")] - [DeploymentItem(@"Data\LanguageUserLink.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Get_all_of_resource_with_computed_id() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "language-user-links"); - - await AssertResponseContent(response, @"Fixtures\ComputedId\Responses\Get_all_of_resource_with_computed_id_Response.json", HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Language.csv", @"Data")] - [DeploymentItem(@"Data\LanguageUserLink.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Get_resource_with_computed_id_by_id() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "language-user-links/9001_402"); - - await AssertResponseContent(response, @"Fixtures\ComputedId\Responses\Get_resource_with_computed_id_by_id_Response.json", HttpStatusCode.OK); - } - } - } -} diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/CreatingResourcesTests.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/CreatingResourcesTests.cs deleted file mode 100644 index b189e933..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/CreatingResourcesTests.cs +++ /dev/null @@ -1,145 +0,0 @@ -using System; -using System.Linq; -using System.Net; -using System.Threading.Tasks; -using FluentAssertions; -using JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests -{ - [TestClass] - public class CreatingResourcesTests : AcceptanceTestsBase - { - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Post_with_client_provided_id() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPost(effortConnection, "posts", @"Fixtures\CreatingResources\Requests\Post_with_client_provided_id_Request.json"); - - await AssertResponseContent(response, @"Fixtures\CreatingResources\Responses\Post_with_client_provided_id_Response.json", HttpStatusCode.OK); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(5); - var actualPost = allPosts.First(t => t.Id == "205"); - actualPost.Id.Should().Be("205"); - actualPost.Title.Should().Be("Added post"); - actualPost.Content.Should().Be("Added post content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 03, 11, 04, 31, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\PostID.csv", @"Data")] - public async Task PostID_with_client_provided_id() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPost(effortConnection, "post-i-ds", @"Fixtures\CreatingResources\Requests\PostID_with_client_provided_id_Request.json"); - - await AssertResponseContent(response, @"Fixtures\CreatingResources\Responses\PostID_with_client_provided_id_Response.json", HttpStatusCode.OK); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.PostsID.ToArray(); - allPosts.Length.Should().Be(5); - var actualPost = allPosts.First(t => t.ID == "205"); - actualPost.ID.Should().Be("205"); - actualPost.Title.Should().Be("Added post"); - actualPost.Content.Should().Be("Added post content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 03, 11, 04, 31, 0, new TimeSpan(0))); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\PostLongId.csv", @"Data")] - public async Task PostLongId_with_client_provided_id() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPost(effortConnection, "post-long-ids", @"Fixtures\CreatingResources\Requests\PostLongId_with_client_provided_id_Request.json"); - - await AssertResponseContent(response, @"Fixtures\CreatingResources\Responses\PostLongId_with_client_provided_id_Response.json", HttpStatusCode.OK); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.PostsLongId.ToArray(); - allPosts.Length.Should().Be(5); - var actualPost = allPosts.First(t => t.Id == 205); - actualPost.Id.Should().Be(205); - actualPost.Title.Should().Be("Added post"); - actualPost.Content.Should().Be("Added post content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 03, 11, 04, 31, 0, new TimeSpan(0))); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Post_with_empty_id() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPost(effortConnection, "posts", @"Fixtures\CreatingResources\Requests\Post_with_empty_id_Request.json"); - - await AssertResponseContent(response, @"Fixtures\CreatingResources\Responses\Post_with_empty_id_Response.json", HttpStatusCode.OK); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(5); - var actualPost = allPosts.First(t => t.Id == "230"); - actualPost.Id.Should().Be("230"); - actualPost.Title.Should().Be("New post"); - actualPost.Content.Should().Be("The server generated my ID"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 04, 13, 12, 09, 0, new TimeSpan(0, 3, 0, 0))); - actualPost.AuthorId.Should().Be("401"); - } - } - } - - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Post_with_empty_id_and_include() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPost(effortConnection, "posts?include=author", @"Fixtures\CreatingResources\Requests\Post_with_empty_id_Request.json"); - - await AssertResponseContent(response, @"Fixtures\CreatingResources\Responses\Post_with_empty_id_and_include_author_Response.json", HttpStatusCode.OK); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(5); - var actualPost = allPosts.First(t => t.Id == "230"); - actualPost.Id.Should().Be("230"); - actualPost.Title.Should().Be("New post"); - actualPost.Content.Should().Be("The server generated my ID"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 04, 13, 12, 09, 0, new TimeSpan(0, 3, 0, 0))); - actualPost.AuthorId.Should().Be("401"); - } - } - } - } -} diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Building.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Building.csv deleted file mode 100644 index 5faa1c59..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Building.csv +++ /dev/null @@ -1,3 +0,0 @@ -Id,Address,OwnerCompanyId -"1000","123 Sesame St.","1100" -"1001","1600 Pennsylvania Avenue", diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Child.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Child.csv deleted file mode 100644 index b529aab6..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Child.csv +++ /dev/null @@ -1,7 +0,0 @@ -Id,ChildDescription,MasterId -7500,"Child 1 Description",1500 -7501,"Child 2 Description",1501 -7502,"Child 3 Description",1501 -7503,"Child 4 Description",1503 -7504,"Child 5 Description",1503 -7505,"Child 6 Description",1503 \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Comment.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Comment.csv deleted file mode 100644 index 6260de5b..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Comment.csv +++ /dev/null @@ -1,6 +0,0 @@ -Id,Text,Created,PostId,AuthorId -"101","Comment 1","2015-01-31T14:30Z","201","403" -"102","Comment 2","2015-01-31T14:35Z","201","402" -"103","Comment 3","2015-01-31T14:41Z","201","403" -"104","Comment 4","2015-02-05T09:08Z","202","403" -"105","Comment 5","2015-02-06T14:19Z","203","401" \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Company.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Company.csv deleted file mode 100644 index 4dc5014b..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Company.csv +++ /dev/null @@ -1,2 +0,0 @@ -Id,Name -"1100","Big Bird and Friends" diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Language.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Language.csv deleted file mode 100644 index 78bcf317..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Language.csv +++ /dev/null @@ -1,5 +0,0 @@ -Id,Name -"9000","English" -"9001","French" -"9002","Spanish" -"9003","German" \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/LanguageUserLink.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/LanguageUserLink.csv deleted file mode 100644 index 88310b3b..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/LanguageUserLink.csv +++ /dev/null @@ -1,7 +0,0 @@ -LanguageId,UserId,FluencyLevel -"9000","401","Native" -"9001","401","Conversational" -"9002","401","Fluent" -"9001","402","Native" -"9002","403","Native" -"9003","404","Native" \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Master.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Master.csv deleted file mode 100644 index 2a582cc4..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Master.csv +++ /dev/null @@ -1,5 +0,0 @@ -Id,Description -1500,"Master 1 Description" -1501,"Master 2 Description" -1502,"Master 3 Description" -1503,"Master 4 Description" diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Officer.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Officer.csv deleted file mode 100644 index 3d36dcbe..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Officer.csv +++ /dev/null @@ -1,6 +0,0 @@ -OfficerId,Name,Rank -"12000","James T. Kirk","Captain" -"12010","Jean-Luc Picard","Captain" -"12011","William T. Riker","Commander" -"12012","Data","Lt. Commander" -"12013","Deanna Troi","Lt. Commander" \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Post.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Post.csv deleted file mode 100644 index 08417948..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Post.csv +++ /dev/null @@ -1,5 +0,0 @@ -Id,Title,Content,Created,AuthorId -"201","Post 1","Post 1 content","2015-01-31T14:00Z","401" -"202","Post 2","Post 2 content","2015-02-05T08:10Z","401" -"203","Post 3","Post 3 content","2015-02-07T11:11Z","401" -"204","Post 4","Post 4 content","2015-02-08T06:59Z","402" \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/PostID.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/PostID.csv deleted file mode 100644 index 544b39c7..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/PostID.csv +++ /dev/null @@ -1,5 +0,0 @@ -ID,Title,Content,Created,AuthorId -"201","Post 1","Post 1 content","2015-01-31T14:00Z" -"202","Post 2","Post 2 content","2015-02-05T08:10Z" -"203","Post 3","Post 3 content","2015-02-07T11:11Z" -"204","Post 4","Post 4 content","2015-02-08T06:59Z" \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/PostLongId.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/PostLongId.csv deleted file mode 100644 index ac3f5a42..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/PostLongId.csv +++ /dev/null @@ -1,5 +0,0 @@ -Id,Title,Content,Created,AuthorId -201,"Post 1","Post 1 content","2015-01-31T14:00Z" -202,"Post 2","Post 2 content","2015-02-05T08:10Z" -203,"Post 3","Post 3 content","2015-02-07T11:11Z" -204,"Post 4","Post 4 content","2015-02-08T06:59Z" \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/PostTagLink.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/PostTagLink.csv deleted file mode 100644 index f982e30d..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/PostTagLink.csv +++ /dev/null @@ -1,6 +0,0 @@ -PostId,TagId -"201","301" -"201","302" -"202","302" -"202","303" -"203","303" \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Starship.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Starship.csv deleted file mode 100644 index 7214a1df..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Starship.csv +++ /dev/null @@ -1,4 +0,0 @@ -StarshipId,Name,StarshipClassId -"NCC-1701","USS Enterprise","80001" -"NCC-1701-D","USS Enterprise","80002" -"NCC-74656","USS Voyager","80003" diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/StarshipClass.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/StarshipClass.csv deleted file mode 100644 index 4aeb6903..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/StarshipClass.csv +++ /dev/null @@ -1,4 +0,0 @@ -StarshipClassId,Name -"80001","Constitution" -"80002","Galaxy" -"80003","Intrepid" diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/StarshipOfficerLink.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/StarshipOfficerLink.csv deleted file mode 100644 index be97ff49..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/StarshipOfficerLink.csv +++ /dev/null @@ -1,6 +0,0 @@ -StarshipId,OfficerId,Position -"NCC-1701","12000","Commanding Officer" -"NCC-1701-D","12010","Commanding Officer" -"NCC-1701-D","12011","First Officer" -"NCC-1701-D","12012","Second Officer" -"NCC-1701-D","12013","Ship's Counselor" \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Tag.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Tag.csv deleted file mode 100644 index 0ef35596..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/Tag.csv +++ /dev/null @@ -1,4 +0,0 @@ -Id,Name -"301","Tag A" -"302","Tag B" -"303","Tag C" \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/User.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/User.csv deleted file mode 100644 index d1c22ad6..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/User.csv +++ /dev/null @@ -1,11 +0,0 @@ -Id,FirstName,LastName -"401","Alice","Smith" -"402","Bob","Jones" -"403","Charlie","Michaels" -"404","Richard","Smith" -"405","Michelle","Johnson" -"406","Ed","Burns" -"407","Thomas","Potter" -"408","Pat","Morgan" -"409","Charlie","Burns" -"410","Sally","Burns" \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/UserGroup.csv b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/UserGroup.csv deleted file mode 100644 index 30ab4160..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Data/UserGroup.csv +++ /dev/null @@ -1,2 +0,0 @@ -Id,Name -"501","Admin users" diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/DeletingResourcesTests.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/DeletingResourcesTests.cs deleted file mode 100644 index f77715f5..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/DeletingResourcesTests.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System.Linq; -using System.Net; -using System.Threading.Tasks; -using FluentAssertions; -using JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests -{ - [TestClass] - public class DeletingResourcesTests : AcceptanceTestsBase - { - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Delete() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitDelete(effortConnection, "posts/203"); - - var responseContent = await response.Content.ReadAsStringAsync(); - responseContent.Should().Be(""); - response.StatusCode.Should().Be(HttpStatusCode.NoContent); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(3); - var actualPosts = allPosts.FirstOrDefault(t => t.Id == "203"); - actualPosts.Should().BeNull(); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\PostID.csv", @"Data")] - public async Task DeleteID() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitDelete(effortConnection, "post-i-ds/203"); - - var responseContent = await response.Content.ReadAsStringAsync(); - responseContent.Should().Be(""); - response.StatusCode.Should().Be(HttpStatusCode.NoContent); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.PostsID.ToArray(); - allPosts.Length.Should().Be(3); - var actualPosts = allPosts.FirstOrDefault(t => t.ID == "203"); - actualPosts.Should().BeNull(); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\PostLongId.csv", @"Data")] - public async Task DeleteLongId() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitDelete(effortConnection, "post-long-ids/203"); - - var responseContent = await response.Content.ReadAsStringAsync(); - responseContent.Should().Be(""); - response.StatusCode.Should().Be(HttpStatusCode.NoContent); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.PostsLongId.ToArray(); - allPosts.Length.Should().Be(3); - var actualPosts = allPosts.FirstOrDefault(t => t.Id == 203); - actualPosts.Should().BeNull(); - } - } - } - } -} diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/ErrorsTests.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/ErrorsTests.cs deleted file mode 100644 index f1c663c6..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/ErrorsTests.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Net; -using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests -{ - [TestClass] - public class ErrorsTests : AcceptanceTestsBase - { - [TestMethod] - public async Task Controller_action_throws_exception() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "trees"); - - await AssertResponseContent(response, @"Fixtures\Errors\Controller_action_throws_exception.json", HttpStatusCode.InternalServerError, true); - } - } - - [TestMethod] - [Ignore] - public async Task Controller_does_not_exist() - { - // TODO: Currently ignoring this test because it doesn't seem possible to intercept 404s before they make it to the formatter - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "foo"); - - await AssertResponseContent(response, @"Fixtures\Errors\Controller_does_not_exist.json", HttpStatusCode.NotFound, true); - } - } - } -} diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/FetchingResourcesTests.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/FetchingResourcesTests.cs deleted file mode 100644 index 39eb2938..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/FetchingResourcesTests.cs +++ /dev/null @@ -1,251 +0,0 @@ -using System.Net; -using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests -{ - [TestClass] - public class FetchingResourcesTests : AcceptanceTestsBase - { - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task GetAll() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "posts"); - - await AssertResponseContent(response, @"Fixtures\FetchingResources\GetAllResponse.json", HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task GetWithFilter() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "posts?filter[title]=Post 4"); - - await AssertResponseContent(response, @"Fixtures\FetchingResources\GetWithFilterResponse.json", HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task GetById() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "posts/202"); - - await AssertResponseContent(response, @"Fixtures\FetchingResources\GetByIdResponse.json", HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Get_resource_by_id_that_doesnt_exist() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "posts/3000"); - - await AssertResponseContent(response, @"Fixtures\FetchingResources\Get_resource_by_id_that_doesnt_exist.json", HttpStatusCode.NotFound, true); - } - } - - [TestMethod] - [DeploymentItem(@"Data\UserGroup.csv", @"Data")] - public async Task Get_dasherized_resource() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "user-groups"); - - await AssertResponseContent(response, @"Fixtures\FetchingResources\Get_dasherized_resource.json", HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Get_related_to_many() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "posts/201/comments"); - - await AssertResponseContent(response, @"Fixtures\FetchingResources\Get_related_to_many_response.json", HttpStatusCode.OK); - } - } - - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Get_related_to_many_included() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "posts/201/comments?include=author"); - - await AssertResponseContent(response, @"Fixtures\FetchingResources\Get_related_to_many_include_response.json", HttpStatusCode.OK); - } - } - - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Get_related_to_many_included_external() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "users/401/posts?include=tags"); - - await AssertResponseContent(response, @"Fixtures\FetchingResources\Get_related_to_many_include_external_response.json", HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Get_related_to_one() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "posts/201/author"); - - await AssertResponseContent(response, @"Fixtures\FetchingResources\Get_related_to_one_response.json", HttpStatusCode.OK); - } - } - - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Get_included_to_one() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "posts/201?include=author"); - - await AssertResponseContent(response, @"Fixtures\FetchingResources\Get_included_to_one_response.json", HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Get_related_to_one_for_resource_that_doesnt_exist() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "posts/3000/author"); - - await AssertResponseContent(response, - @"Fixtures\FetchingResources\Get_related_to_one_for_resource_that_doesnt_exist.json", - HttpStatusCode.NotFound, true); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Get_related_to_many_for_resource_that_doesnt_exist() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "posts/3000/tags"); - - await AssertResponseContent(response, - @"Fixtures\FetchingResources\Get_related_to_many_for_resource_that_doesnt_exist.json", - HttpStatusCode.NotFound, true); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Get_related_resource_for_relationship_that_doesnt_exist() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "posts/201/bananas"); - - await AssertResponseContent(response, - @"Fixtures\FetchingResources\Get_related_resource_for_relationship_that_doesnt_exist.json", - HttpStatusCode.NotFound, true); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Building.csv", @"Data")] - [DeploymentItem(@"Data\Company.csv", @"Data")] - public async Task Get_related_to_one_where_it_is_null() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "buildings/1001/owner"); - - await AssertResponseContent(response, - @"Fixtures\FetchingResources\Get_related_to_one_where_it_is_null.json", - HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Master.csv", @"Data")] - [DeploymentItem(@"Data\Child.csv", @"Data")] - public async Task Get_related_to_many_integer_key() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "masters/1501/children"); - - await AssertResponseContent(response, @"Fixtures\FetchingResources\Get_related_to_many_integer_key_response.json", HttpStatusCode.OK); - } - } - } -} diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/AttributeSerialization/Attributes_of_various_types_serialize_correctly.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/AttributeSerialization/Attributes_of_various_types_serialize_correctly.json deleted file mode 100644 index ca94936a..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/AttributeSerialization/Attributes_of_various_types_serialize_correctly.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "data": [ - { - "type": "samples", - "id": "1", - "attributes": { - "boolean-field": false, - "byte-field": 0, - "complex-attribute-field": null, - "date-time-field": "0001-01-01T00:00:00", - "date-time-offset-field": "0001-01-01T00:00:00.0000000+00:00", - "decimal-field": "0", - "double-field": 0.0, - "enum-field": 0, - "guid-field": "00000000-0000-0000-0000-000000000000", - "int16-field": 0, - "int32-field": 0, - "int64-field": 0, - "j-token-array-field": null, - "j-token-object-field": null, - "j-token-string-field": null, - "nullable-boolean-field": false, - "nullable-byte-field": null, - "nullable-date-time-field": null, - "nullable-date-time-offset-field": null, - "nullable-decimal-field": null, - "nullable-double-field": null, - "nullable-enum-field": null, - "nullable-guid-field": null, - "nullable-int16-field": null, - "nullable-int32-field": null, - "nullable-int64-field": null, - "nullable-sbyte-field": null, - "nullable-single-field": null, - "nullable-uint16-field": null, - "nullable-uint32-field": null, - "nullable-uint64-field": null, - "sbyte-field": 0, - "single-field": 0.0, - "string-field": null, - "uint16-field": 0, - "uint32-field": 0, - "uint64-field": 0 - } - }, - { - "type": "samples", - "id": "2", - "attributes": { - "boolean-field": true, - "byte-field": 253, - "complex-attribute-field": { - "foo": { - "baz": [ 11 ] - }, - "bar": 5 - }, - "date-time-field": "1776-07-04T00:00:00", - "date-time-offset-field": "1776-07-04T00:00:00.0000000-05:00", - "decimal-field": "1056789.123", - "double-field": 1056789.123, - "enum-field": 1, - "guid-field": "6566f9b4-5245-40de-890d-98b40a4ad656", - "int16-field": 32000, - "int32-field": 2000000000, - "int64-field": 9223372036854775807, - "j-token-array-field": [ - { - "my-field1": "George Washington", - "overridden-field2": null, - "MyField3": 216 - }, - { - "my-field1": "Thomas Jefferson", - "overridden-field2": false, - "MyField3": 631 - } - ], - "j-token-object-field": { - "my-field1": "Abraham Lincoln", - "overridden-field2": true, - "MyField3": 439 - }, - "j-token-string-field": "Andrew Jackson", - "nullable-boolean-field": true, - "nullable-byte-field": 253, - "nullable-date-time-field": "1776-07-04T00:00:00", - "nullable-date-time-offset-field": "1776-07-04T00:00:00.0000000-05:00", - "nullable-decimal-field": "1056789.123", - "nullable-double-field": 1056789.123, - "nullable-enum-field": 2, - "nullable-guid-field": "3d1fb81e-43ee-4d04-af91-c8a326341293", - "nullable-int16-field": 32000, - "nullable-int32-field": 2000000000, - "nullable-int64-field": 9223372036854775807, - "nullable-sbyte-field": 123, - "nullable-single-field": 1056789.13, - "nullable-uint16-field": 64000, - "nullable-uint32-field": 3000000000, - "nullable-uint64-field": 9223372036854775808, - "sbyte-field": 123, - "single-field": 1056789.13, - "string-field": "Some string 156", - "uint16-field": 64000, - "uint32-field": 3000000000, - "uint64-field": 9223372036854775808 - } - } - ] -} diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/ComputedId/Responses/Get_all_of_resource_with_computed_id_Response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/ComputedId/Responses/Get_all_of_resource_with_computed_id_Response.json deleted file mode 100644 index 73e17342..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/ComputedId/Responses/Get_all_of_resource_with_computed_id_Response.json +++ /dev/null @@ -1,130 +0,0 @@ -{ - "data": [ - { - "type": "language-user-links", - "id": "9000_401", - "attributes": { - "fluency-level": "Native" - }, - "relationships": { - "language": { - "links": { - "self": "https://www.example.com/language-user-links/9000_401/relationships/language", - "related": "https://www.example.com/language-user-links/9000_401/language" - } - }, - "user": { - "links": { - "self": "https://www.example.com/language-user-links/9000_401/relationships/user", - "related": "https://www.example.com/language-user-links/9000_401/user" - } - } - } - }, - { - "type": "language-user-links", - "id": "9001_401", - "attributes": { - "fluency-level": "Conversational" - }, - "relationships": { - "language": { - "links": { - "self": "https://www.example.com/language-user-links/9001_401/relationships/language", - "related": "https://www.example.com/language-user-links/9001_401/language" - } - }, - "user": { - "links": { - "self": "https://www.example.com/language-user-links/9001_401/relationships/user", - "related": "https://www.example.com/language-user-links/9001_401/user" - } - } - } - }, - { - "type": "language-user-links", - "id": "9001_402", - "attributes": { - "fluency-level": "Native" - }, - "relationships": { - "language": { - "links": { - "self": "https://www.example.com/language-user-links/9001_402/relationships/language", - "related": "https://www.example.com/language-user-links/9001_402/language" - } - }, - "user": { - "links": { - "self": "https://www.example.com/language-user-links/9001_402/relationships/user", - "related": "https://www.example.com/language-user-links/9001_402/user" - } - } - } - }, - { - "type": "language-user-links", - "id": "9002_401", - "attributes": { - "fluency-level": "Fluent" - }, - "relationships": { - "language": { - "links": { - "self": "https://www.example.com/language-user-links/9002_401/relationships/language", - "related": "https://www.example.com/language-user-links/9002_401/language" - } - }, - "user": { - "links": { - "self": "https://www.example.com/language-user-links/9002_401/relationships/user", - "related": "https://www.example.com/language-user-links/9002_401/user" - } - } - } - }, - { - "type": "language-user-links", - "id": "9002_403", - "attributes": { - "fluency-level": "Native" - }, - "relationships": { - "language": { - "links": { - "self": "https://www.example.com/language-user-links/9002_403/relationships/language", - "related": "https://www.example.com/language-user-links/9002_403/language" - } - }, - "user": { - "links": { - "self": "https://www.example.com/language-user-links/9002_403/relationships/user", - "related": "https://www.example.com/language-user-links/9002_403/user" - } - } - } - }, - { - "type": "language-user-links", - "id": "9003_404", - "attributes": { - "fluency-level": "Native" - }, - "relationships": { - "language": { - "links": { - "self": "https://www.example.com/language-user-links/9003_404/relationships/language", - "related": "https://www.example.com/language-user-links/9003_404/language" - } - }, - "user": { - "links": { - "self": "https://www.example.com/language-user-links/9003_404/relationships/user", - "related": "https://www.example.com/language-user-links/9003_404/user" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/ComputedId/Responses/Get_resource_with_computed_id_by_id_Response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/ComputedId/Responses/Get_resource_with_computed_id_by_id_Response.json deleted file mode 100644 index fde48b61..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/ComputedId/Responses/Get_resource_with_computed_id_by_id_Response.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "data": { - "type": "language-user-links", - "id": "9001_402", - "attributes": { - "fluency-level": "Native" - }, - "relationships": { - "language": { - "links": { - "self": "https://www.example.com/language-user-links/9001_402/relationships/language", - "related": "https://www.example.com/language-user-links/9001_402/language" - } - }, - "user": { - "links": { - "self": "https://www.example.com/language-user-links/9001_402/relationships/user", - "related": "https://www.example.com/language-user-links/9001_402/user" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Requests/PostID_with_client_provided_id_Request.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Requests/PostID_with_client_provided_id_Request.json deleted file mode 100644 index 41424e02..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Requests/PostID_with_client_provided_id_Request.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data": { - "type": "post-i-ds", - "id": "205", - "attributes": { - "title": "Added post", - "content": "Added post content", - "created": "2015-03-11T04:31:00+00:00" - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Requests/PostLongId_with_client_provided_id_Request.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Requests/PostLongId_with_client_provided_id_Request.json deleted file mode 100644 index b52fe5c4..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Requests/PostLongId_with_client_provided_id_Request.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data": { - "type": "post-long-ids", - "id": "205", - "attributes": { - "title": "Added post", - "content": "Added post content", - "created": "2015-03-11T04:31:00+00:00" - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Requests/Post_with_client_provided_id_Request.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Requests/Post_with_client_provided_id_Request.json deleted file mode 100644 index c49fe508..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Requests/Post_with_client_provided_id_Request.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "205", - "attributes": { - "title": "Added post", - "content": "Added post content", - "created": "2015-03-11T04:31:00+00:00" - }, - "relationships": { - "author": { - "data": { - "type": "users", - "id": "401" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Requests/Post_with_empty_id_Request.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Requests/Post_with_empty_id_Request.json deleted file mode 100644 index 8d2759bd..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Requests/Post_with_empty_id_Request.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "data": { - "type": "posts", - "attributes": { - "title": "New post", - "content": "The server generated my ID", - "created": "2015-04-13T12:09:00+03:00" - }, - "relationships": { - "author": { - "data": { - "type": "users", - "id": "401" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Responses/PostID_with_client_provided_id_Response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Responses/PostID_with_client_provided_id_Response.json deleted file mode 100644 index 7122e9e9..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Responses/PostID_with_client_provided_id_Response.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data": { - "type": "post-i-ds", - "id": "205", - "attributes": { - "content": "Added post content", - "created": "2015-03-11T04:31:00.0000000+00:00", - "title": "Added post" - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Responses/PostLongId_with_client_provided_id_Response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Responses/PostLongId_with_client_provided_id_Response.json deleted file mode 100644 index dc5ee0f8..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Responses/PostLongId_with_client_provided_id_Response.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data": { - "type": "post-long-ids", - "id": "205", - "attributes": { - "content": "Added post content", - "created": "2015-03-11T04:31:00.0000000+00:00", - "title": "Added post" - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Responses/Post_with_client_provided_id_Response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Responses/Post_with_client_provided_id_Response.json deleted file mode 100644 index a3050aaf..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Responses/Post_with_client_provided_id_Response.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "205", - "attributes": { - "content": "Added post content", - "created": "2015-03-11T04:31:00.0000000+00:00", - "title": "Added post" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/205/relationships/author", - "related": "https://www.example.com/posts/205/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/205/relationships/comments", - "related": "https://www.example.com/posts/205/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/205/relationships/tags", - "related": "https://www.example.com/posts/205/tags" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Responses/Post_with_empty_id_Response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Responses/Post_with_empty_id_Response.json deleted file mode 100644 index 8b7706da..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Responses/Post_with_empty_id_Response.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "230", - "attributes": { - "content": "The server generated my ID", - "created": "2015-04-13T12:09:00.0000000+03:00", - "title": "New post" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/230/relationships/author", - "related": "https://www.example.com/posts/230/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/230/relationships/comments", - "related": "https://www.example.com/posts/230/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/230/relationships/tags", - "related": "https://www.example.com/posts/230/tags" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Responses/Post_with_empty_id_and_include_author_Response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Responses/Post_with_empty_id_and_include_author_Response.json deleted file mode 100644 index f9996946..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/CreatingResources/Responses/Post_with_empty_id_and_include_author_Response.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "230", - "attributes": { - "content": "The server generated my ID", - "created": "2015-04-13T09:09:00.0000000+00:00", - "title": "New post" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/230/relationships/author", - "related": "https://www.example.com/posts/230/author" - }, - "data": { - "type": "users", - "id": "401" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/230/relationships/comments", - "related": "https://www.example.com/posts/230/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/230/relationships/tags", - "related": "https://www.example.com/posts/230/tags" - } - } - } - }, - "included": [ - { - "type": "users", - "id": "401", - "attributes": { - "first-name": "Alice", - "last-name": "Smith" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/401/relationships/comments", - "related": "https://www.example.com/users/401/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/401/relationships/posts", - "related": "https://www.example.com/users/401/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/401/relationships/user-groups", - "related": "https://www.example.com/users/401/user-groups" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Errors/Controller_action_throws_exception.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Errors/Controller_action_throws_exception.json deleted file mode 100644 index b5a6b45a..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Errors/Controller_action_throws_exception.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "500", - "title": "Unhandled exception", - "detail": "An unhandled exception was thrown while processing the request.", - "meta": { - "exceptionMessage": "Something bad happened!", - "stackTrace": "{{STACK_TRACE}}" - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Errors/Controller_does_not_exist.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Errors/Controller_does_not_exist.json deleted file mode 100644 index 69c2a9c3..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Errors/Controller_does_not_exist.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "404", - "title": "Resource not found", - "detail": "The resource you requested does not exist." - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/GetAllResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/GetAllResponse.json deleted file mode 100644 index 38ba54bc..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/GetAllResponse.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "data": [ - { - "type": "posts", - "id": "201", - "attributes": { - "content": "Post 1 content", - "created": "2015-01-31T14:00:00.0000000+00:00", - "title": "Post 1" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/201/relationships/author", - "related": "https://www.example.com/posts/201/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/201/relationships/comments", - "related": "https://www.example.com/posts/201/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/201/relationships/tags", - "related": "https://www.example.com/posts/201/tags" - } - } - } - }, - { - "type": "posts", - "id": "202", - "attributes": { - "content": "Post 2 content", - "created": "2015-02-05T08:10:00.0000000+00:00", - "title": "Post 2" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/202/relationships/author", - "related": "https://www.example.com/posts/202/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/202/relationships/comments", - "related": "https://www.example.com/posts/202/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/202/relationships/tags", - "related": "https://www.example.com/posts/202/tags" - } - } - } - }, - { - "type": "posts", - "id": "203", - "attributes": { - "content": "Post 3 content", - "created": "2015-02-07T11:11:00.0000000+00:00", - "title": "Post 3" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/203/relationships/author", - "related": "https://www.example.com/posts/203/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/203/relationships/comments", - "related": "https://www.example.com/posts/203/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/203/relationships/tags", - "related": "https://www.example.com/posts/203/tags" - } - } - } - }, - { - "type": "posts", - "id": "204", - "attributes": { - "content": "Post 4 content", - "created": "2015-02-08T06:59:00.0000000+00:00", - "title": "Post 4" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/204/relationships/author", - "related": "https://www.example.com/posts/204/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/204/relationships/comments", - "related": "https://www.example.com/posts/204/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/204/relationships/tags", - "related": "https://www.example.com/posts/204/tags" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/GetByIdResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/GetByIdResponse.json deleted file mode 100644 index f9067b51..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/GetByIdResponse.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "attributes": { - "content": "Post 2 content", - "created": "2015-02-05T08:10:00.0000000+00:00", - "title": "Post 2" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/202/relationships/author", - "related": "https://www.example.com/posts/202/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/202/relationships/comments", - "related": "https://www.example.com/posts/202/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/202/relationships/tags", - "related": "https://www.example.com/posts/202/tags" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/GetWithFilterResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/GetWithFilterResponse.json deleted file mode 100644 index 7a337c39..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/GetWithFilterResponse.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "data": [ - { - "type": "posts", - "id": "204", - "attributes": { - "content": "Post 4 content", - "created": "2015-02-08T06:59:00.0000000+00:00", - "title": "Post 4" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/204/relationships/author", - "related": "https://www.example.com/posts/204/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/204/relationships/comments", - "related": "https://www.example.com/posts/204/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/204/relationships/tags", - "related": "https://www.example.com/posts/204/tags" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_dasherized_resource.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_dasherized_resource.json deleted file mode 100644 index 23c46576..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_dasherized_resource.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "data": [ - { - "type": "user-groups", - "id": "501", - "attributes": { - "name": "Admin users" - }, - "relationships": { - "users": { - "links": { - "self": "https://www.example.com/user-groups/501/relationships/users", - "related": "https://www.example.com/user-groups/501/users" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_included_to_one_response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_included_to_one_response.json deleted file mode 100644 index 98fcd282..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_included_to_one_response.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "201", - "attributes": { - "content": "Post 1 content", - "created": "2015-01-31T14:00:00.0000000+00:00", - "title": "Post 1" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/201/relationships/author", - "related": "https://www.example.com/posts/201/author" - }, - "data": { - "type": "users", - "id": "401" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/201/relationships/comments", - "related": "https://www.example.com/posts/201/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/201/relationships/tags", - "related": "https://www.example.com/posts/201/tags" - } - } - } - }, - "included": [ - { - "type": "users", - "id": "401", - "attributes": { - "first-name": "Alice", - "last-name": "Smith" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/401/relationships/comments", - "related": "https://www.example.com/users/401/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/401/relationships/posts", - "related": "https://www.example.com/users/401/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/401/relationships/user-groups", - "related": "https://www.example.com/users/401/user-groups" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_resource_for_relationship_that_doesnt_exist.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_resource_for_relationship_that_doesnt_exist.json deleted file mode 100644 index 44e502d2..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_resource_for_relationship_that_doesnt_exist.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "404", - "title": "Resource not found", - "detail": "No relationship `bananas` exists for the resource type `posts`." - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_for_resource_that_doesnt_exist.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_for_resource_that_doesnt_exist.json deleted file mode 100644 index 3921d080..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_for_resource_that_doesnt_exist.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "404", - "title": "Resource not found", - "detail": "No resource of type `posts` exists with id `3000`." - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_include_external_response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_include_external_response.json deleted file mode 100644 index e8008645..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_include_external_response.json +++ /dev/null @@ -1,164 +0,0 @@ -{ - "data": [ - { - "type": "posts", - "id": "201", - "attributes": { - "content": "Post 1 content", - "created": "2015-01-31T14:00:00.0000000+00:00", - "title": "Post 1" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/201/relationships/author", - "related": "https://www.example.com/posts/201/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/201/relationships/comments", - "related": "https://www.example.com/posts/201/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/201/relationships/tags", - "related": "https://www.example.com/posts/201/tags" - }, - "data": [ - { - "type": "tags", - "id": "301" - }, - { - "type": "tags", - "id": "302" - } - ] - } - } - }, - { - "type": "posts", - "id": "202", - "attributes": { - "content": "Post 2 content", - "created": "2015-02-05T08:10:00.0000000+00:00", - "title": "Post 2" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/202/relationships/author", - "related": "https://www.example.com/posts/202/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/202/relationships/comments", - "related": "https://www.example.com/posts/202/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/202/relationships/tags", - "related": "https://www.example.com/posts/202/tags" - }, - "data": [ - { - "type": "tags", - "id": "302" - }, - { - "type": "tags", - "id": "303" - } - ] - } - } - }, - { - "type": "posts", - "id": "203", - "attributes": { - "content": "Post 3 content", - "created": "2015-02-07T11:11:00.0000000+00:00", - "title": "Post 3" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/203/relationships/author", - "related": "https://www.example.com/posts/203/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/203/relationships/comments", - "related": "https://www.example.com/posts/203/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/203/relationships/tags", - "related": "https://www.example.com/posts/203/tags" - }, - "data": [ - { - "type": "tags", - "id": "303" - } - ] - } - } - } - ], - "included": [ - { - "type": "tags", - "id": "301", - "attributes": { - "name": "Tag A" - }, - "relationships": { - "posts": { - "links": { - "self": "https://www.example.com/tags/301/relationships/posts", - "related": "https://www.example.com/tags/301/posts" - } - } - } - }, - { - "type": "tags", - "id": "302", - "attributes": { - "name": "Tag B" - }, - "relationships": { - "posts": { - "links": { - "self": "https://www.example.com/tags/302/relationships/posts", - "related": "https://www.example.com/tags/302/posts" - } - } - } - }, - { - "type": "tags", - "id": "303", - "attributes": { - "name": "Tag C" - }, - "relationships": { - "posts": { - "links": { - "self": "https://www.example.com/tags/303/relationships/posts", - "related": "https://www.example.com/tags/303/posts" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_include_response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_include_response.json deleted file mode 100644 index e1a01091..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_include_response.json +++ /dev/null @@ -1,140 +0,0 @@ -{ - "data": [ - { - "type": "comments", - "id": "101", - "attributes": { - "created": "2015-01-31T14:30:00.0000000+00:00", - "text": "Comment 1" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/comments/101/relationships/author", - "related": "https://www.example.com/comments/101/author" - }, - "data": { - "type": "users", - "id": "403" - } - }, - "post": { - "links": { - "self": "https://www.example.com/comments/101/relationships/post", - "related": "https://www.example.com/comments/101/post" - } - } - } - }, - { - "type": "comments", - "id": "102", - "attributes": { - "created": "2015-01-31T14:35:00.0000000+00:00", - "text": "Comment 2" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/comments/102/relationships/author", - "related": "https://www.example.com/comments/102/author" - }, - "data": { - "type": "users", - "id": "402" - } - }, - "post": { - "links": { - "self": "https://www.example.com/comments/102/relationships/post", - "related": "https://www.example.com/comments/102/post" - } - } - } - }, - { - "type": "comments", - "id": "103", - "attributes": { - "created": "2015-01-31T14:41:00.0000000+00:00", - "text": "Comment 3" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/comments/103/relationships/author", - "related": "https://www.example.com/comments/103/author" - }, - "data": { - "type": "users", - "id": "403" - } - }, - "post": { - "links": { - "self": "https://www.example.com/comments/103/relationships/post", - "related": "https://www.example.com/comments/103/post" - } - } - } - } - ], - "included": [ - { - "type": "users", - "id": "403", - "attributes": { - "first-name": "Charlie", - "last-name": "Michaels" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/403/relationships/comments", - "related": "https://www.example.com/users/403/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/403/relationships/posts", - "related": "https://www.example.com/users/403/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/403/relationships/user-groups", - "related": "https://www.example.com/users/403/user-groups" - } - } - } - }, - { - "type": "users", - "id": "402", - "attributes": { - "first-name": "Bob", - "last-name": "Jones" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/402/relationships/comments", - "related": "https://www.example.com/users/402/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/402/relationships/posts", - "related": "https://www.example.com/users/402/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/402/relationships/user-groups", - "related": "https://www.example.com/users/402/user-groups" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_integer_key_response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_integer_key_response.json deleted file mode 100644 index f99bab69..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_integer_key_response.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "data": [ - { - "type": "children", - "id": "7501", - "attributes": { - "child-description": "Child 2 Description" - }, - "relationships": { - "master": { - "links": { - "self": "https://www.example.com/children/7501/relationships/master", - "related": "https://www.example.com/children/7501/master" - } - } - } - }, - { - "type": "children", - "id": "7502", - "attributes": { - "child-description": "Child 3 Description" - }, - "relationships": { - "master": { - "links": { - "self": "https://www.example.com/children/7502/relationships/master", - "related": "https://www.example.com/children/7502/master" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_response.json deleted file mode 100644 index 020de840..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_many_response.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "data": [ - { - "type": "comments", - "id": "101", - "attributes": { - "created": "2015-01-31T14:30:00.0000000+00:00", - "text": "Comment 1" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/comments/101/relationships/author", - "related": "https://www.example.com/comments/101/author" - } - }, - "post": { - "links": { - "self": "https://www.example.com/comments/101/relationships/post", - "related": "https://www.example.com/comments/101/post" - } - } - } - }, - { - "type": "comments", - "id": "102", - "attributes": { - "created": "2015-01-31T14:35:00.0000000+00:00", - "text": "Comment 2" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/comments/102/relationships/author", - "related": "https://www.example.com/comments/102/author" - } - }, - "post": { - "links": { - "self": "https://www.example.com/comments/102/relationships/post", - "related": "https://www.example.com/comments/102/post" - } - } - } - }, - { - "type": "comments", - "id": "103", - "attributes": { - "created": "2015-01-31T14:41:00.0000000+00:00", - "text": "Comment 3" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/comments/103/relationships/author", - "related": "https://www.example.com/comments/103/author" - } - }, - "post": { - "links": { - "self": "https://www.example.com/comments/103/relationships/post", - "related": "https://www.example.com/comments/103/post" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_one_for_resource_that_doesnt_exist.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_one_for_resource_that_doesnt_exist.json deleted file mode 100644 index 3921d080..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_one_for_resource_that_doesnt_exist.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "404", - "title": "Resource not found", - "detail": "No resource of type `posts` exists with id `3000`." - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_one_response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_one_response.json deleted file mode 100644 index 504bb96d..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_one_response.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "data": { - "type": "users", - "id": "401", - "attributes": { - "first-name": "Alice", - "last-name": "Smith" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/401/relationships/comments", - "related": "https://www.example.com/users/401/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/401/relationships/posts", - "related": "https://www.example.com/users/401/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/401/relationships/user-groups", - "related": "https://www.example.com/users/401/user-groups" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_one_where_it_is_null.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_one_where_it_is_null.json deleted file mode 100644 index fd4493f0..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_related_to_one_where_it_is_null.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "data": null -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_resource_by_id_that_doesnt_exist.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_resource_by_id_that_doesnt_exist.json deleted file mode 100644 index 3921d080..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/FetchingResources/Get_resource_by_id_that_doesnt_exist.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "404", - "title": "Resource not found", - "detail": "No resource of type `posts` exists with id `3000`." - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Heterogeneous/Responses/GetSearchResultsResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Heterogeneous/Responses/GetSearchResultsResponse.json deleted file mode 100644 index 5d153ee6..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Heterogeneous/Responses/GetSearchResultsResponse.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "data": [ - { - "type": "posts", - "id": "201", - "attributes": { - "content": "Post 1 content", - "created": "2015-01-31T14:00:00.0000000+00:00", - "title": "Post 1" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/201/relationships/author", - "related": "https://www.example.com/posts/201/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/201/relationships/comments", - "related": "https://www.example.com/posts/201/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/201/relationships/tags", - "related": "https://www.example.com/posts/201/tags" - } - } - } - }, - { - "type": "comments", - "id": "101", - "attributes": { - "created": "2015-01-31T14:30:00.0000000+00:00", - "text": "Comment 1" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/comments/101/relationships/author", - "related": "https://www.example.com/comments/101/author" - } - }, - "post": { - "links": { - "self": "https://www.example.com/comments/101/relationships/post", - "related": "https://www.example.com/comments/101/post" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Mapped/Responses/Get_all.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Mapped/Responses/Get_all.json deleted file mode 100644 index 07c6389e..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Mapped/Responses/Get_all.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "data": [ - { - "type": "starships", - "id": "NCC-1701", - "attributes": { - "name": "USS Enterprise", - "starship-class": "Constitution" - }, - "relationships": { - "officers": { - "links": { - "self": "https://www.example.com/starships/NCC-1701/relationships/officers", - "related": "https://www.example.com/starships/NCC-1701/officers" - } - }, - "ship-counselor": { - "links": { - "self": "https://www.example.com/starships/NCC-1701/relationships/ship-counselor", - "related": "https://www.example.com/starships/NCC-1701/ship-counselor" - } - } - } - }, - { - "type": "starships", - "id": "NCC-1701-D", - "attributes": { - "name": "USS Enterprise", - "starship-class": "Galaxy" - }, - "relationships": { - "officers": { - "links": { - "self": "https://www.example.com/starships/NCC-1701-D/relationships/officers", - "related": "https://www.example.com/starships/NCC-1701-D/officers" - } - }, - "ship-counselor": { - "links": { - "self": "https://www.example.com/starships/NCC-1701-D/relationships/ship-counselor", - "related": "https://www.example.com/starships/NCC-1701-D/ship-counselor" - } - } - } - }, - { - "type": "starships", - "id": "NCC-74656", - "attributes": { - "name": "USS Voyager", - "starship-class": "Intrepid" - }, - "relationships": { - "officers": { - "links": { - "self": "https://www.example.com/starships/NCC-74656/relationships/officers", - "related": "https://www.example.com/starships/NCC-74656/officers" - } - }, - "ship-counselor": { - "links": { - "self": "https://www.example.com/starships/NCC-74656/relationships/ship-counselor", - "related": "https://www.example.com/starships/NCC-74656/ship-counselor" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Mapped/Responses/Get_by_id.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Mapped/Responses/Get_by_id.json deleted file mode 100644 index d891b913..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Mapped/Responses/Get_by_id.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "data": { - "type": "starships", - "id": "NCC-1701", - "attributes": { - "name": "USS Enterprise", - "starship-class": "Constitution" - }, - "relationships": { - "officers": { - "links": { - "self": "https://www.example.com/starships/NCC-1701/relationships/officers", - "related": "https://www.example.com/starships/NCC-1701/officers" - } - }, - "ship-counselor": { - "links": { - "self": "https://www.example.com/starships/NCC-1701/relationships/ship-counselor", - "related": "https://www.example.com/starships/NCC-1701/ship-counselor" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Mapped/Responses/Get_related_to_many_response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Mapped/Responses/Get_related_to_many_response.json deleted file mode 100644 index c1221a27..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Mapped/Responses/Get_related_to_many_response.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "data": [ - { - "type": "starship-officers", - "id": "NCC-1701-D_12010", - "attributes": { - "name": "Jean-Luc Picard", - "position": "Commanding Officer", - "rank": "Captain" - }, - "relationships": { - "current-ship": { - "links": { - "self": "https://www.example.com/starship-officers/NCC-1701-D_12010/relationships/current-ship", - "related": "https://www.example.com/starship-officers/NCC-1701-D_12010/current-ship" - } - } - } - }, - { - "type": "starship-officers", - "id": "NCC-1701-D_12011", - "attributes": { - "name": "William T. Riker", - "position": "First Officer", - "rank": "Commander" - }, - "relationships": { - "current-ship": { - "links": { - "self": "https://www.example.com/starship-officers/NCC-1701-D_12011/relationships/current-ship", - "related": "https://www.example.com/starship-officers/NCC-1701-D_12011/current-ship" - } - } - } - }, - { - "type": "starship-officers", - "id": "NCC-1701-D_12012", - "attributes": { - "name": "Data", - "position": "Second Officer", - "rank": "Lt. Commander" - }, - "relationships": { - "current-ship": { - "links": { - "self": "https://www.example.com/starship-officers/NCC-1701-D_12012/relationships/current-ship", - "related": "https://www.example.com/starship-officers/NCC-1701-D_12012/current-ship" - } - } - } - }, - { - "type": "starship-officers", - "id": "NCC-1701-D_12013", - "attributes": { - "name": "Deanna Troi", - "position": "Ship's Counselor", - "rank": "Lt. Commander" - }, - "relationships": { - "current-ship": { - "links": { - "self": "https://www.example.com/starship-officers/NCC-1701-D_12013/relationships/current-ship", - "related": "https://www.example.com/starship-officers/NCC-1701-D_12013/current-ship" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Mapped/Responses/Get_related_to_one_response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Mapped/Responses/Get_related_to_one_response.json deleted file mode 100644 index f311d73c..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Mapped/Responses/Get_related_to_one_response.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "data": { - "type": "starship-officers", - "id": "NCC-1701-D_12013", - "attributes": { - "name": "Deanna Troi", - "position": "Ship's Counselor", - "rank": "Lt. Commander" - }, - "relationships": { - "current-ship": { - "links": { - "self": "https://www.example.com/starship-officers/NCC-1701-D_12013/relationships/current-ship", - "related": "https://www.example.com/starship-officers/NCC-1701-D_12013/current-ship" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Mapped/Responses/Get_resource_by_id_that_doesnt_exist.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Mapped/Responses/Get_resource_by_id_that_doesnt_exist.json deleted file mode 100644 index 57931946..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Mapped/Responses/Get_resource_by_id_that_doesnt_exist.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "404", - "title": "Resource not found", - "detail": "No record exists with type `starships` and ID `NCC-asdf`." - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Pagination/GetAllResponsePaged-2-2.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Pagination/GetAllResponsePaged-2-2.json deleted file mode 100644 index 7bf2f5ba..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Pagination/GetAllResponsePaged-2-2.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "meta": { - "total-pages": 2, - "total-count": 4 - }, - "data": [ - { - "type": "posts", - "id": "203", - "attributes": { - "content": "Post 3 content", - "created": "2015-02-07T11:11:00.0000000+00:00", - "title": "Post 3" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/203/relationships/author", - "related": "https://www.example.com/posts/203/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/203/relationships/comments", - "related": "https://www.example.com/posts/203/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/203/relationships/tags", - "related": "https://www.example.com/posts/203/tags" - } - } - } - }, - { - "type": "posts", - "id": "204", - "attributes": { - "content": "Post 4 content", - "created": "2015-02-08T06:59:00.0000000+00:00", - "title": "Post 4" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/204/relationships/author", - "related": "https://www.example.com/posts/204/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/204/relationships/comments", - "related": "https://www.example.com/posts/204/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/204/relationships/tags", - "related": "https://www.example.com/posts/204/tags" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Pagination/GetFilterPaged-1-2-sorted-desc.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Pagination/GetFilterPaged-1-2-sorted-desc.json deleted file mode 100644 index b65cea48..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Pagination/GetFilterPaged-1-2-sorted-desc.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "meta": { - "total-pages": 2, - "total-count": 3 - }, - "data": [ - { - "type": "users", - "id": "410", - "attributes": { - "first-name": "Sally", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/410/relationships/comments", - "related": "https://www.example.com/users/410/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/410/relationships/posts", - "related": "https://www.example.com/users/410/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/410/relationships/user-groups", - "related": "https://www.example.com/users/410/user-groups" - } - } - } - }, - { - "type": "users", - "id": "406", - "attributes": { - "first-name": "Ed", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/406/relationships/comments", - "related": "https://www.example.com/users/406/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/406/relationships/posts", - "related": "https://www.example.com/users/406/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/406/relationships/user-groups", - "related": "https://www.example.com/users/406/user-groups" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Pagination/GetFilterPaged-1-2-sorted.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Pagination/GetFilterPaged-1-2-sorted.json deleted file mode 100644 index ee562655..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Pagination/GetFilterPaged-1-2-sorted.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "meta": { - "total-pages": 2, - "total-count": 3 - }, - "data": [ - { - "type": "users", - "id": "409", - "attributes": { - "first-name": "Charlie", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/409/relationships/comments", - "related": "https://www.example.com/users/409/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/409/relationships/posts", - "related": "https://www.example.com/users/409/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/409/relationships/user-groups", - "related": "https://www.example.com/users/409/user-groups" - } - } - } - }, - { - "type": "users", - "id": "406", - "attributes": { - "first-name": "Ed", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/406/relationships/comments", - "related": "https://www.example.com/users/406/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/406/relationships/posts", - "related": "https://www.example.com/users/406/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/406/relationships/user-groups", - "related": "https://www.example.com/users/406/user-groups" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Pagination/GetFilterPaged-2-1.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Pagination/GetFilterPaged-2-1.json deleted file mode 100644 index 16e92908..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Pagination/GetFilterPaged-2-1.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "meta": { - "total-pages": 3, - "total-count": 3 - }, - "data": [ - { - "type": "users", - "id": "409", - "attributes": { - "first-name": "Charlie", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/409/relationships/comments", - "related": "https://www.example.com/users/409/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/409/relationships/posts", - "related": "https://www.example.com/users/409/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/409/relationships/user-groups", - "related": "https://www.example.com/users/409/user-groups" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedAscendingResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedAscendingResponse.json deleted file mode 100644 index 9355b97e..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedAscendingResponse.json +++ /dev/null @@ -1,284 +0,0 @@ -{ - "data": [ - { - "type": "users", - "id": "401", - "attributes": { - "first-name": "Alice", - "last-name": "Smith" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/401/relationships/comments", - "related": "https://www.example.com/users/401/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/401/relationships/posts", - "related": "https://www.example.com/users/401/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/401/relationships/user-groups", - "related": "https://www.example.com/users/401/user-groups" - } - } - } - }, - { - "type": "users", - "id": "402", - "attributes": { - "first-name": "Bob", - "last-name": "Jones" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/402/relationships/comments", - "related": "https://www.example.com/users/402/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/402/relationships/posts", - "related": "https://www.example.com/users/402/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/402/relationships/user-groups", - "related": "https://www.example.com/users/402/user-groups" - } - } - } - }, - { - "type": "users", - "id": "403", - "attributes": { - "first-name": "Charlie", - "last-name": "Michaels" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/403/relationships/comments", - "related": "https://www.example.com/users/403/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/403/relationships/posts", - "related": "https://www.example.com/users/403/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/403/relationships/user-groups", - "related": "https://www.example.com/users/403/user-groups" - } - } - } - }, - { - "type": "users", - "id": "409", - "attributes": { - "first-name": "Charlie", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/409/relationships/comments", - "related": "https://www.example.com/users/409/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/409/relationships/posts", - "related": "https://www.example.com/users/409/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/409/relationships/user-groups", - "related": "https://www.example.com/users/409/user-groups" - } - } - } - }, - { - "type": "users", - "id": "406", - "attributes": { - "first-name": "Ed", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/406/relationships/comments", - "related": "https://www.example.com/users/406/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/406/relationships/posts", - "related": "https://www.example.com/users/406/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/406/relationships/user-groups", - "related": "https://www.example.com/users/406/user-groups" - } - } - } - }, - { - "type": "users", - "id": "405", - "attributes": { - "first-name": "Michelle", - "last-name": "Johnson" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/405/relationships/comments", - "related": "https://www.example.com/users/405/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/405/relationships/posts", - "related": "https://www.example.com/users/405/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/405/relationships/user-groups", - "related": "https://www.example.com/users/405/user-groups" - } - } - } - }, - { - "type": "users", - "id": "408", - "attributes": { - "first-name": "Pat", - "last-name": "Morgan" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/408/relationships/comments", - "related": "https://www.example.com/users/408/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/408/relationships/posts", - "related": "https://www.example.com/users/408/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/408/relationships/user-groups", - "related": "https://www.example.com/users/408/user-groups" - } - } - } - }, - { - "type": "users", - "id": "404", - "attributes": { - "first-name": "Richard", - "last-name": "Smith" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/404/relationships/comments", - "related": "https://www.example.com/users/404/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/404/relationships/posts", - "related": "https://www.example.com/users/404/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/404/relationships/user-groups", - "related": "https://www.example.com/users/404/user-groups" - } - } - } - }, - { - "type": "users", - "id": "410", - "attributes": { - "first-name": "Sally", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/410/relationships/comments", - "related": "https://www.example.com/users/410/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/410/relationships/posts", - "related": "https://www.example.com/users/410/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/410/relationships/user-groups", - "related": "https://www.example.com/users/410/user-groups" - } - } - } - }, - { - "type": "users", - "id": "407", - "attributes": { - "first-name": "Thomas", - "last-name": "Potter" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/407/relationships/comments", - "related": "https://www.example.com/users/407/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/407/relationships/posts", - "related": "https://www.example.com/users/407/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/407/relationships/user-groups", - "related": "https://www.example.com/users/407/user-groups" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedByMixedDirectionResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedByMixedDirectionResponse.json deleted file mode 100644 index 34d2cff4..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedByMixedDirectionResponse.json +++ /dev/null @@ -1,284 +0,0 @@ -{ - "data": [ - { - "type": "users", - "id": "410", - "attributes": { - "first-name": "Sally", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/410/relationships/comments", - "related": "https://www.example.com/users/410/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/410/relationships/posts", - "related": "https://www.example.com/users/410/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/410/relationships/user-groups", - "related": "https://www.example.com/users/410/user-groups" - } - } - } - }, - { - "type": "users", - "id": "406", - "attributes": { - "first-name": "Ed", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/406/relationships/comments", - "related": "https://www.example.com/users/406/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/406/relationships/posts", - "related": "https://www.example.com/users/406/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/406/relationships/user-groups", - "related": "https://www.example.com/users/406/user-groups" - } - } - } - }, - { - "type": "users", - "id": "409", - "attributes": { - "first-name": "Charlie", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/409/relationships/comments", - "related": "https://www.example.com/users/409/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/409/relationships/posts", - "related": "https://www.example.com/users/409/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/409/relationships/user-groups", - "related": "https://www.example.com/users/409/user-groups" - } - } - } - }, - { - "type": "users", - "id": "405", - "attributes": { - "first-name": "Michelle", - "last-name": "Johnson" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/405/relationships/comments", - "related": "https://www.example.com/users/405/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/405/relationships/posts", - "related": "https://www.example.com/users/405/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/405/relationships/user-groups", - "related": "https://www.example.com/users/405/user-groups" - } - } - } - }, - { - "type": "users", - "id": "402", - "attributes": { - "first-name": "Bob", - "last-name": "Jones" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/402/relationships/comments", - "related": "https://www.example.com/users/402/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/402/relationships/posts", - "related": "https://www.example.com/users/402/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/402/relationships/user-groups", - "related": "https://www.example.com/users/402/user-groups" - } - } - } - }, - { - "type": "users", - "id": "403", - "attributes": { - "first-name": "Charlie", - "last-name": "Michaels" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/403/relationships/comments", - "related": "https://www.example.com/users/403/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/403/relationships/posts", - "related": "https://www.example.com/users/403/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/403/relationships/user-groups", - "related": "https://www.example.com/users/403/user-groups" - } - } - } - }, - { - "type": "users", - "id": "408", - "attributes": { - "first-name": "Pat", - "last-name": "Morgan" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/408/relationships/comments", - "related": "https://www.example.com/users/408/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/408/relationships/posts", - "related": "https://www.example.com/users/408/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/408/relationships/user-groups", - "related": "https://www.example.com/users/408/user-groups" - } - } - } - }, - { - "type": "users", - "id": "407", - "attributes": { - "first-name": "Thomas", - "last-name": "Potter" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/407/relationships/comments", - "related": "https://www.example.com/users/407/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/407/relationships/posts", - "related": "https://www.example.com/users/407/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/407/relationships/user-groups", - "related": "https://www.example.com/users/407/user-groups" - } - } - } - }, - { - "type": "users", - "id": "404", - "attributes": { - "first-name": "Richard", - "last-name": "Smith" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/404/relationships/comments", - "related": "https://www.example.com/users/404/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/404/relationships/posts", - "related": "https://www.example.com/users/404/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/404/relationships/user-groups", - "related": "https://www.example.com/users/404/user-groups" - } - } - } - }, - { - "type": "users", - "id": "401", - "attributes": { - "first-name": "Alice", - "last-name": "Smith" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/401/relationships/comments", - "related": "https://www.example.com/users/401/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/401/relationships/posts", - "related": "https://www.example.com/users/401/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/401/relationships/user-groups", - "related": "https://www.example.com/users/401/user-groups" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedByMultipleAscendingResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedByMultipleAscendingResponse.json deleted file mode 100644 index bb1e4fbe..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedByMultipleAscendingResponse.json +++ /dev/null @@ -1,284 +0,0 @@ -{ - "data": [ - { - "type": "users", - "id": "409", - "attributes": { - "first-name": "Charlie", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/409/relationships/comments", - "related": "https://www.example.com/users/409/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/409/relationships/posts", - "related": "https://www.example.com/users/409/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/409/relationships/user-groups", - "related": "https://www.example.com/users/409/user-groups" - } - } - } - }, - { - "type": "users", - "id": "406", - "attributes": { - "first-name": "Ed", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/406/relationships/comments", - "related": "https://www.example.com/users/406/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/406/relationships/posts", - "related": "https://www.example.com/users/406/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/406/relationships/user-groups", - "related": "https://www.example.com/users/406/user-groups" - } - } - } - }, - { - "type": "users", - "id": "410", - "attributes": { - "first-name": "Sally", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/410/relationships/comments", - "related": "https://www.example.com/users/410/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/410/relationships/posts", - "related": "https://www.example.com/users/410/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/410/relationships/user-groups", - "related": "https://www.example.com/users/410/user-groups" - } - } - } - }, - { - "type": "users", - "id": "405", - "attributes": { - "first-name": "Michelle", - "last-name": "Johnson" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/405/relationships/comments", - "related": "https://www.example.com/users/405/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/405/relationships/posts", - "related": "https://www.example.com/users/405/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/405/relationships/user-groups", - "related": "https://www.example.com/users/405/user-groups" - } - } - } - }, - { - "type": "users", - "id": "402", - "attributes": { - "first-name": "Bob", - "last-name": "Jones" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/402/relationships/comments", - "related": "https://www.example.com/users/402/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/402/relationships/posts", - "related": "https://www.example.com/users/402/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/402/relationships/user-groups", - "related": "https://www.example.com/users/402/user-groups" - } - } - } - }, - { - "type": "users", - "id": "403", - "attributes": { - "first-name": "Charlie", - "last-name": "Michaels" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/403/relationships/comments", - "related": "https://www.example.com/users/403/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/403/relationships/posts", - "related": "https://www.example.com/users/403/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/403/relationships/user-groups", - "related": "https://www.example.com/users/403/user-groups" - } - } - } - }, - { - "type": "users", - "id": "408", - "attributes": { - "first-name": "Pat", - "last-name": "Morgan" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/408/relationships/comments", - "related": "https://www.example.com/users/408/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/408/relationships/posts", - "related": "https://www.example.com/users/408/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/408/relationships/user-groups", - "related": "https://www.example.com/users/408/user-groups" - } - } - } - }, - { - "type": "users", - "id": "407", - "attributes": { - "first-name": "Thomas", - "last-name": "Potter" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/407/relationships/comments", - "related": "https://www.example.com/users/407/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/407/relationships/posts", - "related": "https://www.example.com/users/407/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/407/relationships/user-groups", - "related": "https://www.example.com/users/407/user-groups" - } - } - } - }, - { - "type": "users", - "id": "401", - "attributes": { - "first-name": "Alice", - "last-name": "Smith" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/401/relationships/comments", - "related": "https://www.example.com/users/401/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/401/relationships/posts", - "related": "https://www.example.com/users/401/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/401/relationships/user-groups", - "related": "https://www.example.com/users/401/user-groups" - } - } - } - }, - { - "type": "users", - "id": "404", - "attributes": { - "first-name": "Richard", - "last-name": "Smith" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/404/relationships/comments", - "related": "https://www.example.com/users/404/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/404/relationships/posts", - "related": "https://www.example.com/users/404/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/404/relationships/user-groups", - "related": "https://www.example.com/users/404/user-groups" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedByMultipleDescendingResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedByMultipleDescendingResponse.json deleted file mode 100644 index c56db237..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedByMultipleDescendingResponse.json +++ /dev/null @@ -1,284 +0,0 @@ -{ - "data": [ - { - "type": "users", - "id": "404", - "attributes": { - "first-name": "Richard", - "last-name": "Smith" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/404/relationships/comments", - "related": "https://www.example.com/users/404/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/404/relationships/posts", - "related": "https://www.example.com/users/404/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/404/relationships/user-groups", - "related": "https://www.example.com/users/404/user-groups" - } - } - } - }, - { - "type": "users", - "id": "401", - "attributes": { - "first-name": "Alice", - "last-name": "Smith" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/401/relationships/comments", - "related": "https://www.example.com/users/401/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/401/relationships/posts", - "related": "https://www.example.com/users/401/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/401/relationships/user-groups", - "related": "https://www.example.com/users/401/user-groups" - } - } - } - }, - { - "type": "users", - "id": "407", - "attributes": { - "first-name": "Thomas", - "last-name": "Potter" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/407/relationships/comments", - "related": "https://www.example.com/users/407/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/407/relationships/posts", - "related": "https://www.example.com/users/407/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/407/relationships/user-groups", - "related": "https://www.example.com/users/407/user-groups" - } - } - } - }, - { - "type": "users", - "id": "408", - "attributes": { - "first-name": "Pat", - "last-name": "Morgan" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/408/relationships/comments", - "related": "https://www.example.com/users/408/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/408/relationships/posts", - "related": "https://www.example.com/users/408/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/408/relationships/user-groups", - "related": "https://www.example.com/users/408/user-groups" - } - } - } - }, - { - "type": "users", - "id": "403", - "attributes": { - "first-name": "Charlie", - "last-name": "Michaels" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/403/relationships/comments", - "related": "https://www.example.com/users/403/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/403/relationships/posts", - "related": "https://www.example.com/users/403/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/403/relationships/user-groups", - "related": "https://www.example.com/users/403/user-groups" - } - } - } - }, - { - "type": "users", - "id": "402", - "attributes": { - "first-name": "Bob", - "last-name": "Jones" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/402/relationships/comments", - "related": "https://www.example.com/users/402/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/402/relationships/posts", - "related": "https://www.example.com/users/402/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/402/relationships/user-groups", - "related": "https://www.example.com/users/402/user-groups" - } - } - } - }, - { - "type": "users", - "id": "405", - "attributes": { - "first-name": "Michelle", - "last-name": "Johnson" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/405/relationships/comments", - "related": "https://www.example.com/users/405/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/405/relationships/posts", - "related": "https://www.example.com/users/405/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/405/relationships/user-groups", - "related": "https://www.example.com/users/405/user-groups" - } - } - } - }, - { - "type": "users", - "id": "410", - "attributes": { - "first-name": "Sally", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/410/relationships/comments", - "related": "https://www.example.com/users/410/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/410/relationships/posts", - "related": "https://www.example.com/users/410/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/410/relationships/user-groups", - "related": "https://www.example.com/users/410/user-groups" - } - } - } - }, - { - "type": "users", - "id": "406", - "attributes": { - "first-name": "Ed", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/406/relationships/comments", - "related": "https://www.example.com/users/406/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/406/relationships/posts", - "related": "https://www.example.com/users/406/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/406/relationships/user-groups", - "related": "https://www.example.com/users/406/user-groups" - } - } - } - }, - { - "type": "users", - "id": "409", - "attributes": { - "first-name": "Charlie", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/409/relationships/comments", - "related": "https://www.example.com/users/409/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/409/relationships/posts", - "related": "https://www.example.com/users/409/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/409/relationships/user-groups", - "related": "https://www.example.com/users/409/user-groups" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedBySameColumnTwiceResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedBySameColumnTwiceResponse.json deleted file mode 100644 index a3541ef0..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedBySameColumnTwiceResponse.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "400", - "title": "Attribute specified more than once", - "detail": "The attribute \"first-name\" was specified more than once.", - "source": { - "parameter": "sort" - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedByUnknownColumnResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedByUnknownColumnResponse.json deleted file mode 100644 index 5884cc7a..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedByUnknownColumnResponse.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "400", - "title": "Attribute not found", - "detail": "The attribute \"foobar\" does not exist on type \"users\".", - "source": { - "parameter": "sort" - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedDescendingResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedDescendingResponse.json deleted file mode 100644 index aa6cd74b..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/Sorting/Responses/GetSortedDescendingResponse.json +++ /dev/null @@ -1,284 +0,0 @@ -{ - "data": [ - { - "type": "users", - "id": "407", - "attributes": { - "first-name": "Thomas", - "last-name": "Potter" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/407/relationships/comments", - "related": "https://www.example.com/users/407/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/407/relationships/posts", - "related": "https://www.example.com/users/407/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/407/relationships/user-groups", - "related": "https://www.example.com/users/407/user-groups" - } - } - } - }, - { - "type": "users", - "id": "410", - "attributes": { - "first-name": "Sally", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/410/relationships/comments", - "related": "https://www.example.com/users/410/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/410/relationships/posts", - "related": "https://www.example.com/users/410/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/410/relationships/user-groups", - "related": "https://www.example.com/users/410/user-groups" - } - } - } - }, - { - "type": "users", - "id": "404", - "attributes": { - "first-name": "Richard", - "last-name": "Smith" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/404/relationships/comments", - "related": "https://www.example.com/users/404/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/404/relationships/posts", - "related": "https://www.example.com/users/404/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/404/relationships/user-groups", - "related": "https://www.example.com/users/404/user-groups" - } - } - } - }, - { - "type": "users", - "id": "408", - "attributes": { - "first-name": "Pat", - "last-name": "Morgan" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/408/relationships/comments", - "related": "https://www.example.com/users/408/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/408/relationships/posts", - "related": "https://www.example.com/users/408/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/408/relationships/user-groups", - "related": "https://www.example.com/users/408/user-groups" - } - } - } - }, - { - "type": "users", - "id": "405", - "attributes": { - "first-name": "Michelle", - "last-name": "Johnson" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/405/relationships/comments", - "related": "https://www.example.com/users/405/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/405/relationships/posts", - "related": "https://www.example.com/users/405/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/405/relationships/user-groups", - "related": "https://www.example.com/users/405/user-groups" - } - } - } - }, - { - "type": "users", - "id": "406", - "attributes": { - "first-name": "Ed", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/406/relationships/comments", - "related": "https://www.example.com/users/406/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/406/relationships/posts", - "related": "https://www.example.com/users/406/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/406/relationships/user-groups", - "related": "https://www.example.com/users/406/user-groups" - } - } - } - }, - { - "type": "users", - "id": "403", - "attributes": { - "first-name": "Charlie", - "last-name": "Michaels" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/403/relationships/comments", - "related": "https://www.example.com/users/403/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/403/relationships/posts", - "related": "https://www.example.com/users/403/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/403/relationships/user-groups", - "related": "https://www.example.com/users/403/user-groups" - } - } - } - }, - { - "type": "users", - "id": "409", - "attributes": { - "first-name": "Charlie", - "last-name": "Burns" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/409/relationships/comments", - "related": "https://www.example.com/users/409/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/409/relationships/posts", - "related": "https://www.example.com/users/409/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/409/relationships/user-groups", - "related": "https://www.example.com/users/409/user-groups" - } - } - } - }, - { - "type": "users", - "id": "402", - "attributes": { - "first-name": "Bob", - "last-name": "Jones" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/402/relationships/comments", - "related": "https://www.example.com/users/402/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/402/relationships/posts", - "related": "https://www.example.com/users/402/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/402/relationships/user-groups", - "related": "https://www.example.com/users/402/user-groups" - } - } - } - }, - { - "type": "users", - "id": "401", - "attributes": { - "first-name": "Alice", - "last-name": "Smith" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/401/relationships/comments", - "related": "https://www.example.com/users/401/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/401/relationships/posts", - "related": "https://www.example.com/users/401/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/401/relationships/user-groups", - "related": "https://www.example.com/users/401/user-groups" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithArrayForToOneLinkageRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithArrayForToOneLinkageRequest.json deleted file mode 100644 index d77552d2..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithArrayForToOneLinkageRequest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "author": { - "data": [ { "type": "users", "id": "403" } ] - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithArrayRelationshipValueRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithArrayRelationshipValueRequest.json deleted file mode 100644 index 7835ed54..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithArrayRelationshipValueRequest.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "tags": ["301"] - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithAttributeUpdateRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithAttributeUpdateRequest.json deleted file mode 100644 index 4a0636e6..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithAttributeUpdateRequest.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "attributes": { - "title": "New post title" - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithAttributeUpdateRequestID.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithAttributeUpdateRequestID.json deleted file mode 100644 index ac7fbb4b..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithAttributeUpdateRequestID.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "data": { - "type": "post-i-ds", - "id": "202", - "attributes": { - "title": "New post title" - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithAttributeUpdateRequestLongId.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithAttributeUpdateRequestLongId.json deleted file mode 100644 index 7358d7a8..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithAttributeUpdateRequestLongId.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "data": { - "type": "post-long-ids", - "id": "202", - "attributes": { - "title": "New post title" - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithMissingToManyLinkageRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithMissingToManyLinkageRequest.json deleted file mode 100644 index 417fe5a3..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithMissingToManyLinkageRequest.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "tags": { - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithMissingToOneLinkageRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithMissingToOneLinkageRequest.json deleted file mode 100644 index a664a866..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithMissingToOneLinkageRequest.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "author": { - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithNullForToManyLinkageRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithNullForToManyLinkageRequest.json deleted file mode 100644 index 58bf45a3..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithNullForToManyLinkageRequest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "tags": { - "data": null - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithNullToOneUpdateRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithNullToOneUpdateRequest.json deleted file mode 100644 index b73bceeb..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithNullToOneUpdateRequest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "author": { - "data": null - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithObjectForToManyLinkageRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithObjectForToManyLinkageRequest.json deleted file mode 100644 index b1e90ab0..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithObjectForToManyLinkageRequest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "tags": { - "data": { "type": "tags", "id": "301" } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithStringForToManyLinkageRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithStringForToManyLinkageRequest.json deleted file mode 100644 index 7aa288c5..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithStringForToManyLinkageRequest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "tags": { - "data": "301" - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithStringForToOneLinkageRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithStringForToOneLinkageRequest.json deleted file mode 100644 index 919ab261..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithStringForToOneLinkageRequest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "author": { - "data": "403" - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithStringRelationshipValueRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithStringRelationshipValueRequest.json deleted file mode 100644 index 5886abfe..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithStringRelationshipValueRequest.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "author": "301" - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToManyEmptyLinkageUpdateRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToManyEmptyLinkageUpdateRequest.json deleted file mode 100644 index 19eb21a7..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToManyEmptyLinkageUpdateRequest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "tags": { - "data": [] - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToManyHomogeneousDataUpdateRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToManyHomogeneousDataUpdateRequest.json deleted file mode 100644 index a3adc581..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToManyHomogeneousDataUpdateRequest.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "tags": { - "data": [ - { - "id": "301", - "type": "tags" - }, - { - "id": "303", - "type": "tags" - } - ] - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToManyLinkageObjectMissingIdRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToManyLinkageObjectMissingIdRequest.json deleted file mode 100644 index 5d36b4cb..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToManyLinkageObjectMissingIdRequest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "tags": { - "data": [ { "type": "tags" } ] - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToManyLinkageObjectMissingTypeRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToManyLinkageObjectMissingTypeRequest.json deleted file mode 100644 index 6b4c11ae..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToManyLinkageObjectMissingTypeRequest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "tags": { - "data": [ { "id": "301" } ] - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToManyUpdateRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToManyUpdateRequest.json deleted file mode 100644 index db0ef77d..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToManyUpdateRequest.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "tags": { - "data": [ - { "type": "tags", "id": "301" } - ] - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToOneLinkageObjectMissingIdRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToOneLinkageObjectMissingIdRequest.json deleted file mode 100644 index ebdfb7d6..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToOneLinkageObjectMissingIdRequest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "author": { - "data": { "type": "users" } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToOneLinkageObjectMissingTypeRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToOneLinkageObjectMissingTypeRequest.json deleted file mode 100644 index 0ef65f96..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToOneLinkageObjectMissingTypeRequest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "author": { - "data": { "id": "403" } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToOneUpdateRequest.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToOneUpdateRequest.json deleted file mode 100644 index 296c122a..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/PatchWithToOneUpdateRequest.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "relationships": { - "author": { - "data": { - "type": "users", - "id": "403" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/Patch_with_unknown_attribute_Request.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/Patch_with_unknown_attribute_Request.json deleted file mode 100644 index 3394d6df..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/Patch_with_unknown_attribute_Request.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "attributes": { - "title": "New post title", - "some-fake-attribute": 99 - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/Patch_with_unknown_relationship_Request.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/Patch_with_unknown_relationship_Request.json deleted file mode 100644 index 1b4d99fb..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Requests/Patch_with_unknown_relationship_Request.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "attributes": { - "title": "New post title" - }, - "relationships": { - "some-fake-relationship": { - "data": { "type": "author", "id": "45000" } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithArrayForToOneLinkageResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithArrayForToOneLinkageResponse.json deleted file mode 100644 index d7a626e3..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithArrayForToOneLinkageResponse.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "400", - "title": "Invalid linkage for to-one relationship", - "detail": "Expected an object or null for to-one linkage", - "source": { - "pointer": "/data/relationships/author/data" - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithArrayRelationshipValueResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithArrayRelationshipValueResponse.json deleted file mode 100644 index 56a27ad3..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithArrayRelationshipValueResponse.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "400", - "title": "Invalid relationship object", - "detail": "Expected an object, but found StartArray", - "source": { - "pointer": "/data/relationships/tags" - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithAttributeUpdateResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithAttributeUpdateResponse.json deleted file mode 100644 index aba0d13d..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithAttributeUpdateResponse.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "attributes": { - "content": "Post 2 content", - "created": "2015-02-05T08:10:00.0000000+00:00", - "title": "New post title" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/202/relationships/author", - "related": "https://www.example.com/posts/202/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/202/relationships/comments", - "related": "https://www.example.com/posts/202/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/202/relationships/tags", - "related": "https://www.example.com/posts/202/tags" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithAttributeUpdateResponseID.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithAttributeUpdateResponseID.json deleted file mode 100644 index b0448cb5..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithAttributeUpdateResponseID.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data": { - "type": "post-i-ds", - "id": "202", - "attributes": { - "content": "Post 2 content", - "created": "2015-02-05T08:10:00.0000000+00:00", - "title": "New post title" - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithAttributeUpdateResponseLongId.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithAttributeUpdateResponseLongId.json deleted file mode 100644 index fea5fa0a..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithAttributeUpdateResponseLongId.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data": { - "type": "post-long-ids", - "id": "202", - "attributes": { - "content": "Post 2 content", - "created": "2015-02-05T08:10:00.0000000+00:00", - "title": "New post title" - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithAttributeUpdateWithIncludeResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithAttributeUpdateWithIncludeResponse.json deleted file mode 100644 index 6bff40d9..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithAttributeUpdateWithIncludeResponse.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "attributes": { - "content": "Post 2 content", - "created": "2015-02-05T08:10:00.0000000+00:00", - "title": "New post title" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/202/relationships/author", - "related": "https://www.example.com/posts/202/author" - }, - "data": { - "type": "users", - "id": "401" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/202/relationships/comments", - "related": "https://www.example.com/posts/202/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/202/relationships/tags", - "related": "https://www.example.com/posts/202/tags" - } - } - } - }, - "included": [ - { - "type": "users", - "id": "401", - "attributes": { - "first-name": "Alice", - "last-name": "Smith" - }, - "relationships": { - "comments": { - "links": { - "self": "https://www.example.com/users/401/relationships/comments", - "related": "https://www.example.com/users/401/comments" - } - }, - "posts": { - "links": { - "self": "https://www.example.com/users/401/relationships/posts", - "related": "https://www.example.com/users/401/posts" - } - }, - "user-groups": { - "links": { - "self": "https://www.example.com/users/401/relationships/user-groups", - "related": "https://www.example.com/users/401/user-groups" - } - } - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithMissingToManyLinkageResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithMissingToManyLinkageResponse.json deleted file mode 100644 index 09cdf2e3..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithMissingToManyLinkageResponse.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "400", - "title": "Missing linkage for to-many relationship", - "detail": "Expected an array for to-many linkage, but no linkage was specified.", - "source": { - "pointer": "/data/relationships/tags" - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithMissingToOneLinkageResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithMissingToOneLinkageResponse.json deleted file mode 100644 index f279160e..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithMissingToOneLinkageResponse.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "400", - "title": "Missing linkage for to-one relationship", - "detail": "Expected an object for to-one linkage, but no linkage was specified.", - "source": { - "pointer": "/data/relationships/author" - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithNullForToManyLinkageResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithNullForToManyLinkageResponse.json deleted file mode 100644 index fc7f2409..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithNullForToManyLinkageResponse.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "400", - "title": "Invalid linkage for to-many relationship", - "detail": "Expected an array for to-many linkage.", - "source": { - "pointer": "/data/relationships/tags/data" - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithNullToOneUpdateResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithNullToOneUpdateResponse.json deleted file mode 100644 index f9067b51..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithNullToOneUpdateResponse.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "attributes": { - "content": "Post 2 content", - "created": "2015-02-05T08:10:00.0000000+00:00", - "title": "Post 2" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/202/relationships/author", - "related": "https://www.example.com/posts/202/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/202/relationships/comments", - "related": "https://www.example.com/posts/202/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/202/relationships/tags", - "related": "https://www.example.com/posts/202/tags" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithObjectForToManyLinkageResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithObjectForToManyLinkageResponse.json deleted file mode 100644 index fc7f2409..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithObjectForToManyLinkageResponse.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "400", - "title": "Invalid linkage for to-many relationship", - "detail": "Expected an array for to-many linkage.", - "source": { - "pointer": "/data/relationships/tags/data" - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithStringForToManyLinkageResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithStringForToManyLinkageResponse.json deleted file mode 100644 index 3326563d..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithStringForToManyLinkageResponse.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "400", - "title": "Invalid linkage for relationship", - "detail": "Expected an array, object, or null for linkage, but got String", - "source": { - "pointer": "/data/relationships/tags/data" - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithStringForToOneLinkageResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithStringForToOneLinkageResponse.json deleted file mode 100644 index cfe637ad..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithStringForToOneLinkageResponse.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "400", - "title": "Invalid linkage for relationship", - "detail": "Expected an array, object, or null for linkage, but got String", - "source": { - "pointer": "/data/relationships/author/data" - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithStringRelationshipValueResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithStringRelationshipValueResponse.json deleted file mode 100644 index 0a717105..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithStringRelationshipValueResponse.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "400", - "title": "Invalid relationship object", - "detail": "Expected an object, but found String", - "source": { - "pointer": "/data/relationships/author" - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToManyEmptyLinkageUpdateResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToManyEmptyLinkageUpdateResponse.json deleted file mode 100644 index f9067b51..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToManyEmptyLinkageUpdateResponse.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "attributes": { - "content": "Post 2 content", - "created": "2015-02-05T08:10:00.0000000+00:00", - "title": "Post 2" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/202/relationships/author", - "related": "https://www.example.com/posts/202/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/202/relationships/comments", - "related": "https://www.example.com/posts/202/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/202/relationships/tags", - "related": "https://www.example.com/posts/202/tags" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToManyHomogeneousDataUpdateResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToManyHomogeneousDataUpdateResponse.json deleted file mode 100644 index f9067b51..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToManyHomogeneousDataUpdateResponse.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "attributes": { - "content": "Post 2 content", - "created": "2015-02-05T08:10:00.0000000+00:00", - "title": "Post 2" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/202/relationships/author", - "related": "https://www.example.com/posts/202/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/202/relationships/comments", - "related": "https://www.example.com/posts/202/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/202/relationships/tags", - "related": "https://www.example.com/posts/202/tags" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToManyLinkageObjectMissingIdResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToManyLinkageObjectMissingIdResponse.json deleted file mode 100644 index 8b28cb3f..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToManyLinkageObjectMissingIdResponse.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "400", - "title": "Resource identifier missing id", - "detail": "The `id` key is missing.", - "source": { - "pointer": "/data/relationships/tags/data" - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToManyLinkageObjectMissingTypeResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToManyLinkageObjectMissingTypeResponse.json deleted file mode 100644 index 125ef5db..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToManyLinkageObjectMissingTypeResponse.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "400", - "title": "Resource identifier missing type", - "detail": "The `type` key is missing.", - "source": { - "pointer": "/data/relationships/tags/data" - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToManyUpdateResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToManyUpdateResponse.json deleted file mode 100644 index f9067b51..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToManyUpdateResponse.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "attributes": { - "content": "Post 2 content", - "created": "2015-02-05T08:10:00.0000000+00:00", - "title": "Post 2" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/202/relationships/author", - "related": "https://www.example.com/posts/202/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/202/relationships/comments", - "related": "https://www.example.com/posts/202/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/202/relationships/tags", - "related": "https://www.example.com/posts/202/tags" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToOneLinkageObjectMissingIdResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToOneLinkageObjectMissingIdResponse.json deleted file mode 100644 index 2beea4ec..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToOneLinkageObjectMissingIdResponse.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "400", - "title": "Resource identifier missing id", - "detail": "The `id` key is missing.", - "source": { - "pointer": "/data/relationships/author/data" - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToOneLinkageObjectMissingTypeResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToOneLinkageObjectMissingTypeResponse.json deleted file mode 100644 index fb14417c..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToOneLinkageObjectMissingTypeResponse.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "errors": [ - { - "id": "{{SOME_GUID}}", - "status": "400", - "title": "Resource identifier missing type", - "detail": "The `type` key is missing.", - "source": { - "pointer": "/data/relationships/author/data" - } - } - ] -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToOneUpdateResponse.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToOneUpdateResponse.json deleted file mode 100644 index f9067b51..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/PatchWithToOneUpdateResponse.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "attributes": { - "content": "Post 2 content", - "created": "2015-02-05T08:10:00.0000000+00:00", - "title": "Post 2" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/202/relationships/author", - "related": "https://www.example.com/posts/202/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/202/relationships/comments", - "related": "https://www.example.com/posts/202/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/202/relationships/tags", - "related": "https://www.example.com/posts/202/tags" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/Patch_with_unknown_attribute_Response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/Patch_with_unknown_attribute_Response.json deleted file mode 100644 index aba0d13d..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/Patch_with_unknown_attribute_Response.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "attributes": { - "content": "Post 2 content", - "created": "2015-02-05T08:10:00.0000000+00:00", - "title": "New post title" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/202/relationships/author", - "related": "https://www.example.com/posts/202/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/202/relationships/comments", - "related": "https://www.example.com/posts/202/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/202/relationships/tags", - "related": "https://www.example.com/posts/202/tags" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/Patch_with_unknown_relationship_Response.json b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/Patch_with_unknown_relationship_Response.json deleted file mode 100644 index aba0d13d..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Fixtures/UpdatingResources/Responses/Patch_with_unknown_relationship_Response.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "data": { - "type": "posts", - "id": "202", - "attributes": { - "content": "Post 2 content", - "created": "2015-02-05T08:10:00.0000000+00:00", - "title": "New post title" - }, - "relationships": { - "author": { - "links": { - "self": "https://www.example.com/posts/202/relationships/author", - "related": "https://www.example.com/posts/202/author" - } - }, - "comments": { - "links": { - "self": "https://www.example.com/posts/202/relationships/comments", - "related": "https://www.example.com/posts/202/comments" - } - }, - "tags": { - "links": { - "self": "https://www.example.com/posts/202/relationships/tags", - "related": "https://www.example.com/posts/202/tags" - } - } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/HeterogeneousTests.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/HeterogeneousTests.cs deleted file mode 100644 index 013baa6b..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/HeterogeneousTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Net; -using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests -{ - [TestClass] - public class HeterogeneousTests : AcceptanceTestsBase - { - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Get() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "search?s=1"); - - await AssertResponseContent(response, @"Fixtures\Heterogeneous\Responses\GetSearchResultsResponse.json", HttpStatusCode.OK); - } - } - } -} diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests.csproj b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests.csproj deleted file mode 100644 index 35d82430..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests.csproj +++ /dev/null @@ -1,321 +0,0 @@ - - - - Debug - AnyCPU - {58AEF8B8-8D51-4175-AC96-BC622703E8BB} - Library - Properties - JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests - JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests - v4.5 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - ..\ - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Effort.EF6.1.1.4\lib\net45\Effort.dll - - - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll - - - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll - - - ..\packages\FluentAssertions.3.2.2\lib\net45\FluentAssertions.dll - - - ..\packages\FluentAssertions.3.2.2\lib\net45\FluentAssertions.Core.dll - - - ..\packages\Microsoft.Owin.3.0.0\lib\net45\Microsoft.Owin.dll - - - ..\packages\Microsoft.Owin.Hosting.3.0.0\lib\net45\Microsoft.Owin.Hosting.dll - - - ..\packages\Microsoft.Owin.Testing.3.0.0\lib\net45\Microsoft.Owin.Testing.dll - - - ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - True - - - ..\packages\NMemory.1.0.1\lib\net45\NMemory.dll - - - ..\packages\Owin.1.0\lib\net40\Owin.dll - - - - - - - ..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll - True - - - - ..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {76dee472-723b-4be6-8b97-428ac326e30f} - JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp - - - {AF7861F3-550B-4F70-A33E-1E5F48D39333} - JSONAPI.Autofac - - - {52b19fd6-efaa-45b5-9c3e-a652e27608d1} - JSONAPI - - - - - Always - - - - - - - - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - False - - - False - - - False - - - False - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/MappedTests.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/MappedTests.cs deleted file mode 100644 index 9ecf7f77..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/MappedTests.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System.Net; -using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests -{ - [TestClass] - public class MappedTests : AcceptanceTestsBase - { - [TestMethod] - [DeploymentItem(@"Data\Starship.csv", @"Data")] - [DeploymentItem(@"Data\StarshipClass.csv", @"Data")] - public async Task Get_all() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "starships"); - - await AssertResponseContent(response, @"Fixtures\Mapped\Responses\Get_all.json", HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Starship.csv", @"Data")] - [DeploymentItem(@"Data\StarshipClass.csv", @"Data")] - public async Task Get_by_id() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "starships/NCC-1701"); - - await AssertResponseContent(response, @"Fixtures\Mapped\Responses\Get_by_id.json", HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Starship.csv", @"Data")] - [DeploymentItem(@"Data\StarshipClass.csv", @"Data")] - public async Task Get_resource_by_id_that_doesnt_exist() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "starships/NCC-asdf"); - - await AssertResponseContent(response, @"Fixtures\Mapped\Responses\Get_resource_by_id_that_doesnt_exist.json", HttpStatusCode.NotFound, true); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Starship.csv", @"Data")] - [DeploymentItem(@"Data\StarshipClass.csv", @"Data")] - [DeploymentItem(@"Data\Officer.csv", @"Data")] - [DeploymentItem(@"Data\StarshipOfficerLink.csv", @"Data")] - public async Task Get_related_to_many() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "starships/NCC-1701-D/officers"); - - await AssertResponseContent(response, @"Fixtures\Mapped\Responses\Get_related_to_many_response.json", HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Starship.csv", @"Data")] - [DeploymentItem(@"Data\StarshipClass.csv", @"Data")] - [DeploymentItem(@"Data\Officer.csv", @"Data")] - [DeploymentItem(@"Data\StarshipOfficerLink.csv", @"Data")] - public async Task Get_related_to_one() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "starships/NCC-1701-D/ship-counselor"); - - await AssertResponseContent(response, @"Fixtures\Mapped\Responses\Get_related_to_one_response.json", HttpStatusCode.OK); - } - } - } -} diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/PaginationTests.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/PaginationTests.cs deleted file mode 100644 index 0db20f57..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/PaginationTests.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System.Net; -using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests -{ - [TestClass] - public class PaginationTests : AcceptanceTestsBase - { - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task GetPage2Post2() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "posts?page[number]=1&page[size]=2"); - - await AssertResponseContent(response, @"Fixtures\Pagination\GetAllResponsePaged-2-2.json", HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task GetWithFilter() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "users?filter[last-name]=Burns&page[number]=1&page[size]=1"); - - await AssertResponseContent(response, @"Fixtures\Pagination\GetFilterPaged-2-1.json", HttpStatusCode.OK); - } - } - - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task GetWithFilterSortedAscTest() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "users?filter[last-name]=Burns&page[number]=0&page[size]=2&sort=first-name"); - - await AssertResponseContent(response, @"Fixtures\Pagination\GetFilterPaged-1-2-sorted.json", HttpStatusCode.OK); - } - } - - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task GetWithFilterSortedDescTest() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "users?filter[last-name]=Burns&page[number]=0&page[size]=2&sort=-first-name"); - - await AssertResponseContent(response, @"Fixtures\Pagination\GetFilterPaged-1-2-sorted-desc.json", HttpStatusCode.OK); - } - } - - } -} diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Properties/AssemblyInfo.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index af90b244..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("3d646890-c7b9-4a90-9706-eb8378591814")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/SortingTests.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/SortingTests.cs deleted file mode 100644 index 7e11a58e..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/SortingTests.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System.Net; -using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests -{ - [TestClass] - public class SortingTests : AcceptanceTestsBase - { - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task GetSortedAscending() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "users?sort=first-name"); - - await AssertResponseContent(response, @"Fixtures\Sorting\Responses\GetSortedAscendingResponse.json", HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task GetSortedDesending() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "users?sort=-first-name"); - - await AssertResponseContent(response, @"Fixtures\Sorting\Responses\GetSortedDescendingResponse.json", HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task GetSortedByMultipleAscending() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "users?sort=last-name,first-name"); - - await AssertResponseContent(response, @"Fixtures\Sorting\Responses\GetSortedByMultipleAscendingResponse.json", HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task GetSortedByMultipleDescending() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "users?sort=-last-name,-first-name"); - - await AssertResponseContent(response, @"Fixtures\Sorting\Responses\GetSortedByMultipleDescendingResponse.json", HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task GetSortedByMixedDirection() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "users?sort=last-name,-first-name"); - - await AssertResponseContent(response, @"Fixtures\Sorting\Responses\GetSortedByMixedDirectionResponse.json", HttpStatusCode.OK); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task GetSortedByUnknownColumn() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "users?sort=foobar"); - - await AssertResponseContent(response, @"Fixtures\Sorting\Responses\GetSortedByUnknownColumnResponse.json", HttpStatusCode.BadRequest, true); - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task GetSortedBySameColumnTwice() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitGet(effortConnection, "users?sort=first-name,first-name"); - - await AssertResponseContent(response, @"Fixtures\Sorting\Responses\GetSortedBySameColumnTwiceResponse.json", HttpStatusCode.BadRequest, true); - } - } - } -} diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/TestHelpers.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/TestHelpers.cs deleted file mode 100644 index dbafdaee..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/TestHelpers.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Data.Common; -using System.IO; -using System.Reflection; -using Effort; -using Effort.DataLoaders; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests -{ - internal static class TestHelpers - { - // http://stackoverflow.com/questions/21175713/no-entity-framework-provider-found-for-the-ado-net-provider-with-invariant-name - // ReSharper disable once NotAccessedField.Local - private static volatile Type _dependency; - static TestHelpers() - { - _dependency = typeof(System.Data.Entity.SqlServer.SqlProviderServices); - } - - public static string ReadEmbeddedFile(string path) - { - var resourcePath = "JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests." + path.Replace("\\", ".").Replace("/", "."); - using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourcePath)) - { - if (stream == null) throw new Exception("Could not find a file at the path: " + path); - return new StreamReader(stream).ReadToEnd(); - } - } - - public static DbConnection GetEffortConnection(string relativeDataPath) - { - var dataPath = Path.GetFullPath(relativeDataPath); - var dataLoader = new CsvDataLoader(dataPath); - return DbConnectionFactory.CreateTransient(dataLoader); - } - } -} diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/UpdatingResourcesTests.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/UpdatingResourcesTests.cs deleted file mode 100644 index e24ae49b..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/UpdatingResourcesTests.cs +++ /dev/null @@ -1,700 +0,0 @@ -using System; -using System.Data.Entity; -using System.Linq; -using System.Net; -using System.Threading.Tasks; -using FluentAssertions; -using JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests -{ - [TestClass] - public class UpdatingResourcesTests : AcceptanceTestsBase - { - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithAttributeUpdate() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithAttributeUpdateRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithAttributeUpdateResponse.json", HttpStatusCode.OK); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.Include(p => p.Tags).ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("New post title"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithAttributeUpdateAndInclude() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202?include=author", @"Fixtures\UpdatingResources\Requests\PatchWithAttributeUpdateRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithAttributeUpdateWithIncludeResponse.json", HttpStatusCode.OK); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.Include(p => p.Tags).ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("New post title"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\PostID.csv", @"Data")] - public async Task PatchWithAttributeUpdateID() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "post-i-ds/202", @"Fixtures\UpdatingResources\Requests\PatchWithAttributeUpdateRequestID.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithAttributeUpdateResponseID.json", HttpStatusCode.OK); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.PostsID; - allPosts.Count().Should().Be(4); - var actualPost = allPosts.First(t => t.ID == "202"); - actualPost.ID.Should().Be("202"); - actualPost.Title.Should().Be("New post title"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\PostLongId.csv", @"Data")] - public async Task PatchWithAttributeUpdateLongId() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "post-long-ids/202", @"Fixtures\UpdatingResources\Requests\PatchWithAttributeUpdateRequestLongId.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithAttributeUpdateResponseLongId.json", HttpStatusCode.OK); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.PostsLongId; - allPosts.Count().Should().Be(4); - var actualPost = allPosts.First(t => t.Id == 202); - actualPost.Id.Should().Be(202); - actualPost.Title.Should().Be("New post title"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Patch_with_unknown_attribute() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\Patch_with_unknown_attribute_Request.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\Patch_with_unknown_attribute_Response.json", HttpStatusCode.OK); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.Include(p => p.Tags).ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("New post title"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task Patch_with_unknown_relationship() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\Patch_with_unknown_relationship_Request.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\Patch_with_unknown_relationship_Response.json", HttpStatusCode.OK); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.Include(p => p.Tags).ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("New post title"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithToManyUpdate() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithToManyUpdateRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithToManyUpdateResponse.json", HttpStatusCode.OK); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.Include(p => p.Tags).ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("301"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithToManyHomogeneousDataUpdate() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithToManyHomogeneousDataUpdateRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithToManyHomogeneousDataUpdateResponse.json", HttpStatusCode.OK); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.Include(p => p.Tags).ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("301", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithToManyEmptyLinkageUpdate() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithToManyEmptyLinkageUpdateRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithToManyEmptyLinkageUpdateResponse.json", HttpStatusCode.OK); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.Include(p => p.Tags).ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Should().BeEmpty(); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithToOneUpdate() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithToOneUpdateRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithToOneUpdateResponse.json", HttpStatusCode.OK); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("403"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithNullToOneUpdate() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithNullToOneUpdateRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithNullToOneUpdateResponse.json", HttpStatusCode.OK); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.Include(p => p.Author).ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.Author.Should().BeNull(); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithMissingToOneLinkage() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithMissingToOneLinkageRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithMissingToOneLinkageResponse.json", HttpStatusCode.BadRequest, true); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithToOneLinkageObjectMissingId() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithToOneLinkageObjectMissingIdRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithToOneLinkageObjectMissingIdResponse.json", HttpStatusCode.BadRequest, true); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithToOneLinkageObjectMissingType() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithToOneLinkageObjectMissingTypeRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithToOneLinkageObjectMissingTypeResponse.json", HttpStatusCode.BadRequest, true); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithArrayForToOneLinkage() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithArrayForToOneLinkageRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithArrayForToOneLinkageResponse.json", HttpStatusCode.BadRequest, true); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithStringForToOneLinkage() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithStringForToOneLinkageRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithStringForToOneLinkageResponse.json", HttpStatusCode.BadRequest, true); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithMissingToManyLinkage() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithMissingToManyLinkageRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithMissingToManyLinkageResponse.json", HttpStatusCode.BadRequest, true); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithToManyLinkageObjectMissingId() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithToManyLinkageObjectMissingIdRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithToManyLinkageObjectMissingIdResponse.json", HttpStatusCode.BadRequest, true); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithToManyLinkageObjectMissingType() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithToManyLinkageObjectMissingTypeRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithToManyLinkageObjectMissingTypeResponse.json", HttpStatusCode.BadRequest, true); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithObjectForToManyLinkage() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithObjectForToManyLinkageRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithObjectForToManyLinkageResponse.json", HttpStatusCode.BadRequest, true); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithStringForToManyLinkage() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithStringForToManyLinkageRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithStringForToManyLinkageResponse.json", HttpStatusCode.BadRequest, true); - - using (var dbContext = new TestDbContext(effortConnection, false)) - - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithNullForToManyLinkage() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithNullForToManyLinkageRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithNullForToManyLinkageResponse.json", HttpStatusCode.BadRequest, true); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithArrayRelationshipValue() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithArrayRelationshipValueRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithArrayRelationshipValueResponse.json", HttpStatusCode.BadRequest, true); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - - [TestMethod] - [DeploymentItem(@"Data\Comment.csv", @"Data")] - [DeploymentItem(@"Data\Post.csv", @"Data")] - [DeploymentItem(@"Data\PostTagLink.csv", @"Data")] - [DeploymentItem(@"Data\Tag.csv", @"Data")] - [DeploymentItem(@"Data\User.csv", @"Data")] - public async Task PatchWithStringRelationshipValue() - { - using (var effortConnection = GetEffortConnection()) - { - var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithStringRelationshipValueRequest.json"); - - await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithStringRelationshipValueResponse.json", HttpStatusCode.BadRequest, true); - - using (var dbContext = new TestDbContext(effortConnection, false)) - { - var allPosts = dbContext.Posts.ToArray(); - allPosts.Length.Should().Be(4); - var actualPost = allPosts.First(t => t.Id == "202"); - actualPost.Id.Should().Be("202"); - actualPost.Title.Should().Be("Post 2"); - actualPost.Content.Should().Be("Post 2 content"); - actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); - actualPost.AuthorId.Should().Be("401"); - actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); - } - } - } - } -} diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/packages.config b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/packages.config deleted file mode 100644 index 0243217e..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests/packages.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Controllers/MainController.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Controllers/MainController.cs deleted file mode 100644 index 6c786a1c..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Controllers/MainController.cs +++ /dev/null @@ -1,12 +0,0 @@ -using JSONAPI.Http; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Controllers -{ - public class MainController : JsonApiController - { - public MainController(IDocumentMaterializerLocator documentMaterializerLocator) - : base(documentMaterializerLocator) - { - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Controllers/SamplesController.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Controllers/SamplesController.cs deleted file mode 100644 index 4d6d7546..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Controllers/SamplesController.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using System.Web.Http; -using JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Controllers -{ - public class SamplesController : ApiController - { - public IHttpActionResult GetSamples() - { - var s1 = new Sample - { - Id = "1", - BooleanField = false, - NullableBooleanField = false, - SbyteField = default(SByte), - NullableSbyteField = null, - ByteField = default(Byte), - NullableByteField = null, - Int16Field = default(Int16), - NullableInt16Field = null, - Uint16Field = default(UInt16), - NullableUint16Field = null, - Int32Field = default(Int32), - NullableInt32Field = null, - Uint32Field = default(Int32), - NullableUint32Field = null, - Int64Field = default(Int64), - NullableInt64Field = null, - Uint64Field = default(UInt64), - NullableUint64Field = null, - DoubleField = default(Double), - NullableDoubleField = null, - SingleField = default(Single), - NullableSingleField = null, - DecimalField = default(Decimal), - NullableDecimalField = null, - DateTimeField = default(DateTime), - NullableDateTimeField = null, - DateTimeOffsetField = default(DateTimeOffset), - NullableDateTimeOffsetField = null, - GuidField = default(Guid), - NullableGuidField = null, - StringField = null, - EnumField = default(SampleEnum), - NullableEnumField = null, - ComplexAttributeField = null, - JTokenStringField = null, - JTokenObjectField = null, - JTokenArrayField = null - }; - var s2 = new Sample - { - Id = "2", - BooleanField = true, - NullableBooleanField = true, - SbyteField = 123, - NullableSbyteField = 123, - ByteField = 253, - NullableByteField = 253, - Int16Field = 32000, - NullableInt16Field = 32000, - Uint16Field = 64000, - NullableUint16Field = 64000, - Int32Field = 2000000000, - NullableInt32Field = 2000000000, - Uint32Field = 3000000000, - NullableUint32Field = 3000000000, - Int64Field = 9223372036854775807, - NullableInt64Field = 9223372036854775807, - Uint64Field = 9223372036854775808, - NullableUint64Field = 9223372036854775808, - DoubleField = 1056789.123, - NullableDoubleField = 1056789.123, - SingleField = 1056789.123f, - NullableSingleField = 1056789.123f, - DecimalField = 1056789.123m, - NullableDecimalField = 1056789.123m, - DateTimeField = new DateTime(1776, 07, 04), - NullableDateTimeField = new DateTime(1776, 07, 04), - DateTimeOffsetField = new DateTimeOffset(new DateTime(1776, 07, 04), new TimeSpan(-5, 0, 0)), - NullableDateTimeOffsetField = new DateTimeOffset(new DateTime(1776, 07, 04), new TimeSpan(-5, 0, 0)), - GuidField = new Guid("6566F9B4-5245-40DE-890D-98B40A4AD656"), - NullableGuidField = new Guid("3D1FB81E-43EE-4D04-AF91-C8A326341293"), - StringField = "Some string 156", - EnumField = SampleEnum.Value1, - NullableEnumField = SampleEnum.Value2, - ComplexAttributeField = "{\"foo\": { \"baz\": [11] }, \"bar\": 5}", - JTokenStringField = "Andrew Jackson", - JTokenObjectField = JToken.FromObject(new SomeSerializableClass { MyField1 = "Abraham Lincoln", MyField2 = true, MyField3 = 439 }), - JTokenArrayField = new JArray( - JToken.FromObject(new SomeSerializableClass { MyField1 = "George Washington", MyField2 = null, MyField3 = 216 }), - JToken.FromObject(new SomeSerializableClass { MyField1 = "Thomas Jefferson", MyField2 = false, MyField3 = 631 })) - }; - - return Ok(new[] { s1, s2 }); - } - - [Serializable] - public class SomeSerializableClass - { - [JsonProperty("my-field1")] - public string MyField1 { get; set; } - - [JsonProperty("overridden-field2")] - public bool? MyField2 { get; set; } - - public int MyField3 { get; set; } - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Controllers/SearchController.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Controllers/SearchController.cs deleted file mode 100644 index 0d4c1667..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Controllers/SearchController.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; -using System.Data.Entity; -using System.Linq; -using System.Threading.Tasks; -using System.Web.Http; -using JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Controllers -{ - public class SearchController : ApiController - { - private readonly TestDbContext _dbContext; - - public SearchController(TestDbContext dbContext) - { - _dbContext = dbContext; - } - - public async Task> Get(string s) - { - IEnumerable posts = await _dbContext.Posts.Where(p => p.Title.Contains(s)).ToArrayAsync(); - IEnumerable comments = await _dbContext.Comments.Where(p => p.Text.Contains(s)).ToArrayAsync(); - return posts.Concat(comments); - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Controllers/TreesController.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Controllers/TreesController.cs deleted file mode 100644 index 6a018db0..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Controllers/TreesController.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Web.Http; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Controllers -{ - public class TreesController : ApiController - { - public IHttpActionResult Get() - { - throw new Exception("Something bad happened!"); - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/CustomEntityFrameworkResourceObjectMaterializer.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/CustomEntityFrameworkResourceObjectMaterializer.cs deleted file mode 100644 index 2a2c6190..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/CustomEntityFrameworkResourceObjectMaterializer.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Data.Entity; -using System.Threading.Tasks; -using JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models; -using JSONAPI.Core; -using JSONAPI.Documents; -using JSONAPI.EntityFramework; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp -{ - public class CustomEntityFrameworkResourceObjectMaterializer : EntityFrameworkResourceObjectMaterializer - { - public CustomEntityFrameworkResourceObjectMaterializer(DbContext dbContext, IResourceTypeRegistry registry) : base(dbContext, registry) - { - } - - protected override Task SetIdForNewResource(IResourceObject resourceObject, object newObject, IResourceTypeRegistration typeRegistration) - { - // This is to facilitate testing creation of a resource with a server-provided ID - if (typeRegistration.Type == typeof (Post) && String.IsNullOrEmpty(resourceObject.Id)) - { - ((Post) newObject).Id = "230"; - return Task.FromResult(0); - } - - return base.SetIdForNewResource(resourceObject, newObject, typeRegistration); - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/DocumentMaterializers/StarshipDocumentMaterializer.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/DocumentMaterializers/StarshipDocumentMaterializer.cs deleted file mode 100644 index 9eb3fa47..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/DocumentMaterializers/StarshipDocumentMaterializer.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Linq; -using System.Linq.Expressions; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models; -using JSONAPI.Core; -using JSONAPI.Documents; -using JSONAPI.Documents.Builders; -using JSONAPI.Http; -using JSONAPI.QueryableTransformers; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.DocumentMaterializers -{ - public class StarshipDocumentMaterializer : MappedDocumentMaterializer - { - private readonly TestDbContext _dbContext; - - public StarshipDocumentMaterializer( - TestDbContext dbContext, - IQueryableResourceCollectionDocumentBuilder queryableResourceCollectionDocumentBuilder, - IBaseUrlService baseUrlService, ISingleResourceDocumentBuilder singleResourceDocumentBuilder, - ISortExpressionExtractor sortExpressionExtractor, - IQueryableEnumerationTransformer queryableEnumerationTransformer, IResourceTypeRegistry resourceTypeRegistry) - : base( - queryableResourceCollectionDocumentBuilder, baseUrlService, singleResourceDocumentBuilder, - queryableEnumerationTransformer, sortExpressionExtractor, resourceTypeRegistry) - { - _dbContext = dbContext; - } - - protected override IQueryable GetQuery() - { - return _dbContext.Starships; - } - - protected override IQueryable GetByIdQuery(string id) - { - return GetQuery().Where(s => s.StarshipId == id); - } - - protected override IQueryable GetMappedQuery(IQueryable entityQuery, Expression>[] propertiesToInclude) - { - return entityQuery.Select(s => new StarshipDto - { - Id = s.StarshipId, - Name = s.Name, - StarshipClass = s.StarshipClass.Name - }); - } - - public override Task CreateRecord(ISingleResourceDocument requestDocument, HttpRequestMessage request, - CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } - - public override Task UpdateRecord(string id, ISingleResourceDocument requestDocument, HttpRequestMessage request, - CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } - - public override Task DeleteRecord(string id, HttpRequestMessage request, CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/DocumentMaterializers/StarshipOfficersRelatedResourceMaterializer.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/DocumentMaterializers/StarshipOfficersRelatedResourceMaterializer.cs deleted file mode 100644 index 9fb646b3..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/DocumentMaterializers/StarshipOfficersRelatedResourceMaterializer.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Data.Entity; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models; -using JSONAPI.Core; -using JSONAPI.Documents.Builders; -using JSONAPI.EntityFramework.Http; -using JSONAPI.Http; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.DocumentMaterializers -{ - public class StarshipOfficersRelatedResourceMaterializer : EntityFrameworkToManyRelatedResourceDocumentMaterializer - { - private readonly DbContext _dbContext; - - public StarshipOfficersRelatedResourceMaterializer(ResourceTypeRelationship relationship, DbContext dbContext, - IQueryableResourceCollectionDocumentBuilder queryableResourceCollectionDocumentBuilder, - ISortExpressionExtractor sortExpressionExtractor, - IIncludeExpressionExtractor includeExpressionExtractor, - IResourceTypeRegistration primaryTypeRegistration) - : base(relationship, dbContext, queryableResourceCollectionDocumentBuilder, sortExpressionExtractor, includeExpressionExtractor, primaryTypeRegistration) - { - _dbContext = dbContext; - } - - protected override Task> GetRelatedQuery(string primaryResourceId, CancellationToken cancellationToken) - { - var query = _dbContext.Set().Where(s => s.StarshipId == primaryResourceId).SelectMany(s => s.OfficerLinks) - .Select(l => new StarshipOfficerDto - { - Id = l.StarshipId + "_" + l.OfficerId, - Name = l.Officer.Name, - Rank = l.Officer.Rank, - Position = l.Position - }); - return Task.FromResult(query); - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/DocumentMaterializers/StarshipShipCounselorRelatedResourceMaterializer.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/DocumentMaterializers/StarshipShipCounselorRelatedResourceMaterializer.cs deleted file mode 100644 index 035c4837..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/DocumentMaterializers/StarshipShipCounselorRelatedResourceMaterializer.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Data.Entity; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models; -using JSONAPI.Core; -using JSONAPI.Documents.Builders; -using JSONAPI.EntityFramework.Http; -using JSONAPI.Http; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.DocumentMaterializers -{ - public class StarshipShipCounselorRelatedResourceMaterializer : EntityFrameworkToOneRelatedResourceDocumentMaterializer - { - private readonly DbContext _dbContext; - - public StarshipShipCounselorRelatedResourceMaterializer( - ISingleResourceDocumentBuilder singleResourceDocumentBuilder, IBaseUrlService baseUrlService, - IResourceTypeRegistration primaryTypeRegistration, ResourceTypeRelationship relationship, - DbContext dbContext) - : base(singleResourceDocumentBuilder, baseUrlService, primaryTypeRegistration, relationship, dbContext) - { - _dbContext = dbContext; - } - - protected override async Task GetRelatedRecord(string primaryResourceId, CancellationToken cancellationToken) - { - var query = _dbContext.Set().Where(s => s.StarshipId == primaryResourceId) - .SelectMany(s => s.OfficerLinks) - .Where(l => l.Position == "Ship's Counselor") - .Select(l => new StarshipOfficerDto - { - Id = l.StarshipId + "_" + l.OfficerId, - Name = l.Officer.Name, - Rank = l.Officer.Rank, - Position = l.Position - }); - return await query.FirstOrDefaultAsync(cancellationToken); - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.csproj b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.csproj deleted file mode 100644 index 0a5148ea..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.csproj +++ /dev/null @@ -1,216 +0,0 @@ - - - - - Debug - AnyCPU - - - 2.0 - {76DEE472-723B-4BE6-8B97-428AC326E30F} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp - JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp - v4.5 - true - - - - - ..\ - true - - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\ - TRACE - prompt - 4 - - - - False - ..\packages\Autofac.3.5.2\lib\net40\Autofac.dll - - - False - ..\packages\Autofac.Owin.3.1.0\lib\net45\Autofac.Integration.Owin.dll - - - False - ..\packages\Autofac.WebApi2.3.4.0\lib\net45\Autofac.Integration.WebApi.dll - - - False - ..\packages\Autofac.WebApi2.Owin.3.2.0\lib\net45\Autofac.Integration.WebApi.Owin.dll - - - False - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll - - - False - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll - - - - ..\packages\Microsoft.Owin.3.0.0\lib\net45\Microsoft.Owin.dll - - - ..\packages\Microsoft.Owin.Host.SystemWeb.3.0.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll - - - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - - - ..\packages\Owin.1.0\lib\net40\Owin.dll - - - - False - ..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll - - - - - - - - - - - - False - ..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll - - - ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.2\lib\net45\System.Web.Http.Owin.dll - - - - - - - - - - - - - Web.config - - - Web.config - - - - - Designer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {64abe648-efcb-46ee-9e1a-e163f52bf372} - JSONAPI.Autofac.EntityFramework - - - {af7861f3-550b-4f70-a33e-1e5f48d39333} - JSONAPI.Autofac - - - {e906356c-93f6-41f6-9a0d-73b8a99aa53c} - JSONAPI.EntityFramework - - - {52b19fd6-efaa-45b5-9c3e-a652e27608d1} - JSONAPI - - - - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - - - - - True - True - 9283 - / - http://localhost:9283/ - False - False - - - False - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Building.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Building.cs deleted file mode 100644 index 3bfd590e..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Building.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using Newtonsoft.Json; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class Building - { - [Key] - public string Id { get; set; } - - public string Address { get; set; } - - [JsonIgnore] - public string OwnerCompanyId { get; set; } - - [ForeignKey("OwnerCompanyId")] - public virtual Company Owner { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Child.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Child.cs deleted file mode 100644 index b3aefcc7..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Child.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using Newtonsoft.Json; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class Child - { - public int Id { get; set; } - - public string ChildDescription { get; set; } - - [Required] - [JsonIgnore] - public int MasterId { get; set; } - - [ForeignKey("MasterId")] - public Master Master { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/City.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/City.cs deleted file mode 100644 index 43283f17..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/City.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using JSONAPI.Attributes; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class City - { - [Key] - public string Id { get; set; } - - public string Name { get; set; } - - [RelatedResourceLinkTemplate("/cities/{1}/state")] - public virtual State State { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Comment.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Comment.cs deleted file mode 100644 index f031485a..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Comment.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using Newtonsoft.Json; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class Comment - { - [Key] - public string Id { get; set; } - - public string Text { get; set; } - - public DateTimeOffset Created { get; set; } - - [Required] - [JsonIgnore] - public string PostId { get; set; } - - [Required] - [JsonIgnore] - public string AuthorId { get; set; } - - [ForeignKey("PostId")] - public virtual Post Post { get; set; } - - [ForeignKey("AuthorId")] - public virtual User Author { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Company.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Company.cs deleted file mode 100644 index 55a4d6e7..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Company.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class Company - { - [Key] - public string Id { get; set; } - - public string Name { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Language.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Language.cs deleted file mode 100644 index 4a8ec476..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Language.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class Language - { - [Key] - public string Id { get; set; } - - public string Name { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/LanguageUserLink.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/LanguageUserLink.cs deleted file mode 100644 index 8a895ea6..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/LanguageUserLink.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using Newtonsoft.Json; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class LanguageUserLink - { - public string Id { get { return LanguageId + "_" + UserId; } } - - [JsonIgnore] - [Key, Column(Order = 1)] - public string LanguageId { get; set; } - - [JsonIgnore] - [Key, Column(Order = 2)] - public string UserId { get; set; } - - public string FluencyLevel { get; set; } - - [ForeignKey("LanguageId")] - public virtual Language Language { get; set; } - - [ForeignKey("UserId")] - public virtual User User { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Master.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Master.cs deleted file mode 100644 index 5ad2015c..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Master.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class Master - { - public int Id { get; set; } - - public string Description { get; set; } - - public virtual ICollection Children { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Officer.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Officer.cs deleted file mode 100644 index e167d4be..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Officer.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class Officer - { - [Key] - public string OfficerId { get; set; } - - public string Name { get; set; } - - public string Rank { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Post.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Post.cs deleted file mode 100644 index 5c750537..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Post.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using Newtonsoft.Json; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class Post - { - [Key] - public string Id { get; set; } - - public string Title { get; set; } - - public string Content { get; set; } - - public DateTimeOffset Created { get; set; } - - [JsonIgnore] - public string AuthorId { get; set; } - - [ForeignKey("AuthorId")] - public virtual User Author { get; set; } - - public virtual ICollection Comments { get; set; } - - public virtual ICollection Tags { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/PostID.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/PostID.cs deleted file mode 100644 index 4e7bd60f..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/PostID.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using Newtonsoft.Json; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class PostID - { - [Key] - public string ID { get; set; } - - public string Title { get; set; } - - public string Content { get; set; } - - public DateTimeOffset Created { get; set; } - - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/PostLongId.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/PostLongId.cs deleted file mode 100644 index 24e830d5..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/PostLongId.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using Newtonsoft.Json; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class PostLongId - { - [Key] - public long Id { get; set; } - - public string Title { get; set; } - - public string Content { get; set; } - - public DateTimeOffset Created { get; set; } - - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Sample.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Sample.cs deleted file mode 100644 index e8096599..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Sample.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using JSONAPI.Attributes; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public enum SampleEnum - { - Value1 = 1, - Value2 = 2 - } - - public class Sample - { - public string Id { get; set; } - public Boolean BooleanField { get; set; } - public Boolean? NullableBooleanField { get; set; } - public SByte SbyteField { get; set; } - public SByte? NullableSbyteField { get; set; } - public Byte ByteField { get; set; } - public Byte? NullableByteField { get; set; } - public Int16 Int16Field { get; set; } - public Int16? NullableInt16Field { get; set; } - public UInt16 Uint16Field { get; set; } - public UInt16? NullableUint16Field { get; set; } - public Int32 Int32Field { get; set; } - public Int32? NullableInt32Field { get; set; } - public UInt32 Uint32Field { get; set; } - public UInt32? NullableUint32Field { get; set; } - public Int64 Int64Field { get; set; } - public Int64? NullableInt64Field { get; set; } - public UInt64 Uint64Field { get; set; } - public UInt64? NullableUint64Field { get; set; } - public Double DoubleField { get; set; } - public Double? NullableDoubleField { get; set; } - public Single SingleField { get; set; } - public Single? NullableSingleField { get; set; } - public Decimal DecimalField { get; set; } - public Decimal? NullableDecimalField { get; set; } - public DateTime DateTimeField { get; set; } - public DateTime? NullableDateTimeField { get; set; } - public DateTimeOffset DateTimeOffsetField { get; set; } - public DateTimeOffset? NullableDateTimeOffsetField { get; set; } - public Guid GuidField { get; set; } - public Guid? NullableGuidField { get; set; } - public string StringField { get; set; } - public SampleEnum EnumField { get; set; } - public SampleEnum? NullableEnumField { get; set; } - - [SerializeAsComplex] - public string ComplexAttributeField { get; set; } - - public JToken JTokenStringField { get; set; } - - public JToken JTokenObjectField { get; set; } - - public JToken JTokenArrayField { get; set; } - } -} diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Starship.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Starship.cs deleted file mode 100644 index 96a55e60..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Starship.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class Starship - { - [Key] - public string StarshipId { get; set; } - - public string Name { get; set; } - - public string StarshipClassId { get; set; } - - [ForeignKey("StarshipClassId")] - public virtual StarshipClass StarshipClass { get; set; } - - public virtual ICollection OfficerLinks { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/StarshipClass.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/StarshipClass.cs deleted file mode 100644 index 028180c6..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/StarshipClass.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class StarshipClass - { - [Key] - public string StarshipClassId { get; set; } - - public string Name { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/StarshipDto.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/StarshipDto.cs deleted file mode 100644 index e081fe44..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/StarshipDto.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections.Generic; -using Newtonsoft.Json; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - [JsonObject(Title = "starship")] - public class StarshipDto - { - public string Id { get; set; } - - public string Name { get; set; } - - public string StarshipClass { get; set; } - - public virtual ICollection Officers { get; set; } - - public virtual StarshipOfficerDto ShipCounselor { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/StarshipOfficerDto.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/StarshipOfficerDto.cs deleted file mode 100644 index ca18f6db..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/StarshipOfficerDto.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Newtonsoft.Json; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - [JsonObject(Title = "starship-officer")] - public class StarshipOfficerDto - { - public string Id { get; set; } - - public string Name { get; set; } - - public string Rank { get; set; } - - public string Position { get; set; } - - public virtual StarshipDto CurrentShip { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/StarshipOfficerLink.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/StarshipOfficerLink.cs deleted file mode 100644 index 26b5704b..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/StarshipOfficerLink.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class StarshipOfficerLink - { - [Key, Column(Order = 0)] - public string StarshipId { get; set; } - - [Key, Column(Order = 1)] - public string OfficerId { get; set; } - - [ForeignKey("StarshipId")] - public virtual Starship Starship { get; set; } - - [ForeignKey("OfficerId")] - public virtual Officer Officer { get; set; } - - public string Position { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/State.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/State.cs deleted file mode 100644 index 3b7ed57f..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/State.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class State - { - [Key] - public string Id { get; set; } - - public string Name { get; set; } - - public virtual ICollection Cities { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Tag.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Tag.cs deleted file mode 100644 index 9d9f25b6..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/Tag.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class Tag - { - [Key] - public string Id { get; set; } - - public string Name { get; set; } - - public virtual ICollection Posts { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/TestDbContext.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/TestDbContext.cs deleted file mode 100644 index 4850d0a0..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/TestDbContext.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Data.Common; -using System.Data.Entity; -using System.Data.Entity.ModelConfiguration.Conventions; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class TestDbContext : DbContext - { - public TestDbContext() - { - - } - - public TestDbContext(string connectionString) : base(connectionString) - { - - } - - public TestDbContext(DbConnection existingConnection, bool contextOwnsConnection) - : base(existingConnection, contextOwnsConnection) - { - - } - - protected override void OnModelCreating(DbModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); - - modelBuilder.Conventions.Remove(); - - modelBuilder - .Entity() - .HasMany(p => p.Tags) - .WithMany(t => t.Posts) - .Map(c => c.MapLeftKey("PostId").MapRightKey("TagId").ToTable("PostTagLink")); - } - - public DbSet Buildings { get; set; } - public DbSet Companies { get; set; } - public DbSet Comments { get; set; } - public DbSet Languages { get; set; } - public DbSet Posts { get; set; } - public DbSet PostsID { get; set; } - public DbSet PostsLongId { get; set; } - public DbSet Tags { get; set; } - public DbSet Users { get; set; } - public DbSet LanguageUserLinks { get; set; } - public DbSet Starships { get; set; } - public DbSet StarshipClasses { get; set; } - public DbSet Officers { get; set; } - public DbSet StarshipOfficerLinks { get; set; } - public DbSet Masters { get; set; } - public DbSet Children { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/User.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/User.cs deleted file mode 100644 index 54596d11..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/User.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class User - { - [Key] - public string Id { get; set; } - - public string FirstName { get; set; } - - public string LastName { get; set; } - - public virtual ICollection Comments { get; set; } - - public virtual ICollection Posts { get; set; } - - public virtual ICollection UserGroups { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/UserGroup.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/UserGroup.cs deleted file mode 100644 index fd154f87..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/UserGroup.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models -{ - public class UserGroup - { - [Key] - public string Id { get; set; } - - public string Name { get; set; } - - public virtual ICollection Users { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Properties/AssemblyInfo.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Properties/AssemblyInfo.cs deleted file mode 100644 index 130abbb8..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("JSONAPI.EntityFramework.Tests.TestWebApp")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("JSONAPI.EntityFramework.Tests.TestWebApp")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("4be8969d-e95b-49f8-8f5e-0c9b7807ef4c")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: InternalsVisibleTo("JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests")] \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Startup.cs b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Startup.cs deleted file mode 100644 index 678f8532..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Startup.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System; -using System.Data.Entity; -using System.Linq.Expressions; -using System.Reflection; -using System.Web.Http; -using Autofac; -using Autofac.Integration.WebApi; -using JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.DocumentMaterializers; -using JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models; -using JSONAPI.Autofac; -using JSONAPI.Autofac.EntityFramework; -using JSONAPI.Configuration; -using JSONAPI.EntityFramework; -using JSONAPI.EntityFramework.Configuration; -using Owin; -using System.Collections.Generic; -using JSONAPI.Documents.Builders; -using JSONAPI.EntityFramework.Documents.Builders; - -namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp -{ - public class Startup - { - private readonly Func _dbContextFactory; - - public Startup() - : this(() => new TestDbContext()) - { - - } - - public Startup(Func dbContextFactory) - { - _dbContextFactory = dbContextFactory; - } - - public void Configuration(IAppBuilder app) - { - /* these steps are divided in multiple methods to support better acceptance tests - * in production all the steps can be made inside the Configuration method. - */ - var configuration = BuildConfiguration(); - - var configurator = BuildAutofacConfigurator(app); - - var httpConfig = BuildHttpConfiguration(); - - MergeAndSetupConfiguration(app, configurator, httpConfig, configuration); - } - - internal void MergeAndSetupConfiguration(IAppBuilder app, JsonApiHttpAutofacConfigurator configurator, - HttpConfiguration httpConfig, JsonApiConfiguration configuration) - { - configurator.Apply(httpConfig, configuration); - app.UseWebApi(httpConfig); - app.UseAutofacWebApi(httpConfig); - } - - /// - /// Build up the which registers all the model types and their mappings. - /// - /// - internal JsonApiConfiguration BuildConfiguration() - { - var configuration = new JsonApiConfiguration( - new Core.PluralizationService( - new Dictionary { { "Child", "Children" } })); - configuration.RegisterEntityFrameworkResourceType(); - configuration.RegisterEntityFrameworkResourceType(); - configuration.RegisterEntityFrameworkResourceType(); - configuration.RegisterEntityFrameworkResourceType(); - configuration.RegisterEntityFrameworkResourceType(); - configuration.RegisterEntityFrameworkResourceType(c => - { - c.OverrideDefaultFilterById(LanguageUserLinkFilterByIdFactory); - c.OverrideDefaultSortById(LanguageUserLinkSortByIdFactory); - }); - configuration.RegisterResourceType(); - configuration.RegisterResourceType(); - configuration.RegisterResourceType(); - configuration.RegisterEntityFrameworkResourceType(); - configuration.RegisterEntityFrameworkResourceType(); - configuration.RegisterEntityFrameworkResourceType(); - configuration.RegisterEntityFrameworkResourceType(); - configuration.RegisterResourceType(); // Example of a resource type not controlled by EF - configuration.RegisterMappedType(c => - { - c.ConfigureRelationship(s => s.Officers, - rc => rc.UseMaterializer()); - c.ConfigureRelationship(s => s.ShipCounselor, - rc => rc.UseMaterializer()); - }); // Example of a resource that is mapped from a DB entity - configuration.RegisterResourceType(); - configuration.RegisterEntityFrameworkResourceType(); - configuration.RegisterEntityFrameworkResourceType(); - return configuration; - } - - /// - /// Build up the which registers , modules and materializer - /// - /// - /// - internal JsonApiHttpAutofacConfigurator BuildAutofacConfigurator(IAppBuilder app) - { - var configurator = new JsonApiHttpAutofacConfigurator(); - configurator.OnApplicationLifetimeScopeCreating(builder => - { - builder.Register(c => _dbContextFactory()) - .AsSelf() - .As() - .InstancePerRequest(); - builder.RegisterModule(); - builder.RegisterType() - .As(); - builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); - builder.RegisterType().As(); - - }); - configurator.OnApplicationLifetimeScopeBegun(applicationLifetimeScope => - { - // TODO: is this a candidate for spinning into a JSONAPI.Autofac.WebApi.Owin package? Yuck - app.UseAutofacMiddleware(applicationLifetimeScope); - }); - return configurator; - } - - /// - /// Build up the with additional routes - /// - /// - internal HttpConfiguration BuildHttpConfiguration() - { - var httpConfig = new HttpConfiguration - { - IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always - }; - - // Additional Web API routes - httpConfig.Routes.MapHttpRoute("Samples", "samples", new { Controller = "Samples" }); - httpConfig.Routes.MapHttpRoute("Search", "search", new { Controller = "Search" }); - httpConfig.Routes.MapHttpRoute("Trees", "trees", new { Controller = "Trees" }); - return httpConfig; - } - - - private BinaryExpression LanguageUserLinkFilterByIdFactory(ParameterExpression param, string id) - { - var split = id.Split('_'); - var languageId = Expression.Constant(split[0]); - var userId = Expression.Constant(split[1]); - - var languageIdPropertyExpr = Expression.Property(param, "LanguageId"); - var languageIdPropertyEqualsExpr = Expression.Equal(languageIdPropertyExpr, languageId); - - var userIdPropertyExpr = Expression.Property(param, "UserId"); - var userIdPropertyEqualsExpr = Expression.Equal(userIdPropertyExpr, userId); - - return Expression.AndAlso(languageIdPropertyEqualsExpr, userIdPropertyEqualsExpr); - } - - private Expression LanguageUserLinkSortByIdFactory(ParameterExpression param) - { - var concatMethod = typeof(string).GetMethod("Concat", new[] { typeof(object), typeof(object) }); - - var languageIdExpr = Expression.Property(param, "LanguageId"); - var userIdExpr = Expression.Property(param, "UserId"); - return Expression.Call(concatMethod, languageIdExpr, userIdExpr); - } - } -} \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Web.Debug.config b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Web.Debug.config deleted file mode 100644 index 2e302f9f..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Web.Debug.config +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Web.Release.config b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Web.Release.config deleted file mode 100644 index c3584446..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Web.Release.config +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Web.config b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Web.config deleted file mode 100644 index 2d263f08..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Web.config +++ /dev/null @@ -1,53 +0,0 @@ - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/packages.config b/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/packages.config deleted file mode 100644 index bba30ec4..00000000 --- a/JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/packages.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.Autofac.EntityFramework/JSONAPI.Autofac.EntityFramework.csproj b/JSONAPI.Autofac.EntityFramework/JSONAPI.Autofac.EntityFramework.csproj deleted file mode 100644 index b7ee5706..00000000 --- a/JSONAPI.Autofac.EntityFramework/JSONAPI.Autofac.EntityFramework.csproj +++ /dev/null @@ -1,84 +0,0 @@ - - - - - Debug - AnyCPU - {64ABE648-EFCB-46EE-9E1A-E163F52BF372} - Library - Properties - JSONAPI.Autofac.EntityFramework - JSONAPI.Autofac.EntityFramework - v4.5 - 512 - ..\ - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - ..\packages\Autofac.3.5.2\lib\net40\Autofac.dll - - - - - - - - - - - - - - - - - - - - {af7861f3-550b-4f70-a33e-1e5f48d39333} - JSONAPI.Autofac - - - {e906356c-93f6-41f6-9a0d-73b8a99aa53c} - JSONAPI.EntityFramework - - - {52b19fd6-efaa-45b5-9c3e-a652e27608d1} - JSONAPI - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/JSONAPI.Autofac.EntityFramework/JsonApiAutofacEntityFrameworkModule.cs b/JSONAPI.Autofac.EntityFramework/JsonApiAutofacEntityFrameworkModule.cs deleted file mode 100644 index 481e823e..00000000 --- a/JSONAPI.Autofac.EntityFramework/JsonApiAutofacEntityFrameworkModule.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Linq; -using Autofac; -using JSONAPI.Core; -using JSONAPI.EntityFramework; -using JSONAPI.EntityFramework.ActionFilters; -using JSONAPI.EntityFramework.Http; -using JSONAPI.Http; -using JSONAPI.QueryableTransformers; - -namespace JSONAPI.Autofac.EntityFramework -{ - public class JsonApiAutofacEntityFrameworkModule : Module - { - protected override void Load(ContainerBuilder builder) - { - builder.RegisterType().As(); - builder.RegisterType() - .As(); - - builder.RegisterGeneric(typeof (EntityFrameworkDocumentMaterializer<>)); - builder.Register((ctx, parameters) => - { - var allParameters = parameters.ToArray(); - var typedParameters = allParameters.OfType().ToArray(); - var resourceTypeRegistrationParameter = - typedParameters.FirstOrDefault(tp => tp.Type == typeof(IResourceTypeRegistration)); - if (resourceTypeRegistrationParameter == null) - throw new Exception( - "An IResourceTypeRegistration parameter must be provided to resolve an instance of EntityFrameworkDocumentMaterializer."); - - var resourceTypeRegistration = resourceTypeRegistrationParameter.Value as IResourceTypeRegistration; - if (resourceTypeRegistration == null) - throw new Exception( - "An IResourceTypeRegistration parameter was provided to resolve EntityFrameworkDocumentMaterializer, but its value was null."); - - var openGenericType = typeof (EntityFrameworkDocumentMaterializer<>); - var materializerType = openGenericType.MakeGenericType(resourceTypeRegistration.Type); - return ctx.Resolve(materializerType, allParameters); - }).As(); - - builder.RegisterGeneric(typeof(EntityFrameworkToManyRelatedResourceDocumentMaterializer<,>)); - builder.RegisterGeneric(typeof(EntityFrameworkToOneRelatedResourceDocumentMaterializer<,>)); - builder.Register((ctx, parameters) => - { - var allParameters = parameters.ToArray(); - var typedParameters = allParameters.OfType().ToArray(); - var resourceTypeRegistrationParameter = - typedParameters.FirstOrDefault(tp => tp.Type == typeof(IResourceTypeRegistration)); - if (resourceTypeRegistrationParameter == null) - throw new Exception( - "An IResourceTypeRegistration parameter must be provided to resolve an instance of EntityFrameworkDocumentMaterializer."); - - var resourceTypeRegistration = resourceTypeRegistrationParameter.Value as IResourceTypeRegistration; - if (resourceTypeRegistration == null) - throw new Exception( - "An IResourceTypeRegistration parameter was provided to resolve EntityFrameworkDocumentMaterializer, but its value was null."); - - var resourceTypeRelationshipParameter = - typedParameters.FirstOrDefault(tp => tp.Type == typeof(ResourceTypeRelationship)); - if (resourceTypeRelationshipParameter == null) - throw new Exception( - "A ResourceTypeRelationship parameter must be provided to resolve an instance of EntityFrameworkDocumentMaterializer."); - - var resourceTypeRelationship = resourceTypeRelationshipParameter.Value as ResourceTypeRelationship; - if (resourceTypeRelationship == null) - throw new Exception( - "A ResourceTypeRelationship parameter was provided to resolve EntityFrameworkDocumentMaterializer, but its value was null."); - - var openGenericType = resourceTypeRelationship.IsToMany - ? typeof (EntityFrameworkToManyRelatedResourceDocumentMaterializer<,>) - : typeof (EntityFrameworkToOneRelatedResourceDocumentMaterializer<,>); - var materializerType = openGenericType.MakeGenericType(resourceTypeRegistration.Type, - resourceTypeRelationship.RelatedType); - return ctx.Resolve(materializerType, allParameters); - }).As(); - } - } -} diff --git a/JSONAPI.Autofac.EntityFramework/Properties/AssemblyInfo.cs b/JSONAPI.Autofac.EntityFramework/Properties/AssemblyInfo.cs deleted file mode 100644 index a30c9bd7..00000000 --- a/JSONAPI.Autofac.EntityFramework/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("JSONAPI.Autofac.EntityFramework")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("JSONAPI.Autofac.EntityFramework")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5c85a230-f640-43cf-ae30-b685d237a6dc")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/JSONAPI.Autofac.EntityFramework/app.config b/JSONAPI.Autofac.EntityFramework/app.config deleted file mode 100644 index b678ca2c..00000000 --- a/JSONAPI.Autofac.EntityFramework/app.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.Autofac.EntityFramework/packages.config b/JSONAPI.Autofac.EntityFramework/packages.config deleted file mode 100644 index f9427518..00000000 --- a/JSONAPI.Autofac.EntityFramework/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/JSONAPI.Autofac.Tests/JSONAPI.Autofac.Tests.csproj b/JSONAPI.Autofac.Tests/JSONAPI.Autofac.Tests.csproj deleted file mode 100644 index 8d82db0c..00000000 --- a/JSONAPI.Autofac.Tests/JSONAPI.Autofac.Tests.csproj +++ /dev/null @@ -1,89 +0,0 @@ - - - - Debug - AnyCPU - {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1} - Library - Properties - JSONAPI.Autofac.Tests - JSONAPI.Autofac.Tests - v4.5 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - {af7861f3-550b-4f70-a33e-1e5f48d39333} - JSONAPI.Autofac - - - - - - - False - - - False - - - False - - - False - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.Autofac.Tests/Properties/AssemblyInfo.cs b/JSONAPI.Autofac.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index e8bddb2b..00000000 --- a/JSONAPI.Autofac.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("JSONAPI.Autofac.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("JSONAPI.Autofac.Tests")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5755d01a-25ed-4be5-9f24-c9a659699558")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/JSONAPI.Autofac.Tests/UnitTest1.cs b/JSONAPI.Autofac.Tests/UnitTest1.cs deleted file mode 100644 index d7da0c41..00000000 --- a/JSONAPI.Autofac.Tests/UnitTest1.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.Autofac.Tests -{ - [TestClass] - public class UnitTest1 - { - [TestMethod] - public void TestMethod1() - { - } - } -} diff --git a/JSONAPI.Autofac/JSONAPI.Autofac.csproj b/JSONAPI.Autofac/JSONAPI.Autofac.csproj deleted file mode 100644 index d9dcafba..00000000 --- a/JSONAPI.Autofac/JSONAPI.Autofac.csproj +++ /dev/null @@ -1,95 +0,0 @@ - - - - - Debug - AnyCPU - {AF7861F3-550B-4F70-A33E-1E5F48D39333} - Library - Properties - JSONAPI.Autofac - JSONAPI.Autofac - v4.5 - 512 - ..\ - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - ..\packages\Autofac.3.5.2\lib\net40\Autofac.dll - - - False - ..\packages\Autofac.WebApi2.3.4.0\lib\net45\Autofac.Integration.WebApi.dll - - - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - - - - - - False - ..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll - - - False - ..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll - - - - - - - - - - - - - - - - - - - - {52b19fd6-efaa-45b5-9c3e-a652e27608d1} - JSONAPI - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/JSONAPI.Autofac/JsonApiAutofacModule.cs b/JSONAPI.Autofac/JsonApiAutofacModule.cs deleted file mode 100644 index dd248aa8..00000000 --- a/JSONAPI.Autofac/JsonApiAutofacModule.cs +++ /dev/null @@ -1,172 +0,0 @@ -using System; -using Autofac; -using Autofac.Core; -using JSONAPI.ActionFilters; -using JSONAPI.Configuration; -using JSONAPI.Core; -using JSONAPI.Documents; -using JSONAPI.Documents.Builders; -using JSONAPI.Http; -using JSONAPI.Json; -using JSONAPI.QueryableTransformers; - -namespace JSONAPI.Autofac -{ - public class JsonApiAutofacModule : Module - { - private readonly IJsonApiConfiguration _jsonApiConfiguration; - - public JsonApiAutofacModule(IJsonApiConfiguration jsonApiConfiguration) - { - _jsonApiConfiguration = jsonApiConfiguration; - } - - protected override void Load(ContainerBuilder builder) - { - // Register resource types - var registry = new ResourceTypeRegistry(); - foreach (var resourceTypeConfiguration in _jsonApiConfiguration.ResourceTypeConfigurations) - { - var resourceTypeRegistration = resourceTypeConfiguration.BuildResourceTypeRegistration(); - registry.AddRegistration(resourceTypeRegistration); - - var configuration = resourceTypeConfiguration; - builder.Register(c => configuration) - .Keyed(resourceTypeRegistration.Type) - .Keyed(resourceTypeRegistration.ResourceTypeName) - .SingleInstance(); - - if (resourceTypeConfiguration.DocumentMaterializerType != null) - builder.RegisterType(resourceTypeConfiguration.DocumentMaterializerType); - - foreach (var relationship in resourceTypeRegistration.Relationships) - { - IResourceTypeRelationshipConfiguration relationshipConfiguration; - if (resourceTypeConfiguration.RelationshipConfigurations - .TryGetValue(relationship.Property.Name, out relationshipConfiguration)) - { - if (relationshipConfiguration.MaterializerType != null) - { - builder.RegisterType(relationshipConfiguration.MaterializerType); - continue; - } - } - - // They didn't set an explicit materializer. See if they specified a factory for this resource type. - if (configuration.RelatedResourceMaterializerTypeFactory == null) continue; - - var materializerType = configuration.RelatedResourceMaterializerTypeFactory(relationship); - builder.RegisterType(materializerType); - } - } - - builder.Register(c => registry).As().SingleInstance(); - builder.Register(c => - { - var context = c.Resolve(); - Func factory = resourceTypeName => - { - var configuration = context.ResolveKeyed(resourceTypeName); - var registration = registry.GetRegistrationForResourceTypeName(resourceTypeName); - var parameters = new Parameter[] { new TypedParameter(typeof (IResourceTypeRegistration), registration) }; - if (configuration.DocumentMaterializerType != null) - return (IDocumentMaterializer)context.Resolve(configuration.DocumentMaterializerType, parameters); - return context.Resolve(parameters); - }; - return factory; - }); - builder.Register(c => - { - var context = c.Resolve(); - Func factory = clrType => - { - var configuration = context.ResolveKeyed(clrType); - var registration = registry.GetRegistrationForType(clrType); - var parameters = new Parameter[] { new TypedParameter(typeof(IResourceTypeRegistration), registration) }; - if (configuration.DocumentMaterializerType != null) - return (IDocumentMaterializer)context.Resolve(configuration.DocumentMaterializerType, parameters); - return context.Resolve(parameters); - }; - return factory; - }); - builder.Register(c => - { - var context = c.Resolve(); - Func factory = (resourceTypeName, relationshipName) => - { - var configuration = context.ResolveKeyed(resourceTypeName); - var registration = registry.GetRegistrationForResourceTypeName(resourceTypeName); - var relationship = registration.GetFieldByName(relationshipName) as ResourceTypeRelationship; - if (relationship == null) - throw JsonApiException.CreateForNotFound( - string.Format("No relationship `{0}` exists for the resource type `{1}`.", relationshipName, resourceTypeName)); - - var parameters = new Parameter[] - { - new TypedParameter(typeof(IResourceTypeRegistration), registration), - new TypedParameter(typeof(ResourceTypeRelationship), relationship) - }; - - // First, see if they have set an explicit materializer for this relationship - IResourceTypeRelationshipConfiguration relationshipConfiguration; - if (configuration.RelationshipConfigurations.TryGetValue(relationship.Property.Name, - out relationshipConfiguration) && relationshipConfiguration.MaterializerType != null) - return (IRelatedResourceDocumentMaterializer)context.Resolve(relationshipConfiguration.MaterializerType, parameters); - - // They didn't set an explicit materializer. See if they specified a factory for this resource type. - if (configuration.RelatedResourceMaterializerTypeFactory != null) - { - var materializerType = configuration.RelatedResourceMaterializerTypeFactory(relationship); - return (IRelatedResourceDocumentMaterializer)context.Resolve(materializerType, parameters); - } - - return context.Resolve(parameters); - }; - return factory; - }); - - builder.RegisterType().SingleInstance(); - if (_jsonApiConfiguration.CustomBaseUrlService != null) - { - builder.Register(c => _jsonApiConfiguration.CustomBaseUrlService).As().SingleInstance(); - } - else - { - builder.RegisterType().As().SingleInstance(); - } - builder.RegisterType().As().InstancePerRequest(); - - // Serialization - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - - // Queryable transforms - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - - // Document building - builder.Register(c => _jsonApiConfiguration.LinkConventions).As().SingleInstance(); - builder.RegisterType().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().SingleInstance(); - builder.RegisterType().SingleInstance(); - builder.RegisterType().As(); - - // Misc - builder.RegisterType().As().SingleInstance(); - builder.RegisterType().As().SingleInstance(); - } - } -} diff --git a/JSONAPI.Autofac/JsonApiConfigurationExtensions.cs b/JSONAPI.Autofac/JsonApiConfigurationExtensions.cs deleted file mode 100644 index 56622b0c..00000000 --- a/JSONAPI.Autofac/JsonApiConfigurationExtensions.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Web.Http; -using Autofac; -using Autofac.Integration.WebApi; -using JSONAPI.Configuration; - -namespace JSONAPI.Autofac -{ - public static class JsonApiConfigurationExtensions - { - public static void SetupHttpConfigurationUsingAutofac(this IJsonApiConfiguration configuration, - HttpConfiguration httpConfiguration, ILifetimeScope parentLifetimeScope) - { - var configurator = new JsonApiHttpAutofacConfigurator(parentLifetimeScope); - configurator.Apply(httpConfiguration, configuration); - } - } -} diff --git a/JSONAPI.Autofac/JsonApiHttpAutofacConfigurator.cs b/JSONAPI.Autofac/JsonApiHttpAutofacConfigurator.cs deleted file mode 100644 index 035f8c09..00000000 --- a/JSONAPI.Autofac/JsonApiHttpAutofacConfigurator.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Web.Http; -using Autofac; -using Autofac.Integration.WebApi; -using JSONAPI.Configuration; - -namespace JSONAPI.Autofac -{ - public class JsonApiHttpAutofacConfigurator - { - private readonly ILifetimeScope _lifetimeScope; - private Action _appLifetimeScopeCreating; - private Action _appLifetimeScopeBegunAction; - - public JsonApiHttpAutofacConfigurator() - { - } - - public JsonApiHttpAutofacConfigurator(ILifetimeScope lifetimeScope) - { - _lifetimeScope = lifetimeScope; - } - - public void OnApplicationLifetimeScopeCreating(Action appLifetimeScopeCreating) - { - _appLifetimeScopeCreating = appLifetimeScopeCreating; - } - - public void OnApplicationLifetimeScopeBegun(Action appLifetimeScopeBegunAction) - { - _appLifetimeScopeBegunAction = appLifetimeScopeBegunAction; - } - - public void Apply(HttpConfiguration httpConfiguration, IJsonApiConfiguration jsonApiConfiguration) - { - ILifetimeScope applicationLifetimeScope; - if (_lifetimeScope == null) - { - var builder = new ContainerBuilder(); - ConfigureApplicationLifetimeScope(jsonApiConfiguration, builder); - applicationLifetimeScope = builder.Build(); - } - else - { - applicationLifetimeScope = _lifetimeScope.BeginLifetimeScope(containerBuilder => - { - ConfigureApplicationLifetimeScope(jsonApiConfiguration, containerBuilder); - }); - } - - if (_appLifetimeScopeBegunAction != null) - _appLifetimeScopeBegunAction(applicationLifetimeScope); - - var jsonApiHttpConfiguration = applicationLifetimeScope.Resolve(); - jsonApiHttpConfiguration.Apply(httpConfiguration, jsonApiConfiguration); - httpConfiguration.DependencyResolver = new AutofacWebApiDependencyResolver(applicationLifetimeScope); - } - - private void ConfigureApplicationLifetimeScope(IJsonApiConfiguration jsonApiConfiguration, ContainerBuilder containerBuilder) - { - var module = new JsonApiAutofacModule(jsonApiConfiguration); - containerBuilder.RegisterModule(module); - - if (_appLifetimeScopeCreating != null) - _appLifetimeScopeCreating(containerBuilder); - } - } -} diff --git a/JSONAPI.Autofac/Properties/AssemblyInfo.cs b/JSONAPI.Autofac/Properties/AssemblyInfo.cs deleted file mode 100644 index 9804046c..00000000 --- a/JSONAPI.Autofac/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("JSONAPI.Autofac")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("JSONAPI.Autofac")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("868ac502-6972-4889-bcbd-9d6160258667")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/JSONAPI.Autofac/app.config b/JSONAPI.Autofac/app.config deleted file mode 100644 index b678ca2c..00000000 --- a/JSONAPI.Autofac/app.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.Autofac/packages.config b/JSONAPI.Autofac/packages.config deleted file mode 100644 index 2ad7611f..00000000 --- a/JSONAPI.Autofac/packages.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.EntityFramework.Tests/ActionFilters/AsynchronousEnumerationTransformerTests.cs b/JSONAPI.EntityFramework.Tests/ActionFilters/AsynchronousEnumerationTransformerTests.cs deleted file mode 100644 index 609c95ed..00000000 --- a/JSONAPI.EntityFramework.Tests/ActionFilters/AsynchronousEnumerationTransformerTests.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data.Entity; -using System.Data.Entity.Infrastructure; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Net.Http.Formatting; -using System.Threading; -using System.Threading.Tasks; -using System.Web.Http.Controllers; -using System.Web.Http.Filters; -using FluentAssertions; -using JSONAPI.EntityFramework.ActionFilters; -using JSONAPI.EntityFramework.Tests.Helpers; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; - -namespace JSONAPI.EntityFramework.Tests.ActionFilters -{ - [TestClass] - public class AsynchronousEnumerationTransformerTests - { - public class Dummy - { - public string Id { get; set; } - - public string Name { get; set; } - } - - private IQueryable _fixtures; - - [TestInitialize] - public void SetupFixtures() - { - _fixtures = new List() - { - new Dummy - { - Id = "1", - Name = "Blue" - }, - new Dummy - { - Id = "2", - Name = "Red" - }, - new Dummy - { - Id = "3", - Name = "Green" - } - }.AsQueryable(); - } - - private IQueryable CreateQueryable(IDbAsyncEnumerator asyncEnumerator) - { - var mockSet = new Mock>(); - mockSet.As>() - .Setup(m => m.GetAsyncEnumerator()) - .Returns(asyncEnumerator); - - mockSet.As>() - .Setup(m => m.Provider) - .Returns(new TestDbAsyncQueryProvider(_fixtures.Provider)); - - mockSet.As>().Setup(m => m.Expression).Returns(_fixtures.Expression); - mockSet.As>().Setup(m => m.ElementType).Returns(_fixtures.ElementType); - mockSet.As>().Setup(m => m.GetEnumerator()).Returns(_fixtures.GetEnumerator()); - - return mockSet.Object; - } - - [TestMethod] - public async Task ResolvesQueryable() - { - var transformer = new AsynchronousEnumerationTransformer(); - - var query = CreateQueryable(new TestDbAsyncEnumerator(_fixtures.GetEnumerator())); - - var array = await transformer.Enumerate(query, new CancellationToken()); - array.Should().NotBeNull(); - array.Length.Should().Be(3); - array[0].Id.Should().Be("1"); - array[1].Id.Should().Be("2"); - array[2].Id.Should().Be("3"); - } - - [TestMethod] - public void CancelsProperly() - { - var actionFilter = new AsynchronousEnumerationTransformer(); - - var context = CreateQueryable(new WaitsUntilCancellationDbAsyncEnumerator(1000, _fixtures.GetEnumerator())); - - var cts = new CancellationTokenSource(); - cts.CancelAfter(300); - - Func action = async () => - { - await actionFilter.Enumerate(context, cts.Token); - }; - action.ShouldThrow(); - } - } -} diff --git a/JSONAPI.EntityFramework.Tests/App.Config b/JSONAPI.EntityFramework.Tests/App.Config deleted file mode 100644 index 75b64305..00000000 --- a/JSONAPI.EntityFramework.Tests/App.Config +++ /dev/null @@ -1,56 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.EntityFramework.Tests/Data/Comment.json b/JSONAPI.EntityFramework.Tests/Data/Comment.json deleted file mode 100644 index e8726ef5..00000000 --- a/JSONAPI.EntityFramework.Tests/Data/Comment.json +++ /dev/null @@ -1 +0,0 @@ -{"comments":[{"id":29,"body":"Nuh uh!"}]} \ No newline at end of file diff --git a/JSONAPI.EntityFramework.Tests/Data/Post.json b/JSONAPI.EntityFramework.Tests/Data/Post.json deleted file mode 100644 index ec05585e..00000000 --- a/JSONAPI.EntityFramework.Tests/Data/Post.json +++ /dev/null @@ -1,2 +0,0 @@ -{"posts":[{"id": "{{GUID}}", "title": "Not at all linkbait!" } ] -} diff --git a/JSONAPI.EntityFramework.Tests/DbContextExtensionsTests.cs b/JSONAPI.EntityFramework.Tests/DbContextExtensionsTests.cs deleted file mode 100644 index 8548b6bd..00000000 --- a/JSONAPI.EntityFramework.Tests/DbContextExtensionsTests.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Data.Common; -using System.Linq; -using Effort; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using JSONAPI.EntityFramework.Tests.Models; -using FluentAssertions; -using System.Collections.Generic; -using System.Data.Entity; - -namespace JSONAPI.EntityFramework.Tests -{ - [TestClass] - public class DbContextExtensionsTests - { - private class TestDbContext : DbContext - { - public DbSet Backlinks { get; set; } - public DbSet Posts { get; set; } - public DbSet PostIDs { get; set; } - - public TestDbContext(DbConnection conn) : base(conn, true) - { - - } - } - - private class NotAnEntity - { - public string Id { get; set; } - public string Temporary { get; set; } - } - - private class SubPost : Post - { - public string Foo { get; set; } - } - private class SubPostID : PostID - { - public string Foo { get; set; } - } - - private DbConnection _conn; - private TestDbContext _context; - - [TestInitialize] - public void SetupEntities() - { - _conn = DbConnectionFactory.CreateTransient(); - _context = new TestDbContext(_conn); - - var b1 = new Backlink - { - Url = "http://www.google.com/", - Snippet = "1 Results" - }; - _context.Backlinks.Add(b1); - - _context.SaveChanges(); - } - - [TestCleanup] - private void CleanupTest() - { - _context.Dispose(); - } - - [TestMethod] - public void GetKeyNamesStandardIdTest() - { - // Act - IEnumerable keyNames = _context.GetKeyNames(typeof(Post)).ToArray(); - - // Assert - keyNames.Count().Should().Be(1); - keyNames.First().Should().Be("Id"); - } - - [TestMethod] - public void GetKeyNamesStandardIDTest() - { - // Act - IEnumerable keyNames = _context.GetKeyNames(typeof(PostID)).ToArray(); - - // Assert - keyNames.Count().Should().Be(1); - keyNames.First().Should().Be("ID"); - } - - [TestMethod] - public void GetKeyNamesNonStandardIdTest() - { - // Act - IEnumerable keyNames = _context.GetKeyNames(typeof(Backlink)).ToArray(); - - // Assert - keyNames.Count().Should().Be(1); - keyNames.First().Should().Be("Url"); - } - - [TestMethod] - public void GetKeyNamesForChildClass() - { - // Act - IEnumerable keyNames = _context.GetKeyNames(typeof(SubPost)).ToArray(); - - // Assert - keyNames.Count().Should().Be(1); - keyNames.First().Should().Be("Id"); - } - - [TestMethod] - public void GetKeyNamesForChildClassID() - { - // Act - IEnumerable keyNames = _context.GetKeyNames(typeof(SubPostID)).ToArray(); - - // Assert - keyNames.Count().Should().Be(1); - keyNames.First().Should().Be("ID"); - } - - [TestMethod] - public void GetKeyNamesNotAnEntityTest() - { - // Act - Action action = () => _context.GetKeyNames(typeof (NotAnEntity)); - action.ShouldThrow().Which.Message.Should().Be("Failed to identify the key names for NotAnEntity or any of its parent classes."); - } - } -} diff --git a/JSONAPI.EntityFramework.Tests/Helpers/TestDbAsyncEnumerable.cs b/JSONAPI.EntityFramework.Tests/Helpers/TestDbAsyncEnumerable.cs deleted file mode 100644 index 8ba6f0c7..00000000 --- a/JSONAPI.EntityFramework.Tests/Helpers/TestDbAsyncEnumerable.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Collections.Generic; -using System.Data.Entity.Infrastructure; -using System.Linq; -using System.Linq.Expressions; - -namespace JSONAPI.EntityFramework.Tests.Helpers -{ - internal class TestDbAsyncEnumerable : EnumerableQuery, IDbAsyncEnumerable, IQueryable - { - public TestDbAsyncEnumerable(IEnumerable enumerable) - : base(enumerable) - { } - - public TestDbAsyncEnumerable(Expression expression) - : base(expression) - { } - - public IDbAsyncEnumerator GetAsyncEnumerator() - { - return new TestDbAsyncEnumerator(this.AsEnumerable().GetEnumerator()); - } - - IDbAsyncEnumerator IDbAsyncEnumerable.GetAsyncEnumerator() - { - return GetAsyncEnumerator(); - } - - IQueryProvider IQueryable.Provider - { - get { return new TestDbAsyncQueryProvider(this); } - } - } -} diff --git a/JSONAPI.EntityFramework.Tests/Helpers/TestDbAsyncEnumerator.cs b/JSONAPI.EntityFramework.Tests/Helpers/TestDbAsyncEnumerator.cs deleted file mode 100644 index 4d0ab3bc..00000000 --- a/JSONAPI.EntityFramework.Tests/Helpers/TestDbAsyncEnumerator.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Collections.Generic; -using System.Data.Entity.Infrastructure; -using System.Threading; -using System.Threading.Tasks; - -namespace JSONAPI.EntityFramework.Tests.Helpers -{ - internal class TestDbAsyncEnumerator : IDbAsyncEnumerator - { - private readonly IEnumerator _inner; - - public TestDbAsyncEnumerator(IEnumerator inner) - { - _inner = inner; - } - - public void Dispose() - { - _inner.Dispose(); - } - - public Task MoveNextAsync(CancellationToken cancellationToken) - { - return Task.FromResult(_inner.MoveNext()); - } - - public T Current - { - get { return _inner.Current; } - } - - object IDbAsyncEnumerator.Current - { - get { return Current; } - } - } -} diff --git a/JSONAPI.EntityFramework.Tests/Helpers/TestDbAsyncQueryProvider.cs b/JSONAPI.EntityFramework.Tests/Helpers/TestDbAsyncQueryProvider.cs deleted file mode 100644 index fad64f4e..00000000 --- a/JSONAPI.EntityFramework.Tests/Helpers/TestDbAsyncQueryProvider.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Data.Entity.Infrastructure; -using System.Linq; -using System.Linq.Expressions; -using System.Threading; -using System.Threading.Tasks; - -namespace JSONAPI.EntityFramework.Tests.Helpers -{ - internal class TestDbAsyncQueryProvider : IDbAsyncQueryProvider - { - private readonly IQueryProvider _inner; - - internal TestDbAsyncQueryProvider(IQueryProvider inner) - { - _inner = inner; - } - - public IQueryable CreateQuery(Expression expression) - { - return new TestDbAsyncEnumerable(expression); - } - - public IQueryable CreateQuery(Expression expression) - { - return new TestDbAsyncEnumerable(expression); - } - - public object Execute(Expression expression) - { - return _inner.Execute(expression); - } - - public TResult Execute(Expression expression) - { - return _inner.Execute(expression); - } - - public Task ExecuteAsync(Expression expression, CancellationToken cancellationToken) - { - return Task.FromResult(Execute(expression)); - } - - public Task ExecuteAsync(Expression expression, CancellationToken cancellationToken) - { - return Task.FromResult(Execute(expression)); - } - } -} diff --git a/JSONAPI.EntityFramework.Tests/Helpers/WaitsUntilCancellationDbAsyncEnumerator.cs b/JSONAPI.EntityFramework.Tests/Helpers/WaitsUntilCancellationDbAsyncEnumerator.cs deleted file mode 100644 index eda34dfe..00000000 --- a/JSONAPI.EntityFramework.Tests/Helpers/WaitsUntilCancellationDbAsyncEnumerator.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Collections.Generic; -using System.Data.Entity.Infrastructure; -using System.Threading; -using System.Threading.Tasks; - -namespace JSONAPI.EntityFramework.Tests.Helpers -{ - internal class WaitsUntilCancellationDbAsyncEnumerator : IDbAsyncEnumerator - { - private readonly int _timeout; - private readonly IEnumerator _inner; - - public WaitsUntilCancellationDbAsyncEnumerator(int timeout, IEnumerator inner) - { - _timeout = timeout; - _inner = inner; - } - - public void Dispose() - { - _inner.Dispose(); - } - - public async Task MoveNextAsync(CancellationToken cancellationToken) - { - await Task.Delay(_timeout, cancellationToken); - - return _inner.MoveNext(); - } - - public T Current - { - get { return _inner.Current; } - } - - object IDbAsyncEnumerator.Current - { - get { return Current; } - } - } -} diff --git a/JSONAPI.EntityFramework.Tests/JSONAPI.EntityFramework.Tests.csproj b/JSONAPI.EntityFramework.Tests/JSONAPI.EntityFramework.Tests.csproj deleted file mode 100644 index 6e341345..00000000 --- a/JSONAPI.EntityFramework.Tests/JSONAPI.EntityFramework.Tests.csproj +++ /dev/null @@ -1,171 +0,0 @@ - - - - Debug - AnyCPU - - - 2.0 - {00655E05-F1BB-425D-92F3-659EFB581439} - Library - Properties - JSONAPI.EntityFramework.Tests - JSONAPI.EntityFramework.Tests - v4.5 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - - ..\ - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - - False - ..\packages\Effort.EF6.1.1.4\lib\net45\Effort.dll - - - False - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll - - - False - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll - - - False - ..\packages\FluentAssertions.3.2.2\lib\net45\FluentAssertions.dll - - - False - ..\packages\FluentAssertions.3.2.2\lib\net45\FluentAssertions.Core.dll - - - ..\packages\Microsoft.Owin.3.0.0\lib\net45\Microsoft.Owin.dll - - - ..\packages\Microsoft.Owin.Hosting.3.0.0\lib\net45\Microsoft.Owin.Hosting.dll - - - ..\packages\Microsoft.Owin.Testing.3.0.0\lib\net45\Microsoft.Owin.Testing.dll - - - - False - ..\packages\Moq.4.2.1502.0911\lib\net40\Moq.dll - - - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - - - False - ..\packages\NMemory.1.0.1\lib\net45\NMemory.dll - - - ..\packages\Owin.1.0\lib\net40\Owin.dll - - - - - 3.5 - - - - - False - ..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll - - - - - - False - ..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll - - - - - - - False - - - - - - - - - - - - - - - - - - - Designer - - - Always - - - Always - - - - - - {76dee472-723b-4be6-8b97-428ac326e30f} - JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp - - - {E906356C-93F6-41F6-9A0D-73B8A99AA53C} - JSONAPI.EntityFramework - - - {52B19FD6-EFAA-45B5-9C3E-A652E27608D1} - JSONAPI - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/JSONAPI.EntityFramework.Tests/Models/Author.cs b/JSONAPI.EntityFramework.Tests/Models/Author.cs deleted file mode 100644 index 826c02dd..00000000 --- a/JSONAPI.EntityFramework.Tests/Models/Author.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace JSONAPI.EntityFramework.Tests.Models -{ - using System; - using System.Collections.Generic; - - public partial class Author - { - public Author() - { - this.Posts = new HashSet(); - } - - public string Id { get; set; } - public string Name { get; set; } - - public virtual ICollection Posts { get; set; } - } -} diff --git a/JSONAPI.EntityFramework.Tests/Models/Backlink.cs b/JSONAPI.EntityFramework.Tests/Models/Backlink.cs deleted file mode 100644 index 168f19be..00000000 --- a/JSONAPI.EntityFramework.Tests/Models/Backlink.cs +++ /dev/null @@ -1,18 +0,0 @@ -using JSONAPI.Attributes; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace JSONAPI.EntityFramework.Tests.Models -{ - public class Backlink - { - [UseAsId] - [System.ComponentModel.DataAnnotations.Key] - public string Url { get; set; } - - public Post Post { get; set; } - public string Snippet { get; set; } - } -} diff --git a/JSONAPI.EntityFramework.Tests/Models/Comment.cs b/JSONAPI.EntityFramework.Tests/Models/Comment.cs deleted file mode 100644 index d88430b7..00000000 --- a/JSONAPI.EntityFramework.Tests/Models/Comment.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace JSONAPI.EntityFramework.Tests.Models -{ - using System; - using System.Collections.Generic; - - public partial class Comment - { - public int Id { get; set; } - public string Body { get; set; } - - public virtual Post Post { get; set; } - } -} diff --git a/JSONAPI.EntityFramework.Tests/Models/Post.cs b/JSONAPI.EntityFramework.Tests/Models/Post.cs deleted file mode 100644 index 44bc0440..00000000 --- a/JSONAPI.EntityFramework.Tests/Models/Post.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace JSONAPI.EntityFramework.Tests.Models -{ - using System; - using System.Collections.Generic; - using System.ComponentModel.DataAnnotations.Schema; - - public partial class Post - { - public Post() - { - this.Comments = new HashSet(); - } - - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public Guid Id { get; set; } - public string Title { get; set; } - - public virtual Author Author { get; set; } - public virtual ICollection Comments { get; set; } - } -} diff --git a/JSONAPI.EntityFramework.Tests/Models/PostID.cs b/JSONAPI.EntityFramework.Tests/Models/PostID.cs deleted file mode 100644 index 420e047a..00000000 --- a/JSONAPI.EntityFramework.Tests/Models/PostID.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace JSONAPI.EntityFramework.Tests.Models -{ - using System; - using System.Collections.Generic; - using System.ComponentModel.DataAnnotations.Schema; - - public partial class PostID - { - public PostID() - { - this.Comments = new HashSet(); - } - - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public Guid ID { get; set; } - public string Title { get; set; } - - public virtual Author Author { get; set; } - public virtual ICollection Comments { get; set; } - } -} diff --git a/JSONAPI.EntityFramework.Tests/Properties/AssemblyInfo.cs b/JSONAPI.EntityFramework.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index a78b280a..00000000 --- a/JSONAPI.EntityFramework.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("JSONAPI.EntityFramework.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("ERMC")] -[assembly: AssemblyProduct("JSONAPI.EntityFramework.Tests")] -[assembly: AssemblyCopyright("Copyright © ERMC 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("96c8ac31-7cd7-41ee-805d-5c4694dcb846")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/JSONAPI.EntityFramework.Tests/packages.config b/JSONAPI.EntityFramework.Tests/packages.config deleted file mode 100644 index a5ce68c2..00000000 --- a/JSONAPI.EntityFramework.Tests/packages.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.EntityFramework/ActionFilters/AsynchronousEnumerationTransformer.cs b/JSONAPI.EntityFramework/ActionFilters/AsynchronousEnumerationTransformer.cs deleted file mode 100644 index f6efe4c3..00000000 --- a/JSONAPI.EntityFramework/ActionFilters/AsynchronousEnumerationTransformer.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Data.Entity; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.QueryableTransformers; - -namespace JSONAPI.EntityFramework.ActionFilters -{ - /// - /// Enumerates an IQueryable asynchronously using Entity Framework's ToArrayAsync() method. - /// - public class AsynchronousEnumerationTransformer : IQueryableEnumerationTransformer - { - public async Task Enumerate(IQueryable query, CancellationToken cancellationToken) - { - return await query.ToArrayAsync(cancellationToken); - } - - public async Task FirstOrDefault(IQueryable query, CancellationToken cancellationToken) - { - return await query.FirstOrDefaultAsync(cancellationToken); - } - } -} diff --git a/JSONAPI.EntityFramework/App.config b/JSONAPI.EntityFramework/App.config deleted file mode 100644 index 5dcb1e0c..00000000 --- a/JSONAPI.EntityFramework/App.config +++ /dev/null @@ -1,37 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.EntityFramework/Configuration/JsonApiAutofacConfigurationExtensions.cs b/JSONAPI.EntityFramework/Configuration/JsonApiAutofacConfigurationExtensions.cs deleted file mode 100644 index eca72b87..00000000 --- a/JSONAPI.EntityFramework/Configuration/JsonApiAutofacConfigurationExtensions.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using JSONAPI.Configuration; -using JSONAPI.EntityFramework.Http; - -namespace JSONAPI.EntityFramework.Configuration -{ - public static class JsonApiConfigurationExtensions - { - public static void RegisterEntityFrameworkResourceType(this JsonApiConfiguration jsonApiConfiguration, - Action> configurationAction = null) where TResourceType : class - { - jsonApiConfiguration.RegisterResourceType(c => - { - c.UseDocumentMaterializer>(); - if (configurationAction != null) - configurationAction(c); - }); - } - } -} diff --git a/JSONAPI.EntityFramework/DbContextExtensions.cs b/JSONAPI.EntityFramework/DbContextExtensions.cs deleted file mode 100644 index 37724b77..00000000 --- a/JSONAPI.EntityFramework/DbContextExtensions.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data.Entity; -using System.Data.Entity.Core.Objects; -using System.Data.Entity.Infrastructure; -using System.Linq; -using System.Reflection; - -namespace JSONAPI.EntityFramework -{ - /// - /// Extensions on DbContext useful for JSONAPI.NET - /// - public static class DbContextExtensions - { - /// - /// Gets the ID key names for an entity type - /// - /// - /// - /// - public static IEnumerable GetKeyNames(this DbContext dbContext, Type type) - { - if (dbContext == null) throw new ArgumentNullException("dbContext"); - if (type == null) throw new ArgumentNullException("type"); - - var originalType = type; - - while (type != null) - { - var openMethod = typeof(DbContextExtensions).GetMethod("GetKeyNamesFromGeneric", BindingFlags.Public | BindingFlags.Static); - var method = openMethod.MakeGenericMethod(type); - - try - { - return (IEnumerable) method.Invoke(null, new object[] {dbContext}); - } - catch (TargetInvocationException) - { - } - - type = type.BaseType; - } - - throw new Exception(string.Format("Failed to identify the key names for {0} or any of its parent classes.", originalType.Name)); - } - - /// - /// Gets the ID key names for an entity type - /// - /// - /// - /// - /// - public static IEnumerable GetKeyNamesFromGeneric(this DbContext dbContext) where T : class - { - var objectContext = ((IObjectContextAdapter)dbContext).ObjectContext; - ObjectSet objectSet; - try - { - objectSet = objectContext.CreateObjectSet(); - - } - catch (InvalidOperationException e) - { - throw new ArgumentException( - String.Format("The Type {0} was not found in the DbContext with Type {1}", typeof(T).Name, dbContext.GetType().Name), - e - ); - } - return objectSet.EntitySet.ElementType.KeyMembers.Select(k => k.Name).ToArray(); - } - - } -} diff --git a/JSONAPI.EntityFramework/Documents/Builders/EntityFrameworkQueryableResourceCollectionDocumentBuilder.cs b/JSONAPI.EntityFramework/Documents/Builders/EntityFrameworkQueryableResourceCollectionDocumentBuilder.cs deleted file mode 100644 index 1bd9e2c8..00000000 --- a/JSONAPI.EntityFramework/Documents/Builders/EntityFrameworkQueryableResourceCollectionDocumentBuilder.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Data.Entity; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.Documents; -using JSONAPI.Documents.Builders; -using JSONAPI.Http; -using JSONAPI.QueryableTransformers; - -namespace JSONAPI.EntityFramework.Documents.Builders -{ - /// - /// Provides a entity framework implementation of an IQueryableResourceCollectionDocumentBuilder - /// - public class EntityFrameworkQueryableResourceCollectionDocumentBuilder: DefaultQueryableResourceCollectionDocumentBuilder - { - /// - /// Creates a new EntityFrameworkQueryableResourceCollectionDocumentBuilder - /// - public EntityFrameworkQueryableResourceCollectionDocumentBuilder( - IResourceCollectionDocumentBuilder resourceCollectionDocumentBuilder, - IQueryableEnumerationTransformer enumerationTransformer, - IQueryableFilteringTransformer filteringTransformer, - IQueryableSortingTransformer sortingTransformer, - IQueryablePaginationTransformer paginationTransformer, - IBaseUrlService baseUrlService) : - base(resourceCollectionDocumentBuilder, - enumerationTransformer, - filteringTransformer, - sortingTransformer, - paginationTransformer, - baseUrlService) - { - } - - /// - /// Returns the metadata that should be sent with this document. - /// - protected override async Task GetDocumentMetadata(IQueryable originalQuery, IQueryable filteredQuery, IOrderedQueryable sortedQuery, - IPaginationTransformResult paginationResult, CancellationToken cancellationToken) - { - var metadata = new Metadata(); - if (paginationResult.PaginationWasApplied) - { - var count = await filteredQuery.CountAsync(cancellationToken); - metadata.MetaObject.Add("total-pages", (int)Math.Ceiling((decimal) count / paginationResult.PageSize)); - metadata.MetaObject.Add("total-count", count); - } - if (metadata.MetaObject.HasValues) - return metadata; - return null; - } - } -} diff --git a/JSONAPI.EntityFramework/EntityFrameworkPluralizationService.cs b/JSONAPI.EntityFramework/EntityFrameworkPluralizationService.cs deleted file mode 100644 index 05739362..00000000 --- a/JSONAPI.EntityFramework/EntityFrameworkPluralizationService.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using JSONAPI.Core; - -namespace JSONAPI.EntityFramework -{ - /// - /// Implementation of IPluralizationService that uses EntityFramework's built-in EnglishPluralizationService - /// - public class EntityFrameworkPluralizationService : IPluralizationService - { - private static readonly Lazy _pls - = new Lazy( - () => new System.Data.Entity.Infrastructure.Pluralization.EnglishPluralizationService() - ); - public string Pluralize(string s) - { - return _pls.Value.Pluralize(s); - } - public string Singularize(string s) - { - return _pls.Value.Singularize(s); - } - } -} diff --git a/JSONAPI.EntityFramework/EntityFrameworkResourceObjectMaterializer.cs b/JSONAPI.EntityFramework/EntityFrameworkResourceObjectMaterializer.cs deleted file mode 100644 index b0b26ea9..00000000 --- a/JSONAPI.EntityFramework/EntityFrameworkResourceObjectMaterializer.cs +++ /dev/null @@ -1,221 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data.Entity; -using System.Linq; -using System.Linq.Expressions; -using System.Reflection; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.Core; -using JSONAPI.Documents; -using JSONAPI.Json; - -namespace JSONAPI.EntityFramework -{ - /// - /// Default implementation of IEntityFrameworkResourceObjectMaterializer - /// - public class EntityFrameworkResourceObjectMaterializer : IEntityFrameworkResourceObjectMaterializer - { - private readonly DbContext _dbContext; - private readonly IResourceTypeRegistry _registry; - private readonly MethodInfo _openSetToManyRelationshipValueMethod; - private readonly MethodInfo _openGetExistingRecordGenericMethod; - - /// - /// Creates a new EntityFrameworkEntityFrameworkResourceObjectMaterializer - /// - /// - /// - public EntityFrameworkResourceObjectMaterializer(DbContext dbContext, IResourceTypeRegistry registry) - { - _dbContext = dbContext; - _registry = registry; - _openSetToManyRelationshipValueMethod = GetType() - .GetMethod("SetToManyRelationshipValue", BindingFlags.NonPublic | BindingFlags.Instance); - _openGetExistingRecordGenericMethod = GetType() - .GetMethod("GetExistingRecordGeneric", BindingFlags.NonPublic | BindingFlags.Instance); - } - - public async Task MaterializeResourceObject(IResourceObject resourceObject, CancellationToken cancellationToken) - { - var registration = _registry.GetRegistrationForResourceTypeName(resourceObject.Type); - - var relationshipsToInclude = new List(); - if (resourceObject.Relationships != null) - { - relationshipsToInclude.AddRange( - resourceObject.Relationships - .Select(relationshipObject => registration.GetFieldByName(relationshipObject.Key)) - .OfType()); - } - - - var material = await GetExistingRecord(registration, resourceObject.Id, relationshipsToInclude.ToArray(), cancellationToken); - if (material == null) - { - material = Activator.CreateInstance(registration.Type); - await SetIdForNewResource(resourceObject, material, registration); - _dbContext.Set(registration.Type).Add(material); - } - - await MergeFieldsIntoProperties(resourceObject, material, registration, cancellationToken); - - return material; - } - - /// - /// Allows implementers to control how a new resource's ID should be set. - /// - protected virtual Task SetIdForNewResource(IResourceObject resourceObject, object newObject, IResourceTypeRegistration typeRegistration) - { - if (resourceObject.Id != null) - { - typeRegistration.IdProperty.SetValue(newObject, Convert.ChangeType(resourceObject.Id, typeRegistration.IdProperty.PropertyType)); - } - return Task.FromResult(0); - } - - /// - /// Gets an existing record from the store by ID, if it exists - /// - /// - protected virtual async Task GetExistingRecord(IResourceTypeRegistration registration, string id, - ResourceTypeRelationship[] relationshipsToInclude, CancellationToken cancellationToken) - { - var method = _openGetExistingRecordGenericMethod.MakeGenericMethod(registration.Type); - var result = (dynamic) method.Invoke(this, new object[] {registration, id, relationshipsToInclude, cancellationToken}); // no convert needed => see GetExistingRecordGeneric => filterByIdFactory will do it - return await result; - } - - /// - /// Merges the field values of the given resource object into the materialized object - /// - /// - /// - /// - /// - /// - /// Thrown when a semantically incorrect part of the document is encountered - protected virtual async Task MergeFieldsIntoProperties(IResourceObject resourceObject, object material, - IResourceTypeRegistration registration, CancellationToken cancellationToken) - { - foreach (var attributeValue in resourceObject.Attributes) - { - var attribute = registration.GetFieldByName(attributeValue.Key) as ResourceTypeAttribute; - if (attribute == null) continue; - attribute.SetValue(material, attributeValue.Value); - } - - foreach (var relationshipValue in resourceObject.Relationships) - { - var linkage = relationshipValue.Value.Linkage; - - var typeRelationship = registration.GetFieldByName(relationshipValue.Key) as ResourceTypeRelationship; - if (typeRelationship == null) continue; - - if (typeRelationship.IsToMany) - { - if (linkage == null) - throw new DeserializationException("Missing linkage for to-many relationship", - "Expected an array for to-many linkage, but no linkage was specified.", "/data/relationships/" + relationshipValue.Key); - - if (!linkage.IsToMany) - throw new DeserializationException("Invalid linkage for to-many relationship", - "Expected an array for to-many linkage.", - "/data/relationships/" + relationshipValue.Key + "/data"); - - // TODO: One query per related object is going to be slow. At the very least, we should be able to group the queries by type - var newCollection = new List(); - foreach (var resourceIdentifier in linkage.Identifiers) - { - var relatedObjectRegistration = _registry.GetRegistrationForResourceTypeName(resourceIdentifier.Type); - var relatedObject = await GetExistingRecord(relatedObjectRegistration, resourceIdentifier.Id, null, cancellationToken); - newCollection.Add(relatedObject); - } - - var method = _openSetToManyRelationshipValueMethod.MakeGenericMethod(typeRelationship.RelatedType); - method.Invoke(this, new[] { material, newCollection, typeRelationship }); - } - else - { - if (linkage == null) - throw new DeserializationException("Missing linkage for to-one relationship", - "Expected an object for to-one linkage, but no linkage was specified.", "/data/relationships/" + relationshipValue.Key); - - if (linkage.IsToMany) - throw new DeserializationException("Invalid linkage for to-one relationship", - "Expected an object or null for to-one linkage", - "/data/relationships/" + relationshipValue.Key + "/data"); - - var identifier = linkage.Identifiers.FirstOrDefault(); - if (identifier == null) - { - typeRelationship.Property.SetValue(material, null); - } - else - { - var relatedObjectRegistration = _registry.GetRegistrationForResourceTypeName(identifier.Type); - var relatedObject = - await GetExistingRecord(relatedObjectRegistration, identifier.Id, null, cancellationToken); - - typeRelationship.Property.SetValue(material, relatedObject); - } - } - } - } - - /// - /// Gets a record by ID - /// - protected async Task GetExistingRecordGeneric(IResourceTypeRegistration registration, - string id, ResourceTypeRelationship[] relationshipsToInclude, CancellationToken cancellationToken) where TRecord : class - { - var param = Expression.Parameter(registration.Type); - var filterExpression = registration.GetFilterByIdExpression(param, id); // no conversion of id => filterByIdFactory will do it - var lambda = Expression.Lambda>(filterExpression, param); - var query = _dbContext.Set().AsQueryable() - .Where(lambda); - - if (relationshipsToInclude != null) - { - query = relationshipsToInclude.Aggregate(query, - (current, resourceTypeRelationship) => current.Include(resourceTypeRelationship.Property.Name)); - } - - return await query.FirstOrDefaultAsync(cancellationToken); - } - - /// - /// Sets the value of a to-many relationship - /// - protected void SetToManyRelationshipValue(object material, IEnumerable relatedObjects, ResourceTypeRelationship relationship) - { - var currentValue = relationship.Property.GetValue(material); - var typedArray = relatedObjects.Select(o => (TRelated) o).ToArray(); - if (relationship.Property.PropertyType.IsAssignableFrom(typeof (List))) - { - if (currentValue == null) - { - relationship.Property.SetValue(material, typedArray.ToList()); - } - else - { - var listCurrentValue = (ICollection) currentValue; - var itemsToAdd = typedArray.Except(listCurrentValue); - var itemsToRemove = listCurrentValue.Except(typedArray).ToList(); - - foreach (var related in itemsToAdd) - listCurrentValue.Add(related); - - foreach (var related in itemsToRemove) - listCurrentValue.Remove(related); - } - } - else - { - relationship.Property.SetValue(material, typedArray); - } - } - } -} diff --git a/JSONAPI.EntityFramework/Http/EntityFrameworkDocumentMaterializer.cs b/JSONAPI.EntityFramework/Http/EntityFrameworkDocumentMaterializer.cs deleted file mode 100644 index 114f7877..00000000 --- a/JSONAPI.EntityFramework/Http/EntityFrameworkDocumentMaterializer.cs +++ /dev/null @@ -1,202 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data.Entity; -using System.Linq; -using System.Linq.Expressions; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.Core; -using JSONAPI.Documents; -using JSONAPI.Documents.Builders; -using JSONAPI.Extensions; -using JSONAPI.Http; - -namespace JSONAPI.EntityFramework.Http -{ - /// - /// Implementation of IDocumentMaterializer for use with Entity Framework. - /// - public class EntityFrameworkDocumentMaterializer : IDocumentMaterializer where T : class - { - protected readonly DbContext DbContext; - private readonly IResourceTypeRegistration _resourceTypeRegistration; - private readonly IQueryableResourceCollectionDocumentBuilder _queryableResourceCollectionDocumentBuilder; - private readonly ISingleResourceDocumentBuilder _singleResourceDocumentBuilder; - private readonly IEntityFrameworkResourceObjectMaterializer _entityFrameworkResourceObjectMaterializer; - private readonly ISortExpressionExtractor _sortExpressionExtractor; - private readonly IIncludeExpressionExtractor _includeExpressionExtractor; - private readonly IBaseUrlService _baseUrlService; - - /// - /// Creates a new EntityFrameworkDocumentMaterializer - /// - public EntityFrameworkDocumentMaterializer( - DbContext dbContext, - IResourceTypeRegistration resourceTypeRegistration, - IQueryableResourceCollectionDocumentBuilder queryableResourceCollectionDocumentBuilder, - ISingleResourceDocumentBuilder singleResourceDocumentBuilder, - IEntityFrameworkResourceObjectMaterializer entityFrameworkResourceObjectMaterializer, - ISortExpressionExtractor sortExpressionExtractor, - IIncludeExpressionExtractor includeExpressionExtractor, - IBaseUrlService baseUrlService) - { - DbContext = dbContext; - _resourceTypeRegistration = resourceTypeRegistration; - _queryableResourceCollectionDocumentBuilder = queryableResourceCollectionDocumentBuilder; - _singleResourceDocumentBuilder = singleResourceDocumentBuilder; - _entityFrameworkResourceObjectMaterializer = entityFrameworkResourceObjectMaterializer; - _sortExpressionExtractor = sortExpressionExtractor; - _includeExpressionExtractor = includeExpressionExtractor; - _baseUrlService = baseUrlService; - } - - public virtual Task GetRecords(HttpRequestMessage request, CancellationToken cancellationToken) - { - var sortExpressions = _sortExpressionExtractor.ExtractSortExpressions(request); - var includes = _includeExpressionExtractor.ExtractIncludeExpressions(request); - var query = QueryIncludeNavigationProperties(null, GetNavigationPropertiesIncludes(includes)); - return _queryableResourceCollectionDocumentBuilder.BuildDocument(query, request, sortExpressions, cancellationToken, includes); - } - - public virtual async Task GetRecordById(string id, HttpRequestMessage request, CancellationToken cancellationToken) - { - var apiBaseUrl = GetBaseUrlFromRequest(request); - var includes = _includeExpressionExtractor.ExtractIncludeExpressions(request); - var singleResource = await FilterById(id, _resourceTypeRegistration, GetNavigationPropertiesIncludes(includes)).FirstOrDefaultAsync(cancellationToken); - if (singleResource == null) - throw JsonApiException.CreateForNotFound(string.Format("No resource of type `{0}` exists with id `{1}`.", - _resourceTypeRegistration.ResourceTypeName, id)); - return _singleResourceDocumentBuilder.BuildDocument(singleResource, apiBaseUrl, includes, null); - } - - public virtual async Task CreateRecord(ISingleResourceDocument requestDocument, - HttpRequestMessage request, CancellationToken cancellationToken) - { - var apiBaseUrl = GetBaseUrlFromRequest(request); - var newRecord = MaterializeAsync(requestDocument.PrimaryData, cancellationToken); - await OnCreate(newRecord); - await DbContext.SaveChangesAsync(cancellationToken); - var includes = _includeExpressionExtractor.ExtractIncludeExpressions(request); - var returnDocument = _singleResourceDocumentBuilder.BuildDocument(await newRecord, apiBaseUrl, includes, null); - - return returnDocument; - } - - - public virtual async Task UpdateRecord(string id, ISingleResourceDocument requestDocument, - HttpRequestMessage request, CancellationToken cancellationToken) - { - var apiBaseUrl = GetBaseUrlFromRequest(request); - var newRecord = MaterializeAsync(requestDocument.PrimaryData, cancellationToken); - await OnUpdate(newRecord); - await DbContext.SaveChangesAsync(cancellationToken); - var includes = _includeExpressionExtractor.ExtractIncludeExpressions(request); - var returnDocument = _singleResourceDocumentBuilder.BuildDocument(await newRecord, apiBaseUrl, includes, null); - - return returnDocument; - } - - public virtual async Task DeleteRecord(string id, HttpRequestMessage request, CancellationToken cancellationToken) - { - var singleResource = DbContext.Set().FindAsync(cancellationToken, Convert.ChangeType(id, _resourceTypeRegistration.IdProperty.PropertyType)); - await OnDelete(singleResource); - DbContext.Set().Remove(await singleResource); - await DbContext.SaveChangesAsync(cancellationToken); - - return null; - } - - /// - /// Gets the base URL for link creation from the current request - /// - protected string GetBaseUrlFromRequest(HttpRequestMessage request) - { - return _baseUrlService.GetBaseUrl(request); - } - - /// - /// Convert a resource object into a material record managed by EntityFramework. - /// - /// - protected virtual async Task MaterializeAsync(IResourceObject resourceObject, CancellationToken cancellationToken) - { - return (T) await _entityFrameworkResourceObjectMaterializer.MaterializeResourceObject(resourceObject, cancellationToken); - } - - - /// - /// Manipulate entity before create. - /// - /// - /// - protected virtual async Task OnCreate(Task record) - { - await record; - } - - /// - /// Manipulate entity before update. - /// - /// - protected virtual async Task OnUpdate(Task record) - { - await record; - } - - /// - /// Manipulate entity before delete. - /// - /// - /// - protected virtual async Task OnDelete(Task record) - { - await record; - } - - /// - /// This method allows to include into query. - /// This can reduce the number of queries (eager loading) - /// - /// - /// - /// - protected virtual Expression>[] GetNavigationPropertiesIncludes(string[] includes) - { - List>> list = new List>>(); - foreach (var include in includes) - { - var incl = include.Pascalize(); - var param = Expression.Parameter(typeof(TResource)); - var lambda = - Expression.Lambda>( - Expression.PropertyOrField(param, incl),param); - list.Add(lambda); - } - return list.ToArray(); - } - - - private IQueryable QueryIncludeNavigationProperties(Expression> predicate, - params Expression>[] includes) where TResource : class - { - IQueryable query = DbContext.Set(); - if (includes != null && includes.Any()) // eager loading - query = includes.Aggregate(query, (current, include) => current.Include(include)); - - if (predicate != null) - query = query.Where(predicate); - - return query.AsQueryable(); - } - - private IQueryable FilterById(string id, IResourceTypeRegistration resourceTypeRegistration, - params Expression>[] includes) where TResource : class - { - var param = Expression.Parameter(typeof(TResource)); - var filterByIdExpression = resourceTypeRegistration.GetFilterByIdExpression(param, id); - var predicate = Expression.Lambda>(filterByIdExpression, param); - return QueryIncludeNavigationProperties(predicate, includes); - } - } -} diff --git a/JSONAPI.EntityFramework/Http/EntityFrameworkToManyRelatedResourceDocumentMaterializer.cs b/JSONAPI.EntityFramework/Http/EntityFrameworkToManyRelatedResourceDocumentMaterializer.cs deleted file mode 100644 index 142075a0..00000000 --- a/JSONAPI.EntityFramework/Http/EntityFrameworkToManyRelatedResourceDocumentMaterializer.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data.Entity; -using System.Linq; -using System.Linq.Expressions; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.Core; -using JSONAPI.Documents.Builders; -using JSONAPI.Extensions; -using JSONAPI.Http; - -namespace JSONAPI.EntityFramework.Http -{ - /// - /// Implementation of for use with Entity Framework - /// - public class EntityFrameworkToManyRelatedResourceDocumentMaterializer : - QueryableToManyRelatedResourceDocumentMaterializer where TPrimaryResource : class - { - private readonly IResourceTypeRegistration _primaryTypeRegistration; - private readonly ResourceTypeRelationship _relationship; - private readonly DbContext _dbContext; - - /// - /// Builds a new EntityFrameworkToManyRelatedResourceDocumentMaterializer. - /// - public EntityFrameworkToManyRelatedResourceDocumentMaterializer( - ResourceTypeRelationship relationship, - DbContext dbContext, - IQueryableResourceCollectionDocumentBuilder queryableResourceCollectionDocumentBuilder, - ISortExpressionExtractor sortExpressionExtractor, - IIncludeExpressionExtractor includeExpressionExtractor, - IResourceTypeRegistration primaryTypeRegistration) - : base(queryableResourceCollectionDocumentBuilder, sortExpressionExtractor, includeExpressionExtractor) - { - _relationship = relationship; - _dbContext = dbContext; - _primaryTypeRegistration = primaryTypeRegistration; - } - - protected override async Task> GetRelatedQuery(string primaryResourceId, - CancellationToken cancellationToken) - { - var param = Expression.Parameter(typeof (TPrimaryResource)); - var accessorExpr = Expression.Property(param, _relationship.Property); - var lambda = Expression.Lambda>>(accessorExpr, param); - - var primaryEntityQuery = FilterById(primaryResourceId, _primaryTypeRegistration); - - // We have to see if the resource even exists, so we can throw a 404 if it doesn't - var relatedResource = await primaryEntityQuery.FirstOrDefaultAsync(cancellationToken); - if (relatedResource == null) - throw JsonApiException.CreateForNotFound(string.Format( - "No resource of type `{0}` exists with id `{1}`.", - _primaryTypeRegistration.ResourceTypeName, primaryResourceId)); - var includes = GetNavigationPropertiesIncludes(Includes); - var query = primaryEntityQuery.SelectMany(lambda); - - if (includes != null && includes.Any()) - query = includes.Aggregate(query, (current, include) => current.Include(include)); - return query; - } - - - /// - /// This method allows to include into query. - /// This can reduce the number of queries (eager loading) - /// - /// - /// - protected virtual Expression>[] GetNavigationPropertiesIncludes(string[] includes) - { - List>> list = new List>>(); - foreach (var include in includes) - { - var incl = include.Pascalize(); - var param = Expression.Parameter(typeof(TRelated)); - var lambda = - Expression.Lambda>( - Expression.PropertyOrField(param, incl), param); - list.Add(lambda); - } - return list.ToArray(); - } - - private IQueryable FilterById(string id, - IResourceTypeRegistration resourceTypeRegistration) where TResource : class - { - var param = Expression.Parameter(typeof (TResource)); - var filterByIdExpression = resourceTypeRegistration.GetFilterByIdExpression(param, id); - var predicate = Expression.Lambda>(filterByIdExpression, param); - IQueryable query = _dbContext.Set(); - return query.Where(predicate); - } - - } -} diff --git a/JSONAPI.EntityFramework/Http/EntityFrameworkToOneRelatedResourceDocumentMaterializer.cs b/JSONAPI.EntityFramework/Http/EntityFrameworkToOneRelatedResourceDocumentMaterializer.cs deleted file mode 100644 index 7fcb3814..00000000 --- a/JSONAPI.EntityFramework/Http/EntityFrameworkToOneRelatedResourceDocumentMaterializer.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Data.Entity; -using System.Linq; -using System.Linq.Expressions; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.Core; -using JSONAPI.Documents.Builders; -using JSONAPI.Http; - -namespace JSONAPI.EntityFramework.Http -{ - /// - /// Implementation of for use with Entity Framework - /// - public class EntityFrameworkToOneRelatedResourceDocumentMaterializer : - QueryableToOneRelatedResourceDocumentMaterializer where TPrimaryResource : class - { - private readonly IResourceTypeRegistration _primaryTypeRegistration; - private readonly ResourceTypeRelationship _relationship; - private readonly DbContext _dbContext; - - /// - /// Builds a new EntityFrameworkToOneRelatedResourceDocumentMaterializer - /// - public EntityFrameworkToOneRelatedResourceDocumentMaterializer( - ISingleResourceDocumentBuilder singleResourceDocumentBuilder, IBaseUrlService baseUrlService, - IResourceTypeRegistration primaryTypeRegistration, ResourceTypeRelationship relationship, - DbContext dbContext) - : base(singleResourceDocumentBuilder, baseUrlService) - { - _primaryTypeRegistration = primaryTypeRegistration; - _relationship = relationship; - _dbContext = dbContext; - } - - protected override async Task GetRelatedRecord(string primaryResourceId, CancellationToken cancellationToken) - { - var param = Expression.Parameter(typeof(TPrimaryResource)); - var accessorExpr = Expression.Property(param, _relationship.Property); - var lambda = Expression.Lambda>(accessorExpr, param); - - var primaryEntityQuery = FilterById(primaryResourceId, _primaryTypeRegistration); - var primaryEntityExists = await primaryEntityQuery.AnyAsync(cancellationToken); - if (!primaryEntityExists) - throw JsonApiException.CreateForNotFound(string.Format("No resource of type `{0}` exists with id `{1}`.", - _primaryTypeRegistration.ResourceTypeName, primaryResourceId)); - return await primaryEntityQuery.Select(lambda).FirstOrDefaultAsync(cancellationToken); - } - - private IQueryable Filter(Expression> predicate, - params Expression>[] includes) where TResource : class - { - IQueryable query = _dbContext.Set(); - if (includes != null && includes.Any()) - query = includes.Aggregate(query, (current, include) => current.Include(include)); - - if (predicate != null) - query = query.Where(predicate); - - return query.AsQueryable(); - } - - private IQueryable FilterById(string id, IResourceTypeRegistration resourceTypeRegistration, - params Expression>[] includes) where TResource : class - { - var param = Expression.Parameter(typeof(TResource)); - var filterByIdExpression = resourceTypeRegistration.GetFilterByIdExpression(param, id); - var predicate = Expression.Lambda>(filterByIdExpression, param); - return Filter(predicate, includes); - } - } -} diff --git a/JSONAPI.EntityFramework/IEntityFrameworkResourceObjectMaterializer.cs b/JSONAPI.EntityFramework/IEntityFrameworkResourceObjectMaterializer.cs deleted file mode 100644 index 321fd36c..00000000 --- a/JSONAPI.EntityFramework/IEntityFrameworkResourceObjectMaterializer.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.Documents; -using JSONAPI.Json; - -namespace JSONAPI.EntityFramework -{ - /// - /// This class manages converting IResourceObject instances from a request into records managed - /// by Entity Framework. - /// - public interface IEntityFrameworkResourceObjectMaterializer - { - /// - /// Gets a record managed by Entity Framework that has merged in the data from - /// the supplied resource object. - /// - /// - /// - /// - /// - Task MaterializeResourceObject(IResourceObject resourceObject, CancellationToken cancellationToken); - } -} \ No newline at end of file diff --git a/JSONAPI.EntityFramework/JSONAPI.EntityFramework.csproj b/JSONAPI.EntityFramework/JSONAPI.EntityFramework.csproj deleted file mode 100644 index 2045b33d..00000000 --- a/JSONAPI.EntityFramework/JSONAPI.EntityFramework.csproj +++ /dev/null @@ -1,105 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {E906356C-93F6-41F6-9A0D-73B8A99AA53C} - Library - Properties - JSONAPI.EntityFramework - JSONAPI.EntityFramework - v4.5 - 512 - ..\ - true - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - bin\Debug\JSONAPI.EntityFramework.XML - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - bin\Release\JSONAPI.EntityFramework.XML - - - - False - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll - - - False - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll - - - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - - - - - - - - False - ..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll - - - - - False - ..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll - - - - - - - - - - - - - - - - - - - - - - - - - {52b19fd6-efaa-45b5-9c3e-a652e27608d1} - JSONAPI - - - - - - - \ No newline at end of file diff --git a/JSONAPI.EntityFramework/JSONAPI.EntityFramework.nuspec b/JSONAPI.EntityFramework/JSONAPI.EntityFramework.nuspec deleted file mode 100644 index 151b7a73..00000000 --- a/JSONAPI.EntityFramework/JSONAPI.EntityFramework.nuspec +++ /dev/null @@ -1,23 +0,0 @@ - - - - $id$ - $version$ - JSONAPI.NET Entity Framework Integration - S'pht'Kr - S'pht'Kr - https://github.com/SphtKr/JSONAPI.NET/blob/master/LICENSE.md - https://github.com/SphtKr/JSONAPI.NET - https://raw.githubusercontent.com/SphtKr/JSONAPI.NET/master/JSONAPI/JSONAPI_NET_icon_512.png - false - Entity Framework integration for JSONAPI.NET, including an EntityFrameworkMaterializer and ApiController to highly automate building JSON API web services from EF6+ data models. - - No changes in this package for 0.2.1, just updating the projectUrl (moved to GitHub). - - Copyright 2014 - JSON WebAPI REST ember emberjs ember.js ember-data Entity Framework EF entity-framework - - - - - \ No newline at end of file diff --git a/JSONAPI.EntityFramework/Properties/AssemblyInfo.cs b/JSONAPI.EntityFramework/Properties/AssemblyInfo.cs deleted file mode 100644 index 3205b9a6..00000000 --- a/JSONAPI.EntityFramework/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("JSONAPI.EntityFramework")] -[assembly: AssemblyDescription("A toolkit for using WebAPI and (optionally) EntityFramework to quickly build REST services complying with the JSON API spec (jsonapi.org).")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("JSONAPI.NET")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("cdabab0c-3332-4b93-8cb6-ad521265a701")] - -[assembly: InternalsVisibleTo("JSONAPI.EntityFramework.Tests")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.2.1.0")] -[assembly: AssemblyFileVersion("0.2.1.0")] diff --git a/JSONAPI.EntityFramework/packages.config b/JSONAPI.EntityFramework/packages.config deleted file mode 100644 index d19b6caa..00000000 --- a/JSONAPI.EntityFramework/packages.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/JSONAPI.Tests/ActionFilters/DefaultFilteringTransformerTests.cs b/JSONAPI.Tests/ActionFilters/DefaultFilteringTransformerTests.cs deleted file mode 100644 index 6b458e2a..00000000 --- a/JSONAPI.Tests/ActionFilters/DefaultFilteringTransformerTests.cs +++ /dev/null @@ -1,1223 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Threading; -using System.Web.Http; -using FluentAssertions; -using JSONAPI.ActionFilters; -using JSONAPI.Core; -using JSONAPI.Documents.Builders; -using JSONAPI.QueryableTransformers; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.Tests.ActionFilters -{ - [TestClass] - public class DefaultFilteringTransformerTests : QueryableTransformerTestsBase - { - private enum SomeEnum - { - EnumValue1 = 1, - EnumValue2 = 2, - EnumValue3 = 3 - } - - private class SomeUnknownType - { - - } - - private class RelatedItemWithId - { - public string Id { get; set; } - public string Name { get; set; } - } - - private class Dummy - { - public string Id { get; set; } - public string StringField { get; set; } - public DateTime DateTimeField { get; set; } - public DateTime? NullableDateTimeField { get; set; } - public DateTimeOffset DateTimeOffsetField { get; set; } - public DateTimeOffset? NullableDateTimeOffsetField { get; set; } - public SomeEnum EnumField { get; set; } - public SomeEnum? NullableEnumField { get; set; } - public Decimal DecimalField { get; set; } - public Decimal? NullableDecimalField { get; set; } - public Boolean BooleanField { get; set; } - public Boolean? NullableBooleanField { get; set; } - public SByte SbyteField { get; set; } - public SByte? NullableSbyteField { get; set; } - public Byte ByteField { get; set; } - public Byte? NullableByteField { get; set; } - public Int16 Int16Field { get; set; } - public Int16? NullableInt16Field { get; set; } - public UInt16 Uint16Field { get; set; } - public UInt16? NullableUint16Field { get; set; } - public Int32 Int32Field { get; set; } - public Int32? NullableInt32Field { get; set; } - public UInt32 Uint32Field { get; set; } - public UInt32? NullableUint32Field { get; set; } - public Int64 Int64Field { get; set; } - public Int64? NullableInt64Field { get; set; } - public UInt64 Uint64Field { get; set; } - public UInt64? NullableUint64Field { get; set; } - public Double DoubleField { get; set; } - public Double? NullableDoubleField { get; set; } - public Single SingleField { get; set; } - public Single? NullableSingleField { get; set; } - public SomeUnknownType UnknownTypeField { get; set; } - public RelatedItemWithId ToOneRelatedItem { get; set; } - public ICollection ToManyRelatedItems { get; set; } - } - - private IList _fixtures; - private IQueryable _fixturesQuery; - - [TestInitialize] - public void SetupFixtures() - { - _fixtures = new List - { - #region StringField - - new Dummy - { - Id = "100", - StringField = "String value 1" - }, - new Dummy - { - Id = "101", - StringField = "String value 2" - }, - new Dummy - { - Id = "102", - StringField = "String value 2", - EnumField = SomeEnum.EnumValue3 - }, - - #endregion - - #region DateTimeField - - new Dummy - { - Id = "110", - DateTimeField = new DateTime(1930, 11, 7) - }, - new Dummy - { - Id = "111", - DateTimeField = new DateTime(1980, 6, 2) - }, - - #endregion - - #region NullableDateTimeField - - new Dummy - { - Id = "120", - NullableDateTimeField = new DateTime(1961, 2, 18) - }, - - #endregion - - #region DateTimeOffsetField - - new Dummy - { - Id = "130", - DateTimeOffsetField = new DateTime(1991, 1, 3) - }, - new Dummy - { - Id = "131", - DateTimeOffsetField = new DateTime(2004, 10, 31) - }, - - #endregion - - #region NullableDateTimeOffsetField - - new Dummy - { - Id = "140", - NullableDateTimeOffsetField = new DateTime(2014, 5, 5) - }, - - #endregion - - #region EnumField - - new Dummy - { - Id = "150", - EnumField = SomeEnum.EnumValue1 - }, - new Dummy - { - Id = "151", - EnumField = SomeEnum.EnumValue2 - }, - - #endregion - - #region NullableEnumField - - new Dummy - { - Id = "160", - NullableEnumField = SomeEnum.EnumValue3 - }, - - #endregion - - #region DecimalField - - new Dummy - { - Id = "170", - DecimalField = (decimal) 4.03 - }, - new Dummy - { - Id = "171", - DecimalField = (decimal) 6.37 - }, - - #endregion - - #region NullableDecimalField - - new Dummy - { - Id = "180", - NullableDecimalField = (decimal) 12.09 - }, - - #endregion - - #region BooleanField - - new Dummy - { - Id = "190", - BooleanField = true - }, - new Dummy - { - Id = "191", - BooleanField = false - }, - - #endregion - - #region NullableBooleanField - - new Dummy - { - Id = "200", - NullableBooleanField = false - }, - - #endregion - - #region SByteField - - new Dummy - { - Id = "210", - SbyteField = 63 - }, - new Dummy - { - Id = "211", - SbyteField = -89 - }, - - #endregion - - #region NullableSByteField - - new Dummy - { - Id = "220", - NullableSbyteField = 91 - }, - - #endregion - - #region ByteField - - new Dummy - { - Id = "230", - ByteField = 250 - }, - new Dummy - { - Id = "231", - ByteField = 130 - }, - - #endregion - - #region NullableByteField - - new Dummy - { - Id = "240", - NullableByteField = 44 - }, - - #endregion - - #region Int16Field - - new Dummy - { - Id = "250", - Int16Field = 12345 - }, - new Dummy - { - Id = "251", - Int16Field = -23456 - }, - - #endregion - - #region NullableInt16Field - - new Dummy - { - Id = "260", - NullableInt16Field = 32764 - }, - - #endregion - - #region UInt16Field - - new Dummy - { - Id = "270", - Uint16Field = 12345 - }, - new Dummy - { - Id = "271", - Uint16Field = 45678 - }, - - #endregion - - #region NullableUInt16Field - - new Dummy - { - Id = "280", - NullableUint16Field = 65000 - }, - - #endregion - - #region Int32Field - - new Dummy - { - Id = "290", - Int32Field = 100000006 - }, - new Dummy - { - Id = "291", - Int32Field = -234567890 - }, - - #endregion - - #region NullableInt32Field - - new Dummy - { - Id = "300", - NullableInt32Field = 345678901 - }, - - #endregion - - #region UInt32Field - - new Dummy - { - Id = "310", - Uint32Field = 123456789 - }, - new Dummy - { - Id = "311", - Uint32Field = 234567890 - }, - - #endregion - - #region NullableUInt32Field - - new Dummy - { - Id = "320", - NullableUint32Field = 345678901 - }, - - #endregion - - #region Int64Field - - new Dummy - { - Id = "330", - Int64Field = 123453489012 - }, - new Dummy - { - Id = "331", - Int64Field = -234067890123 - }, - - #endregion - - #region NullableInt64Field - - new Dummy - { - Id = "340", - NullableInt64Field = 345671901234 - }, - - #endregion - - #region UInt64Field - - new Dummy - { - Id = "350", - Uint64Field = 123456789012 - }, - new Dummy - { - Id = "351", - Uint64Field = 234567890123 - }, - - #endregion - - #region NullableUInt64Field - - new Dummy - { - Id = "360", - NullableUint64Field = 345678901234 - }, - - #endregion - - #region SingleField - - new Dummy - { - Id = "370", - SingleField = 21.56901f - }, - new Dummy - { - Id = "371", - SingleField = -34.789f - }, - - #endregion - - #region NullableSingleField - - new Dummy - { - Id = "380", - NullableSingleField = 1.3456f - }, - - #endregion - - #region DoubleField - - new Dummy - { - Id = "390", - DoubleField = 12.3453489012 - }, - new Dummy - { - Id = "391", - DoubleField = -2340678.90123 - }, - - #endregion - - #region NullableDoubleField - - new Dummy - { - Id = "400", - NullableDoubleField = 34567.1901234 - }, - - #endregion - - #region Unknown Type - - new Dummy - { - Id = "1000", - UnknownTypeField = new SomeUnknownType() - }, - - #endregion - - #region ToOneRelatedItem - - new Dummy - { - Id = "1100", - ToOneRelatedItem = new RelatedItemWithId - { - Id = "1101", - Name = "Related sample 1" - } - }, - new Dummy - { - Id = "1102", - ToOneRelatedItem = new RelatedItemWithId - { - Id = "1103", - Name = "Related sample 2" - } - }, - - #endregion - - #region ToManyRelatedItems - - new Dummy - { - Id = "1110", - ToManyRelatedItems = new List - { - new RelatedItemWithId { Id = "1111", Name = "Related sample 3" }, - new RelatedItemWithId { Id = "1112", Name = "Related sample 4" } - } - }, - - new Dummy - { - Id = "1120", - ToManyRelatedItems = new List - { - new RelatedItemWithId { Id = "1121", Name = "Related sample 5" }, - new RelatedItemWithId { Id = "1122", Name = "Related sample 6" } - } - } - - #endregion - }; - _fixturesQuery = _fixtures.AsQueryable(); - } - - private DefaultFilteringTransformer GetTransformer() - { - var pluralizationService = new PluralizationService(new Dictionary - { - {"Dummy", "Dummies"} - }); - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(pluralizationService)); - var registry = new ResourceTypeRegistry(); - registry.AddRegistration(registrar.BuildRegistration(typeof(Dummy))); - registry.AddRegistration(registrar.BuildRegistration(typeof(RelatedItemWithId))); - return new DefaultFilteringTransformer(registry); - } - - private Dummy[] GetArray(string uri) - { - return Transform(GetTransformer(), _fixturesQuery, uri).ToArray(); - } - - #region String - - [TestMethod] - public void Filters_by_matching_string_id_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[id]=100"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("100"); - } - - [TestMethod] - public void Filters_by_missing_string_id_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[id]="); - returnedArray.Length.Should().Be(0); - } - - [TestMethod] - public void Filters_by_matching_string_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[string-field]=String value 1"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("100"); - } - - [TestMethod] - public void Filters_by_missing_string_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[string-field]="); - returnedArray.Length.Should().Be(_fixtures.Count - 3); - returnedArray.Any(d => d.Id == "100" || d.Id == "101" || d.Id == "102").Should().BeFalse(); - } - - #endregion - - #region DateTime - - [TestMethod] - public void Filters_by_matching_datetime_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[date-time-field]=1930-11-07"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("110"); - } - - [TestMethod] - public void Filters_by_missing_datetime_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[date-time-field]="); - returnedArray.Length.Should().Be(0); - } - - [TestMethod] - public void Filters_by_matching_nullable_datetime_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-date-time-field]=1961-02-18"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("120"); - } - - [TestMethod] - public void Filters_by_missing_nullable_datetime_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-date-time-field]="); - returnedArray.Length.Should().Be(_fixtures.Count - 1); - returnedArray.Any(d => d.Id == "120").Should().BeFalse(); - } - - #endregion - - #region DateTimeOffset - - [TestMethod] - public void Filters_by_matching_datetimeoffset_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[date-time-offset-field]=1991-01-03"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("130"); - } - - [TestMethod] - public void Filters_by_missing_datetimeoffset_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[date-time-offset-field]="); - returnedArray.Length.Should().Be(0); - } - - [TestMethod] - public void Filters_by_matching_nullable_datetimeoffset_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-date-time-offset-field]=2014-05-05"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("140"); - } - - [TestMethod] - public void Filters_by_missing_nullable_datetimeoffset_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-date-time-offset-field]="); - returnedArray.Length.Should().Be(_fixtures.Count - 1); - returnedArray.Any(d => d.Id == "140").Should().BeFalse(); - } - - #endregion - - #region Enum - - [TestMethod] - public void Filters_by_matching_enum_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[enum-field]=1"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("150"); - } - - [TestMethod] - public void Filters_by_missing_enum_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[enum-field]="); - returnedArray.Length.Should().Be(0); - } - - [TestMethod] - public void Filters_by_matching_nullable_enum_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-enum-field]=3"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("160"); - } - - [TestMethod] - public void Filters_by_missing_nullable_enum_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-enum-field]="); - returnedArray.Length.Should().Be(_fixtures.Count - 1); - returnedArray.Any(d => d.Id == "160").Should().BeFalse(); - } - - #endregion - - #region Decimal - - [TestMethod] - public void Filters_by_matching_decimal_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[decimal-field]=4.03"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("170"); - } - - [TestMethod] - public void Filters_by_matching_decimal_property_non_en_US() - { - var currentCulture = Thread.CurrentThread.CurrentCulture; - Thread.CurrentThread.CurrentCulture = new CultureInfo("se-SE"); - - var returnedArray = GetArray("http://api.example.com/dummies?filter[decimal-field]=4.03"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("170"); - - Thread.CurrentThread.CurrentCulture = currentCulture; - } - - [TestMethod] - public void Filters_by_missing_decimal_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[decimal-field]="); - returnedArray.Length.Should().Be(0); - } - - [TestMethod] - public void Filters_by_matching_nullable_decimal_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-decimal-field]=12.09"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("180"); - } - - [TestMethod] - public void Filters_by_missing_nullable_decimal_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-decimal-field]="); - returnedArray.Length.Should().Be(_fixtures.Count - 1); - returnedArray.Any(d => d.Id == "180").Should().BeFalse(); - } - - #endregion - - #region Boolean - - [TestMethod] - public void Filters_by_matching_boolean_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[boolean-field]=true"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("190"); - } - - [TestMethod] - public void Filters_by_missing_boolean_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[boolean-field]="); - returnedArray.Length.Should().Be(0); - } - - [TestMethod] - public void Filters_by_matching_nullable_boolean_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-boolean-field]=false"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("200"); - } - - [TestMethod] - public void Filters_by_missing_nullable_boolean_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-boolean-field]="); - returnedArray.Length.Should().Be(_fixtures.Count - 1); - returnedArray.Any(d => d.Id == "200").Should().BeFalse(); - } - - #endregion - - #region SByte - - [TestMethod] - public void Filters_by_matching_sbyte_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[sbyte-field]=63"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("210"); - } - - [TestMethod] - public void Filters_by_missing_sbyte_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[sbyte-field]="); - returnedArray.Length.Should().Be(0); - } - - [TestMethod] - public void Filters_by_matching_nullable_sbyte_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-sbyte-field]=91"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("220"); - } - - [TestMethod] - public void Filters_by_missing_nullable_sbyte_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-sbyte-field]="); - returnedArray.Length.Should().Be(_fixtures.Count - 1); - returnedArray.Any(d => d.Id == "220").Should().BeFalse(); - } - - #endregion - - #region Byte - - [TestMethod] - public void Filters_by_matching_byte_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[byte-field]=250"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("230"); - } - - [TestMethod] - public void Filters_by_missing_byte_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[byte-field]="); - returnedArray.Length.Should().Be(0); - } - - [TestMethod] - public void Filters_by_matching_nullable_byte_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-byte-field]=44"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("240"); - } - - [TestMethod] - public void Filters_by_missing_nullable_byte_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-byte-field]="); - returnedArray.Length.Should().Be(_fixtures.Count - 1); - returnedArray.Any(d => d.Id == "240").Should().BeFalse(); - } - - #endregion - - #region Int16 - - [TestMethod] - public void Filters_by_matching_int16_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[int16-field]=12345"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("250"); - } - - [TestMethod] - public void Filters_by_missing_int16_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[int16-field]="); - returnedArray.Length.Should().Be(0); - } - - [TestMethod] - public void Filters_by_matching_nullable_int16_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-int16-field]=32764"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("260"); - } - - [TestMethod] - public void Filters_by_missing_nullable_int16_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-int16-field]="); - returnedArray.Length.Should().Be(_fixtures.Count - 1); - returnedArray.Any(d => d.Id == "260").Should().BeFalse(); - } - - #endregion - - #region UInt16 - - [TestMethod] - public void Filters_by_matching_uint16_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[uint16-field]=12345"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("270"); - } - - [TestMethod] - public void Filters_by_missing_uint16_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[uint16-field]="); - returnedArray.Length.Should().Be(0); - } - - [TestMethod] - public void Filters_by_matching_nullable_uint16_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-uint16-field]=65000"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("280"); - } - - [TestMethod] - public void Filters_by_missing_nullable_uint16_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-uint16-field]="); - returnedArray.Length.Should().Be(_fixtures.Count - 1); - returnedArray.Any(d => d.Id == "280").Should().BeFalse(); - } - - #endregion - - #region Int32 - - [TestMethod] - public void Filters_by_matching_int32_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[int32-field]=100000006"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("290"); - } - - [TestMethod] - public void Filters_by_missing_int32_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[int32-field]="); - returnedArray.Length.Should().Be(0); - } - - [TestMethod] - public void Filters_by_matching_nullable_int32_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-int32-field]=345678901"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("300"); - } - - [TestMethod] - public void Filters_by_missing_nullable_int32_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-int32-field]="); - returnedArray.Length.Should().Be(_fixtures.Count - 1); - returnedArray.Any(d => d.Id == "300").Should().BeFalse(); - } - - #endregion - - #region UInt32 - - [TestMethod] - public void Filters_by_matching_uint32_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[uint32-field]=123456789"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("310"); - } - - [TestMethod] - public void Filters_by_missing_uint32_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[uint32-field]="); - returnedArray.Length.Should().Be(0); - } - - [TestMethod] - public void Filters_by_matching_nullable_uint32_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-uint32-field]=345678901"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("320"); - } - - [TestMethod] - public void Filters_by_missing_nullable_uint32_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-uint32-field]="); - returnedArray.Length.Should().Be(_fixtures.Count - 1); - returnedArray.Any(d => d.Id == "320").Should().BeFalse(); - } - - #endregion - - #region Int64 - - [TestMethod] - public void Filters_by_matching_int64_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[int64-field]=123453489012"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("330"); - } - - [TestMethod] - public void Filters_by_missing_int64_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[int64-field]="); - returnedArray.Length.Should().Be(0); - } - - [TestMethod] - public void Filters_by_matching_nullable_int64_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-int64-field]=345671901234"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("340"); - } - - [TestMethod] - public void Filters_by_missing_nullable_int64_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-int64-field]="); - returnedArray.Length.Should().Be(_fixtures.Count - 1); - returnedArray.Any(d => d.Id == "340").Should().BeFalse(); - } - - #endregion - - #region UInt64 - - [TestMethod] - public void Filters_by_matching_uint64_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[uint64-field]=123456789012"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("350"); - } - - [TestMethod] - public void Filters_by_missing_uint64_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[uint64-field]="); - returnedArray.Length.Should().Be(0); - } - - [TestMethod] - public void Filters_by_matching_nullable_uint64_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-uint64-field]=345678901234"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("360"); - } - - [TestMethod] - public void Filters_by_missing_nullable_uint64_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-uint64-field]="); - returnedArray.Length.Should().Be(_fixtures.Count - 1); - returnedArray.Any(d => d.Id == "360").Should().BeFalse(); - } - - #endregion - - #region Single - - [TestMethod] - public void Filters_by_matching_single_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[single-field]=21.56901"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("370"); - } - - [TestMethod] - public void Filters_by_matching_single_property_non_en_US() - { - var currentCulture = Thread.CurrentThread.CurrentCulture; - Thread.CurrentThread.CurrentCulture = new CultureInfo("se-SE"); - - var returnedArray = GetArray("http://api.example.com/dummies?filter[single-field]=21.56901"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("370"); - - Thread.CurrentThread.CurrentCulture = currentCulture; - } - - - [TestMethod] - public void Filters_by_missing_single_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[single-field]="); - returnedArray.Length.Should().Be(0); - } - - [TestMethod] - public void Filters_by_matching_nullable_single_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-single-field]=1.3456"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("380"); - } - - [TestMethod] - public void Filters_by_missing_nullable_single_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-single-field]="); - returnedArray.Length.Should().Be(_fixtures.Count - 1); - returnedArray.Any(d => d.Id == "380").Should().BeFalse(); - } - - #endregion - - #region Double - - [TestMethod] - public void Filters_by_matching_double_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[double-field]=12.3453489012"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("390"); - } - - [TestMethod] - public void Filters_by_matching_double_property_non_en_US() - { - var currentCulture = Thread.CurrentThread.CurrentCulture; - Thread.CurrentThread.CurrentCulture = new CultureInfo("se-SE"); - - var returnedArray = GetArray("http://api.example.com/dummies?filter[double-field]=12.3453489012"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("390"); - - Thread.CurrentThread.CurrentCulture = currentCulture; - } - - [TestMethod] - public void Filters_by_missing_double_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[double-field]="); - returnedArray.Length.Should().Be(0); - } - - [TestMethod] - public void Filters_by_matching_nullable_double_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-double-field]=34567.1901234"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("400"); - } - - [TestMethod] - public void Filters_by_missing_nullable_double_property() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[nullable-double-field]="); - returnedArray.Length.Should().Be(_fixtures.Count - 1); - returnedArray.Any(d => d.Id == "400").Should().BeFalse(); - } - - #endregion - - #region Unknown Type - - [TestMethod] - public void Does_not_filter_unknown_type() - { - Action action = () => GetArray("http://api.example.com/dummies?filter[unknownTypeField]=asdfasd"); - action.ShouldThrow().Which.Error.Status.Should().Be(HttpStatusCode.BadRequest); - } - - #endregion - - #region To-one relationship - - [TestMethod] - public void Filters_by_matching_to_one_relationship_id() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[to-one-related-item]=1101"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("1100"); - } - - [TestMethod] - public void Filters_by_missing_to_one_relationship_id() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[to-one-related-item]="); - returnedArray.Length.Should().Be(_fixtures.Count - 2); - returnedArray.Any(d => d.Id == "1100" || d.Id == "1102").Should().BeFalse(); - } - - #endregion - - #region To-many relationship - - [TestMethod] - public void Filters_by_matching_id_in_to_many_relationship() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[to-many-related-items]=1111"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("1110"); - } - - [TestMethod] - public void Filters_by_missing_id_in_to_many_relationship() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[to-many-related-items]="); - returnedArray.Length.Should().Be(_fixtures.Count - 2); - returnedArray.Any(d => d.Id == "1110" || d.Id == "1120").Should().BeFalse(); - } - - #endregion - - #region Multiple filters - - [TestMethod] - public void Ands_together_filters() - { - var returnedArray = GetArray("http://api.example.com/dummies?filter[string-field]=String value 2&filter[enum-field]=3"); - returnedArray.Length.Should().Be(1); - returnedArray[0].Id.Should().Be("102"); - } - - #endregion - } -} diff --git a/JSONAPI.Tests/ActionFilters/DefaultPaginationTransformerTests.cs b/JSONAPI.Tests/ActionFilters/DefaultPaginationTransformerTests.cs deleted file mode 100644 index 8cb1e0af..00000000 --- a/JSONAPI.Tests/ActionFilters/DefaultPaginationTransformerTests.cs +++ /dev/null @@ -1,181 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Web.Http; -using FluentAssertions; -using JSONAPI.ActionFilters; -using JSONAPI.Core; -using JSONAPI.Documents.Builders; -using JSONAPI.QueryableTransformers; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.Tests.ActionFilters -{ - [TestClass] - public class DefaultPaginationTransformerTests - { - private class Dummy - { - // ReSharper disable UnusedAutoPropertyAccessor.Local - public string Id { get; set; } - // ReSharper restore UnusedAutoPropertyAccessor.Local - - public string FirstName { get; set; } - - public string LastName { get; set; } - } - - private IList _fixtures; - private IQueryable _fixturesQuery; - - [TestInitialize] - public void SetupFixtures() - { - _fixtures = new List - { - new Dummy { Id = "1", FirstName = "Thomas", LastName = "Paine" }, - new Dummy { Id = "2", FirstName = "Samuel", LastName = "Adams" }, - new Dummy { Id = "3", FirstName = "George", LastName = "Washington"}, - new Dummy { Id = "4", FirstName = "Thomas", LastName = "Jefferson" }, - new Dummy { Id = "5", FirstName = "Martha", LastName = "Washington"}, - new Dummy { Id = "6", FirstName = "Abraham", LastName = "Lincoln" }, - new Dummy { Id = "7", FirstName = "Andrew", LastName = "Jackson" }, - new Dummy { Id = "8", FirstName = "Andrew", LastName = "Johnson" }, - new Dummy { Id = "9", FirstName = "William", LastName = "Harrison" } - }; - _fixturesQuery = _fixtures.AsQueryable(); - } - - private DefaultPaginationTransformer GetTransformer(int maxPageSize) - { - return new DefaultPaginationTransformer(maxPageSize); - } - - private Dummy[] GetArray(string uri, int maxPageSize = 50) - { - var request = new HttpRequestMessage(HttpMethod.Get, uri); - return GetTransformer(maxPageSize).ApplyPagination(_fixturesQuery, request).PagedQuery.ToArray(); - } - - [TestMethod] - public void ApplyPagination_has_no_effect_when_no_paging_parameters_are_supplied() - { - var array = GetArray("http://api.example.com/dummies"); - array.Length.Should().Be(9); - } - - [TestMethod] - public void ApplyPagination_returns_all_results_when_they_are_within_page() - { - var array = GetArray("http://api.example.com/dummies?page[number]=0&page[size]=10"); - array.Length.Should().Be(9); - } - - [TestMethod] - public void ApplyPagination_returns_first_page_of_data() - { - var array = GetArray("http://api.example.com/dummies?page[number]=0&page[size]=4"); - array.Should().BeEquivalentTo(_fixtures[0], _fixtures[1], _fixtures[2], _fixtures[3]); - } - - [TestMethod] - public void ApplyPagination_returns_second_page_of_data() - { - var array = GetArray("http://api.example.com/dummies?page[number]=1&page[size]=4"); - array.Should().BeEquivalentTo(_fixtures[4], _fixtures[5], _fixtures[6], _fixtures[7]); - } - - [TestMethod] - public void ApplyPagination_returns_page_at_end() - { - var array = GetArray("http://api.example.com/dummies?page[number]=2&page[size]=4"); - array.Should().BeEquivalentTo(_fixtures[8]); - } - - [TestMethod] - public void ApplyPagination_returns_nothing_for_page_after_end() - { - var array = GetArray("http://api.example.com/dummies?page[number]=3&page[size]=4"); - array.Length.Should().Be(0); - } - - [TestMethod] - public void ApplyPagination_uses_max_page_size_when_requested_page_size_is_higher() - { - var array = GetArray("http://api.example.com/dummies?page[number]=1&page[size]=8", 3); - array.Should().BeEquivalentTo(_fixtures[3], _fixtures[4], _fixtures[5]); - } - - [TestMethod] - public void ApplyPagination_throws_exception_if_page_number_is_negative() - { - Action action = () => - { - GetArray("http://api.example.com/dummies?page[number]=-4&page[size]=4"); - }; - action.ShouldThrow().And.Error.Detail.Should().Be("Page number must not be negative."); - } - - [TestMethod] - public void ApplyPagination_throws_exception_if_page_size_is_negative() - { - Action action = () => - { - GetArray("http://api.example.com/dummies?page[number]=0&page[size]=-4"); - }; - action.ShouldThrow().And.Error.Detail.Should().Be("Page size must be greater than or equal to 1."); - } - - [TestMethod] - public void ApplyPagination_throws_exception_when_page_size_is_zero() - { - Action action = () => - { - GetArray("http://api.example.com/dummies?page[number]=0&page[size]=0"); - }; - action.ShouldThrow().And.Error.Detail.Should().Be("Page size must be greater than or equal to 1."); - } - - [TestMethod] - public void ApplyPagination_throws_exception_if_page_number_specified_but_not_size() - { - Action action = () => - { - GetArray("http://api.example.com/dummies?page[number]=0"); - }; - action.ShouldThrow().And.Error.Detail.Should().Be("In order for paging to work properly, if either page.number or page.size is set, both must be."); - } - - [TestMethod] - public void ApplyPagination_throws_exception_if_page_size_specified_but_not_number() - { - Action action = () => - { - GetArray("http://api.example.com/dummies?page[size]=0"); - }; - action.ShouldThrow().And.Error.Detail.Should().Be("In order for paging to work properly, if either page.number or page.size is set, both must be."); - } - - [TestMethod] - public void DefaultPaginationTransformer_cannot_be_instantiated_if_max_page_size_is_zero() - { - Action action = () => - { - GetTransformer(0); - }; - action.ShouldThrow(); - } - - [TestMethod] - public void DefaultPaginationTransformer_cannot_be_instantiated_if_max_page_size_is_negative() - { - Action action = () => - { - GetTransformer(-4); - }; - action.ShouldThrow(); - } - } -} diff --git a/JSONAPI.Tests/ActionFilters/DefaultSortingTransformerTests.cs b/JSONAPI.Tests/ActionFilters/DefaultSortingTransformerTests.cs deleted file mode 100644 index 4283b1eb..00000000 --- a/JSONAPI.Tests/ActionFilters/DefaultSortingTransformerTests.cs +++ /dev/null @@ -1,187 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using FluentAssertions; -using JSONAPI.Core; -using JSONAPI.Documents.Builders; -using JSONAPI.QueryableTransformers; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.Tests.ActionFilters -{ - [TestClass] - public class DefaultSortingTransformerTests : QueryableTransformerTestsBase - { - private class Dummy - { - // ReSharper disable UnusedAutoPropertyAccessor.Local - public string Id { get; set; } - // ReSharper restore UnusedAutoPropertyAccessor.Local - - public string FirstName { get; set; } - - public string LastName { get; set; } - - public DateTime BirthDate { get; set; } - } - - private class Dummy2 - { - public int Id { get; set; } - - public string Name { get; set; } - } - - private IList _fixtures; - private IQueryable _fixturesQuery; - private IList _fixtures2; - private IQueryable _fixtures2Query; - - [TestInitialize] - public void SetupFixtures() - { - _fixtures = new List - { - new Dummy {Id = "1", FirstName = "Thomas", LastName = "Paine", BirthDate = new DateTime(1737, 2, 9)}, - new Dummy {Id = "2", FirstName = "Samuel", LastName = "Adams", BirthDate = new DateTime(1722, 9, 27)}, - new Dummy {Id = "3", FirstName = "George", LastName = "Washington", BirthDate = new DateTime(1732, 2, 22)}, - new Dummy {Id = "4", FirstName = "Thomas", LastName = "Jefferson", BirthDate = new DateTime(1743, 4, 13)}, - new Dummy {Id = "5", FirstName = "Martha", LastName = "Washington", BirthDate = new DateTime(1731, 6, 13)}, - new Dummy {Id = "6", FirstName = "Abraham", LastName = "Lincoln", BirthDate = new DateTime(1809, 2, 12)}, - new Dummy {Id = "7", FirstName = "Andrew", LastName = "Jackson", BirthDate = new DateTime(1767, 3, 15)}, - new Dummy {Id = "8", FirstName = "Andrew", LastName = "Johnson", BirthDate = new DateTime(1808, 12, 29)}, - new Dummy {Id = "9", FirstName = "William", LastName = "Harrison", BirthDate = new DateTime(1773, 2, 9)} - }; - _fixturesQuery = _fixtures.AsQueryable(); - - _fixtures2 = new List - { - new Dummy2 {Id = 45, Name = "France"}, - new Dummy2 {Id = 52, Name = "Spain"}, - new Dummy2 {Id = 33, Name = "Mongolia"}, - }; - _fixtures2Query = _fixtures2.AsQueryable(); - } - - private DefaultSortingTransformer GetTransformer() - { - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - var registry = new ResourceTypeRegistry(); - registry.AddRegistration(registrar.BuildRegistration(typeof(Dummy), "dummies")); - registry.AddRegistration(registrar.BuildRegistration(typeof(Dummy2), "dummy2s")); - return new DefaultSortingTransformer(registry); - } - - private TFixture[] GetArray(string[] sortExpressions, IQueryable fixturesQuery) - { - return GetTransformer().Sort(fixturesQuery, sortExpressions).ToArray(); - } - - private Dummy[] GetDummyArray(string[] sortExpressions) - { - return GetArray(sortExpressions, _fixturesQuery); - } - - private Dummy2[] GetDummy2Array(string[] sortExpressions) - { - return GetArray(sortExpressions, _fixtures2Query); - } - - private void RunTransformAndExpectFailure(string[] sortExpressions, string expectedMessage) - { - Action action = () => - { - // ReSharper disable once UnusedVariable - var result = GetTransformer().Sort(_fixturesQuery, sortExpressions).ToArray(); - }; - action.ShouldThrow().Which.Error.Detail.Should().Be(expectedMessage); - } - - [TestMethod] - public void Sorts_by_attribute_ascending() - { - var array = GetDummyArray(new [] { "first-name" }); - array.Should().BeInAscendingOrder(d => d.FirstName); - } - - [TestMethod] - public void Sorts_by_attribute_descending() - { - var array = GetDummyArray(new [] { "-first-name" }); - array.Should().BeInDescendingOrder(d => d.FirstName); - } - - [TestMethod] - public void Sorts_by_two_ascending_attributes() - { - var array = GetDummyArray(new [] { "last-name", "first-name" }); - array.Should().ContainInOrder(_fixtures.OrderBy(d => d.LastName + d.FirstName)); - } - - [TestMethod] - public void Sorts_by_two_descending_attributes() - { - var array = GetDummyArray(new [] { "-last-name", "-first-name" }); - array.Should().ContainInOrder(_fixtures.OrderByDescending(d => d.LastName + d.FirstName)); - } - - [TestMethod] - public void Sorts_by_id_when_expressions_are_empty() - { - var array = GetDummyArray(new string[] { }); - array.Should().ContainInOrder(_fixtures.OrderBy(d => d.Id)); - } - - [TestMethod] - public void Returns_400_if_sort_argument_is_empty() - { - RunTransformAndExpectFailure(new[] { "" }, "One of the sort expressions is empty."); - } - - [TestMethod] - public void Returns_400_if_sort_argument_is_whitespace() - { - RunTransformAndExpectFailure(new [] { " " }, "One of the sort expressions is empty."); - } - - [TestMethod] - public void Returns_400_if_sort_argument_is_empty_descending() - { - RunTransformAndExpectFailure(new [] { "-" }, "One of the sort expressions is empty."); - } - - [TestMethod] - public void Returns_400_if_sort_argument_is_whitespace_descending() - { - RunTransformAndExpectFailure(new[] { "- " }, "One of the sort expressions is empty."); - } - - [TestMethod] - public void Returns_400_if_no_property_exists() - { - RunTransformAndExpectFailure(new[] { "foobar" }, - "The attribute \"foobar\" does not exist on type \"dummies\"."); - } - - [TestMethod] - public void Returns_400_if_the_same_property_is_specified_more_than_once() - { - RunTransformAndExpectFailure(new[] { "last-name", "last-name" }, - "The attribute \"last-name\" was specified more than once."); - } - - [TestMethod] - public void Can_sort_by_DateTimeOffset() - { - var array = GetDummyArray(new [] { "birth-date" }); - array.Should().BeInAscendingOrder(d => d.BirthDate); - } - - [TestMethod] - public void Can_sort_by_resource_with_integer_key() - { - var array = GetDummy2Array(new [] { "name" }); - array.Should().BeInAscendingOrder(d => d.Name); - } - } -} diff --git a/JSONAPI.Tests/ActionFilters/FallbackDocumentBuilderAttributeTests.cs b/JSONAPI.Tests/ActionFilters/FallbackDocumentBuilderAttributeTests.cs deleted file mode 100644 index 49a87216..00000000 --- a/JSONAPI.Tests/ActionFilters/FallbackDocumentBuilderAttributeTests.cs +++ /dev/null @@ -1,173 +0,0 @@ -using System; -using System.Net; -using System.Net.Http; -using System.Net.Http.Formatting; -using System.Net.Http.Headers; -using System.Threading; -using System.Threading.Tasks; -using System.Web.Http; -using System.Web.Http.Controllers; -using System.Web.Http.Filters; -using FluentAssertions; -using JSONAPI.ActionFilters; -using JSONAPI.Documents; -using JSONAPI.Documents.Builders; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; - -namespace JSONAPI.Tests.ActionFilters -{ - [TestClass] - public class FallbackDocumentBuilderAttributeTests - { - private HttpActionExecutedContext GetActionExecutedContext(object objectContentValue, Exception exception = null) - { - var mockMediaTypeFormatter = new Mock(MockBehavior.Strict); - mockMediaTypeFormatter.Setup(f => f.CanWriteType(It.IsAny())).Returns(true); - mockMediaTypeFormatter.Setup(f => f.SetDefaultContentHeaders(It.IsAny(), It.IsAny(), It.IsAny())); - var response = new HttpResponseMessage - { - Content = new ObjectContent(objectContentValue.GetType(), objectContentValue, mockMediaTypeFormatter.Object) - }; - var actionContext = new HttpActionContext { Response = response }; - return new HttpActionExecutedContext(actionContext, exception); - } - - [TestMethod] - public void OnActionExecutedAsync_leaves_ISingleResourceDocument_alone() - { - // Arrange - var mockDocument = new Mock(MockBehavior.Strict); - var actionExecutedContext = GetActionExecutedContext(mockDocument.Object); - var cancellationTokenSource = new CancellationTokenSource(); - var mockFallbackDocumentBuilder = new Mock(MockBehavior.Strict); - var mockErrorDocumentBuilder = new Mock(MockBehavior.Strict); - - // Act - var attribute = new FallbackDocumentBuilderAttribute(mockFallbackDocumentBuilder.Object, mockErrorDocumentBuilder.Object); - var task = attribute.OnActionExecutedAsync(actionExecutedContext, cancellationTokenSource.Token); - task.Wait(); - - ((ObjectContent)actionExecutedContext.Response.Content).Value.Should().BeSameAs(mockDocument.Object); - actionExecutedContext.Response.StatusCode.Should().Be(HttpStatusCode.OK); - } - - [TestMethod] - public void OnActionExecutedAsync_leaves_IResourceCollectionDocument_alone() - { - // Arrange - var mockDocument = new Mock(MockBehavior.Strict); - var actionExecutedContext = GetActionExecutedContext(mockDocument.Object); - var cancellationTokenSource = new CancellationTokenSource(); - var mockFallbackDocumentBuilder = new Mock(MockBehavior.Strict); - var mockErrorDocumentBuilder = new Mock(MockBehavior.Strict); - - // Act - var attribute = new FallbackDocumentBuilderAttribute(mockFallbackDocumentBuilder.Object, mockErrorDocumentBuilder.Object); - var task = attribute.OnActionExecutedAsync(actionExecutedContext, cancellationTokenSource.Token); - task.Wait(); - - ((ObjectContent)actionExecutedContext.Response.Content).Value.Should().BeSameAs(mockDocument.Object); - actionExecutedContext.Response.StatusCode.Should().Be(HttpStatusCode.OK); - } - - [TestMethod] - public void OnActionExecutedAsync_leaves_IErrorDocument_alone_but_changes_request_status_to_match_error_status() - { - // Arrange - var mockError = new Mock(MockBehavior.Strict); - mockError.Setup(e => e.Status).Returns(HttpStatusCode.Conflict); - var mockDocument = new Mock(MockBehavior.Strict); - mockDocument.Setup(p => p.Errors).Returns(new[] {mockError.Object}); - var actionExecutedContext = GetActionExecutedContext(mockDocument.Object); - var cancellationTokenSource = new CancellationTokenSource(); - var mockFallbackDocumentBuilder = new Mock(MockBehavior.Strict); - var mockErrorDocumentBuilder = new Mock(MockBehavior.Strict); - - // Act - var attribute = new FallbackDocumentBuilderAttribute(mockFallbackDocumentBuilder.Object, mockErrorDocumentBuilder.Object); - var task = attribute.OnActionExecutedAsync(actionExecutedContext, cancellationTokenSource.Token); - task.Wait(); - - ((ObjectContent)actionExecutedContext.Response.Content).Value.Should().BeSameAs(mockDocument.Object); - actionExecutedContext.Response.StatusCode.Should().Be(HttpStatusCode.Conflict); - } - - [TestMethod] - public void OnActionExecutedAsync_does_nothing_if_there_is_an_exception() - { - // Arrange - var objectContent = new object(); - var theException = new Exception("This is an error."); - var actionExecutedContext = GetActionExecutedContext(objectContent, theException); - var cancellationTokenSource = new CancellationTokenSource(); - var mockFallbackDocumentBuilder = new Mock(MockBehavior.Strict); - var mockErrorDocumentBuilder = new Mock(MockBehavior.Strict); - - // Act - var attribute = new FallbackDocumentBuilderAttribute(mockFallbackDocumentBuilder.Object, mockErrorDocumentBuilder.Object); - var task = attribute.OnActionExecutedAsync(actionExecutedContext, cancellationTokenSource.Token); - task.Wait(); - - var newObjectContent = ((ObjectContent) actionExecutedContext.Response.Content).Value; - newObjectContent.Should().BeSameAs(objectContent); - actionExecutedContext.Exception.Should().Be(theException); - } - - private class Fruit - { - } - - [TestMethod] - public void OnActionExecutedAsync_delegates_to_fallback_document_builder_for_unknown_types() - { - // Arrange - var resource = new Fruit(); - var actionExecutedContext = GetActionExecutedContext(resource); - var cancellationTokenSource = new CancellationTokenSource(); - - var mockResult = new Mock(MockBehavior.Strict); - var mockFallbackDocumentBuilder = new Mock(MockBehavior.Strict); - mockFallbackDocumentBuilder.Setup(b => b.BuildDocument(resource, It.IsAny(), cancellationTokenSource.Token)) - .Returns(Task.FromResult(mockResult.Object)); - - var mockErrorDocumentBuilder = new Mock(MockBehavior.Strict); - - // Act - var attribute = new FallbackDocumentBuilderAttribute(mockFallbackDocumentBuilder.Object, mockErrorDocumentBuilder.Object); - var task = attribute.OnActionExecutedAsync(actionExecutedContext, cancellationTokenSource.Token); - task.Wait(); - - // Assert - ((ObjectContent)actionExecutedContext.Response.Content).Value.Should().BeSameAs(mockResult.Object); - actionExecutedContext.Response.StatusCode.Should().Be(HttpStatusCode.OK); - } - - [TestMethod] - public void OnActionExecutedAsync_creates_IErrorDocument_for_HttpError() - { - // Arrange - var httpError = new HttpError("Some error"); - var actionExecutedContext = GetActionExecutedContext(httpError); - var cancellationTokenSource = new CancellationTokenSource(); - var mockFallbackDocumentBuilder = new Mock(MockBehavior.Strict); - - var mockError = new Mock(MockBehavior.Strict); - mockError.Setup(e => e.Status).Returns(HttpStatusCode.OK); - var mockResult = new Mock(MockBehavior.Strict); - mockResult.Setup(r => r.Errors).Returns(new[] { mockError.Object }); - - var mockErrorDocumentBuilder = new Mock(MockBehavior.Strict); - mockErrorDocumentBuilder.Setup(b => b.BuildFromHttpError(httpError, HttpStatusCode.OK)).Returns(mockResult.Object); - - // Act - var attribute = new FallbackDocumentBuilderAttribute(mockFallbackDocumentBuilder.Object, mockErrorDocumentBuilder.Object); - var task = attribute.OnActionExecutedAsync(actionExecutedContext, cancellationTokenSource.Token); - task.Wait(); - - // Assert - ((ObjectContent)actionExecutedContext.Response.Content).Value.Should().BeSameAs(mockResult.Object); - actionExecutedContext.Response.StatusCode.Should().Be(HttpStatusCode.OK); - } - } -} diff --git a/JSONAPI.Tests/ActionFilters/QueryableTransformerTestsBase.cs b/JSONAPI.Tests/ActionFilters/QueryableTransformerTestsBase.cs deleted file mode 100644 index adba3c0a..00000000 --- a/JSONAPI.Tests/ActionFilters/QueryableTransformerTestsBase.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Linq; -using System.Net.Http; -using JSONAPI.ActionFilters; -using JSONAPI.QueryableTransformers; - -namespace JSONAPI.Tests.ActionFilters -{ - public abstract class QueryableTransformerTestsBase - { - internal IQueryable Transform(IQueryableFilteringTransformer filteringTransformer, IQueryable query, string uri) - { - var request = new HttpRequestMessage(HttpMethod.Get, uri); - return filteringTransformer.Filter(query, request); - } - } -} diff --git a/JSONAPI.Tests/Core/DefaultNamingConventionsTests.cs b/JSONAPI.Tests/Core/DefaultNamingConventionsTests.cs deleted file mode 100644 index 5ce99dcc..00000000 --- a/JSONAPI.Tests/Core/DefaultNamingConventionsTests.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using FluentAssertions; -using JSONAPI.Attributes; -using JSONAPI.Core; -using JSONAPI.Tests.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Newtonsoft.Json; - -namespace JSONAPI.Tests.Core -{ - [TestClass] - public class DefaultNamingConventionsTests - { - private class Band - { - [JsonProperty("THE-GENRE")] - public string Genre { get; set; } - } - - private class SomeClass - { - public string SomeKey { get; set; } - } - - [TestMethod] - public void GetFieldNameForProperty_returns_right_name_for_id() - { - // Arrange - var namingConventions = new DefaultNamingConventions(new PluralizationService()); - - // Act - var name = namingConventions.GetFieldNameForProperty(typeof(Author).GetProperty("Id")); - - // Assert - name.Should().Be("id"); - } - - [TestMethod] - public void GetFieldNameForProperty_returns_right_name_for_camel_cased_property() - { - // Arrange - var namingConventions = new DefaultNamingConventions(new PluralizationService()); - - // Act - var name = namingConventions.GetFieldNameForProperty(typeof(SomeClass).GetProperty("SomeKey")); - - // Assert - name.Should().Be("some-key"); - } - - [TestMethod] - public void GetFieldNameForProperty_returns_right_name_for_property_with_JsonProperty_attribute() - { - // Arrange - var namingConventions = new DefaultNamingConventions(new PluralizationService()); - - // Act - var name = namingConventions.GetFieldNameForProperty(typeof(Band).GetProperty("Genre")); - - // Assert - name.Should().Be("THE-GENRE"); - } - } -} diff --git a/JSONAPI.Tests/Core/EnumAttributeValueConverterTests.cs b/JSONAPI.Tests/Core/EnumAttributeValueConverterTests.cs deleted file mode 100644 index 9f14283f..00000000 --- a/JSONAPI.Tests/Core/EnumAttributeValueConverterTests.cs +++ /dev/null @@ -1,71 +0,0 @@ -using FluentAssertions; -using JSONAPI.Core; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Tests.Core -{ - [TestClass] - public class EnumAttributeValueConverterTests - { - public enum Int32Enum - { - Value1 = 1, - Value2 = 2, - Value3 = 3 - } - - public enum Int64Enum : long - { - Value1 = 1, - Value2 = 2, - Value3 = 3 - } - - private class Class1 - { - public Int32Enum Value { get; set; } - } - - private class Class2 - { - public Int64Enum Value { get; set; } - } - - [TestMethod] - public void GetValue_for_int32_enum() - { - // Arrange - var property = typeof (Class1).GetProperty("Value"); - var obj = new Class1 - { - Value = Int32Enum.Value1 - }; - - // Act - var converter = new EnumAttributeValueConverter(property, typeof(Int32Enum), false); - var actualValue = (JValue)converter.GetValue(obj); - - // Assert - actualValue.Value.Should().Be((long)1); - } - - [TestMethod] - public void GetValue_for_int64_enum() - { - // Arrange - var property = typeof(Class2).GetProperty("Value"); - var obj = new Class2 - { - Value = Int64Enum.Value1 - }; - - // Act - var converter = new EnumAttributeValueConverter(property, typeof(Int64Enum), false); - var actualValue = (JValue)converter.GetValue(obj); - - // Assert - actualValue.Value.Should().Be((long)1); - } - } -} diff --git a/JSONAPI.Tests/Core/PrimitiveTypeAttributeValueConverterTests.cs b/JSONAPI.Tests/Core/PrimitiveTypeAttributeValueConverterTests.cs deleted file mode 100644 index eb7b53f2..00000000 --- a/JSONAPI.Tests/Core/PrimitiveTypeAttributeValueConverterTests.cs +++ /dev/null @@ -1,52 +0,0 @@ -using FluentAssertions; -using JSONAPI.Core; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Tests.Core -{ - [TestClass] - public class PrimitiveTypeAttributeValueConverterTests - { - private class Class1 - { - public int? NullableIntValue { get; set; } - } - - [TestMethod] - public void GetValue_for_null() - { - // Arrange - var property = typeof (Class1).GetProperty("NullableIntValue"); - var obj = new Class1 - { - NullableIntValue = null - }; - - // Act - var converter = new PrimitiveTypeAttributeValueConverter(property); - var actualValue = (JValue)converter.GetValue(obj); - - // Assert - ((object)actualValue).Should().Be(null); - } - - [TestMethod] - public void SetValue_for_null() - { - // Arrange - var property = typeof(Class1).GetProperty("NullableIntValue"); - var obj = new Class1 - { - NullableIntValue = 4 - }; - - // Act - var converter = new PrimitiveTypeAttributeValueConverter(property); - converter.SetValue(obj, JValue.CreateNull()); - - // Assert - obj.NullableIntValue.Should().Be(null); - } - } -} diff --git a/JSONAPI.Tests/Core/ResourceTypeRegistrarTests.cs b/JSONAPI.Tests/Core/ResourceTypeRegistrarTests.cs deleted file mode 100644 index b1b242e9..00000000 --- a/JSONAPI.Tests/Core/ResourceTypeRegistrarTests.cs +++ /dev/null @@ -1,813 +0,0 @@ -using System; -using JSONAPI.Attributes; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using JSONAPI.Core; -using JSONAPI.Tests.Models; -using System.Reflection; -using System.Collections.Generic; -using System.Collections; -using System.Diagnostics; -using System.Globalization; -using System.Linq; -using System.Threading; -using FluentAssertions; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Tests.Core -{ - [TestClass] - public class ResourceTypeRegistrarTests - { - private class InvalidModel // No Id discernable! - { - public string Data { get; set; } - } - - private class CustomIdModel - { - [UseAsId] - public Guid Uuid { get; set; } - - public string Data { get; set; } - } - - private class Salad - { - public string Id { get; set; } - - [JsonProperty("salad-type")] - public string TheSaladType { get; set; } - - [JsonProperty("salad-type")] - public string AnotherSaladType { get; set; } - } - - private class Continent - { - [UseAsId] - public string Name { get; set; } - - public string Id { get; set; } - } - - private class Boat - { - public string Id { get; set; } - - public string Type { get; set; } - } - - [TestMethod] - public void Cant_register_type_with_missing_id() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - Action action = () => registrar.BuildRegistration(typeof(InvalidModel)); - - // Assert - action.ShouldThrow() - .Which.Message.Should() - .Be("Unable to determine Id property for type `InvalidModel`."); - } - - [TestMethod] - public void Cant_register_type_with_non_id_property_called_id() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - Action action = () => registrar.BuildRegistration(typeof(Continent)); - - // Assert - action.ShouldThrow() - .Which.Message.Should() - .Be("Failed to register type `Continent` because it contains a non-id property that would serialize as \"id\"."); - } - - [TestMethod] - public void Cant_register_type_with_property_called_type() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - Action action = () => registrar.BuildRegistration(typeof(Boat)); - - // Assert - action.ShouldThrow() - .Which.Message.Should() - .Be("Failed to register type `Boat` because it contains a property that would serialize as \"type\"."); - } - - [TestMethod] - public void Cant_register_type_with_two_properties_with_the_same_name() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - Type saladType = typeof(Salad); - - // Act - Action action = () => registrar.BuildRegistration(saladType); - - // Assert - action.ShouldThrow().Which.Message.Should() - .Be("Failed to register type `Salad` because contains multiple properties that would serialize as `salad-type`."); - } - - [TestMethod] - public void BuildRegistration_sets_up_registration_correctly() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var postReg = registrar.BuildRegistration(typeof(Post)); - - // Assert - postReg.IdProperty.Should().BeSameAs(typeof(Post).GetProperty("Id")); - postReg.ResourceTypeName.Should().Be("posts"); - postReg.Attributes.Length.Should().Be(1); - postReg.Attributes.First().Property.Should().BeSameAs(typeof(Post).GetProperty("Title")); - postReg.Relationships.Length.Should().Be(2); - postReg.Relationships[0].IsToMany.Should().BeFalse(); - postReg.Relationships[0].Property.Should().BeSameAs(typeof(Post).GetProperty("Author")); - postReg.Relationships[0].SelfLinkTemplate.Should().BeNull(); - postReg.Relationships[0].RelatedResourceLinkTemplate.Should().BeNull(); - postReg.Relationships[1].IsToMany.Should().BeTrue(); - postReg.Relationships[1].Property.Should().BeSameAs(typeof(Post).GetProperty("Comments")); - postReg.Relationships[1].SelfLinkTemplate.Should().Be("/posts/{1}/relationships/comments"); - postReg.Relationships[1].RelatedResourceLinkTemplate.Should().Be("/posts/{1}/comments"); - } - - private AttributeGrabBag InitializeGrabBag() - { - return new AttributeGrabBag() - { - Id = "2", - BooleanField = true, - NullableBooleanField = true, - SbyteField = 123, - NullableSbyteField = 123, - ByteField = 253, - NullableByteField = 253, - Int16Field = 32000, - NullableInt16Field = 32000, - Uint16Field = 64000, - NullableUint16Field = 64000, - Int32Field = 2000000000, - NullableInt32Field = 2000000000, - Uint32Field = 3000000000, - NullableUint32Field = 3000000000, - Int64Field = 9223372036854775807, - NullableInt64Field = 9223372036854775807, - Uint64Field = 9223372036854775808, - NullableUint64Field = 9223372036854775808, - DoubleField = 1056789.123, - NullableDoubleField = 1056789.123, - SingleField = 1056789.123f, - NullableSingleField = 1056789.123f, - DecimalField = 1056789.123m, - NullableDecimalField = 1056789.123m, - DateTimeField = new DateTime(1776, 07, 04), - NullableDateTimeField = new DateTime(1776, 07, 04), - DateTimeOffsetField = new DateTimeOffset(new DateTime(1776, 07, 04), new TimeSpan(-5, 0, 0)), - NullableDateTimeOffsetField = new DateTimeOffset(new DateTime(1776, 07, 04), new TimeSpan(-5, 0, 0)), - GuidField = new Guid("6566F9B4-5245-40DE-890D-98B40A4AD656"), - NullableGuidField = new Guid("3D1FB81E-43EE-4D04-AF91-C8A326341293"), - StringField = "Some string 156", - EnumField = SampleEnum.Value1, - NullableEnumField = SampleEnum.Value2, - ComplexAttributeField = "{\"foo\": { \"baz\": [11] }, \"bar\": 5}" - }; - } - - private void AssertAttribute(IResourceTypeRegistration reg, string attributeName, - JToken tokenToSet, TPropertyType expectedPropertyValue, TTokenType expectedTokenAfterSet, Func getPropertyFunc) - { - AssertAttributeHelper(reg, attributeName, tokenToSet, grabBag => - { - var propertyValueAfterSet = getPropertyFunc(grabBag); - propertyValueAfterSet.Should().Be(expectedPropertyValue); - }, token => - { - if (expectedTokenAfterSet == null) - token.Should().BeNull(); - else - { - var convertedTokenValue = token.Value(); - convertedTokenValue.Should().Be(expectedTokenAfterSet); - } - }); - } - - private void AssertAttributeHelper(IResourceTypeRegistration reg, string attributeName, - JToken tokenToSet, Action testPropertyValueAfterSet, - Action testTokenAfterSetAndGet) - { - var grabBag = InitializeGrabBag(); - - var field = reg.GetFieldByName(attributeName); - var attribute = (ResourceTypeAttribute)field; - attribute.JsonKey.Should().Be(attributeName); - - attribute.SetValue(grabBag, tokenToSet); - testPropertyValueAfterSet(grabBag); - - var convertedToken = attribute.GetValue(grabBag); - testTokenAfterSetAndGet(convertedToken); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_boolean_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "boolean-field", false, false, false, g => g.BooleanField); - AssertAttribute(reg, "boolean-field", true, true, true, g => g.BooleanField); - AssertAttribute(reg, "boolean-field", null, false, false, g => g.BooleanField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_nullable_boolean_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "nullable-boolean-field", false, false, false, g => g.NullableBooleanField); - AssertAttribute(reg, "nullable-boolean-field", true, true, true, g => g.NullableBooleanField); - AssertAttribute(reg, "nullable-boolean-field", null, null, (Boolean?) null, g => g.NullableBooleanField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_SByte_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "sbyte-field", 0, 0, 0, g => g.SbyteField); - AssertAttribute(reg, "sbyte-field", 12, 12, 12, g => g.SbyteField); - AssertAttribute(reg, "sbyte-field", -12, -12, -12, g => g.SbyteField); - AssertAttribute(reg, "sbyte-field", null, 0, 0, g => g.SbyteField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_nullable_SByte_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "nullable-sbyte-field", 0, (SByte?)0, (SByte?)0, g => g.NullableSbyteField); - AssertAttribute(reg, "nullable-sbyte-field", 12, (SByte?)12, (SByte?)12, g => g.NullableSbyteField); - AssertAttribute(reg, "nullable-sbyte-field", -12, (SByte?)-12, (SByte?)-12, g => g.NullableSbyteField); - AssertAttribute(reg, "nullable-sbyte-field", null, null, (SByte?)null, g => g.NullableSbyteField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_Byte_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "byte-field", 0, 0, 0, g => g.ByteField); - AssertAttribute(reg, "byte-field", 12, 12, 12, g => g.ByteField); - AssertAttribute(reg, "byte-field", null, 0, 0, g => g.ByteField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_nullable_Byte_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "nullable-byte-field", 0, (Byte?)0, (Byte?)0, g => g.NullableByteField); - AssertAttribute(reg, "nullable-byte-field", 12, (Byte?)12, (Byte?)12, g => g.NullableByteField); - AssertAttribute(reg, "nullable-byte-field", null, null, (Byte?)null, g => g.NullableByteField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_Int16_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "int16-field", 0, 0, 0, g => g.Int16Field); - AssertAttribute(reg, "int16-field", 4000, 4000, 4000, g => g.Int16Field); - AssertAttribute(reg, "int16-field", -4000, -4000, -4000, g => g.Int16Field); - AssertAttribute(reg, "int16-field", null, 0, 0, g => g.Int16Field); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_nullable_Int16_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "nullable-int16-field", 0, (Int16?)0, (Int16?)0, g => g.NullableInt16Field); - AssertAttribute(reg, "nullable-int16-field", 4000, (Int16?)4000, (Int16?)4000, g => g.NullableInt16Field); - AssertAttribute(reg, "nullable-int16-field", -4000, (Int16?)-4000, (Int16?)-4000, g => g.NullableInt16Field); - AssertAttribute(reg, "nullable-int16-field", null, null, (Int16?)null, g => g.NullableInt16Field); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_UInt16_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "uint16-field", 0, 0, 0, g => g.Uint16Field); - AssertAttribute(reg, "uint16-field", 4000, 4000, 4000, g => g.Uint16Field); - AssertAttribute(reg, "uint16-field", null, 0, 0, g => g.Uint16Field); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_nullable_UInt16_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "nullable-uint16-field", 0, (UInt16?)0, (UInt16?)0, g => g.NullableUint16Field); - AssertAttribute(reg, "nullable-uint16-field", 4000, (UInt16?)4000, (UInt16?)4000, g => g.NullableUint16Field); - AssertAttribute(reg, "nullable-uint16-field", null, null, (UInt16?)null, g => g.NullableUint16Field); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_Int32_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "int32-field", 0, 0, 0, g => g.Int32Field); - AssertAttribute(reg, "int32-field", 2000000, 2000000, 2000000, g => g.Int32Field); - AssertAttribute(reg, "int32-field", -2000000, -2000000, -2000000, g => g.Int32Field); - AssertAttribute(reg, "int32-field", null, 0, 0, g => g.Int32Field); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_nullable_Int32_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "nullable-int32-field", 0, 0, (Int32?)0, g => g.NullableInt32Field); - AssertAttribute(reg, "nullable-int32-field", 2000000, 2000000, (Int32?)2000000, g => g.NullableInt32Field); - AssertAttribute(reg, "nullable-int32-field", -2000000, -2000000, (Int32?)-2000000, g => g.NullableInt32Field); - AssertAttribute(reg, "nullable-int32-field", null, null, (Int32?)null, g => g.NullableInt32Field); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_UInt32_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "uint32-field", 0, (UInt32)0, (UInt32)0, g => g.Uint32Field); - AssertAttribute(reg, "uint32-field", 2000000, (UInt32)2000000, (UInt32)2000000, g => g.Uint32Field); - AssertAttribute(reg, "uint32-field", null, (UInt32)0, (UInt32)0, g => g.Uint32Field); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_nullable_UInt32_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "nullable-uint32-field", 0, (UInt32?)0, (UInt32?)0, g => g.NullableUint32Field); - AssertAttribute(reg, "nullable-uint32-field", 2000000, (UInt32?)2000000, (UInt32?)2000000, g => g.NullableUint32Field); - AssertAttribute(reg, "nullable-uint32-field", null, null, (UInt32?)null, g => g.NullableUint32Field); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_Int64_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "int64-field", 0, 0, 0, g => g.Int64Field); - AssertAttribute(reg, "int64-field", 20000000000, 20000000000, 20000000000, g => g.Int64Field); - AssertAttribute(reg, "int64-field", -20000000000, -20000000000, -20000000000, g => g.Int64Field); - AssertAttribute(reg, "int64-field", null, 0, 0, g => g.Int64Field); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_nullable_Int64_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "nullable-int64-field", 0, 0, (Int64?)0, g => g.NullableInt64Field); - AssertAttribute(reg, "nullable-int64-field", 20000000000, 20000000000, (Int64?)20000000000, g => g.NullableInt64Field); - AssertAttribute(reg, "nullable-int64-field", -20000000000, -20000000000, (Int64?)-20000000000, g => g.NullableInt64Field); - AssertAttribute(reg, "nullable-int64-field", null, null, (Int64?)null, g => g.NullableInt64Field); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_UInt64_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "uint64-field", 0, (UInt64)0, (UInt64)0, g => g.Uint64Field); - AssertAttribute(reg, "uint64-field", 20000000000, (UInt64)20000000000, (UInt64)20000000000, g => g.Uint64Field); - AssertAttribute(reg, "uint64-field", null, (UInt64)0, (UInt64)0, g => g.Uint64Field); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_nullable_UInt64_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "nullable-uint64-field", 0, (UInt64?)0, (UInt64?)0, g => g.NullableUint64Field); - AssertAttribute(reg, "nullable-uint64-field", 20000000000, (UInt64?)20000000000, (UInt64?)20000000000, g => g.NullableUint64Field); - AssertAttribute(reg, "nullable-uint64-field", null, null, (UInt64?)null, g => g.NullableUint64Field); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_Single_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "single-field", 0f, 0f, 0f, g => g.SingleField); - AssertAttribute(reg, "single-field", 20000000000.1234f, 20000000000.1234f, 20000000000.1234f, g => g.SingleField); - AssertAttribute(reg, "single-field", -20000000000.1234f, -20000000000.1234f, -20000000000.1234f, g => g.SingleField); - AssertAttribute(reg, "single-field", null, 0, 0, g => g.SingleField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_nullable_Single_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "nullable-single-field", 0f, 0f, 0f, g => g.NullableSingleField); - AssertAttribute(reg, "nullable-single-field", 20000000000.1234f, 20000000000.1234f, (Int64?)20000000000.1234f, g => g.NullableSingleField); - AssertAttribute(reg, "nullable-single-field", -20000000000.1234f, -20000000000.1234f, -20000000000.1234f, g => g.NullableSingleField); - AssertAttribute(reg, "nullable-single-field", null, null, (Single?)null, g => g.NullableSingleField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_Double_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "double-field", 0d, 0d, 0d, g => g.DoubleField); - AssertAttribute(reg, "double-field", 20000000000.1234d, 20000000000.1234d, 20000000000.1234d, g => g.DoubleField); - AssertAttribute(reg, "double-field", null, 0d, 0d, g => g.DoubleField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_nullable_Double_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "nullable-double-field", 0d, 0d, 0d, g => g.NullableDoubleField); - AssertAttribute(reg, "nullable-double-field", 20000000000.1234d, 20000000000.1234d, 20000000000.1234d, g => g.NullableDoubleField); - AssertAttribute(reg, "nullable-double-field", null, null, (Double?)null, g => g.NullableDoubleField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_Decimal_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "decimal-field", "0", 0m, "0", g => g.DecimalField); - AssertAttribute(reg, "decimal-field", "20000000000.1234", 20000000000.1234m, "20000000000.1234", g => g.DecimalField); - AssertAttribute(reg, "decimal-field", null, 0m, "0", g => g.DecimalField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_Decimal_field_non_en_US() - { - // Set up non US culture - var culture = Thread.CurrentThread.CurrentCulture; - Thread.CurrentThread.CurrentCulture = new CultureInfo("se-SE"); - - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - AssertAttribute(reg, "decimal-field", "20000000000.1234", 20000000000.1234m, "20000000000.1234", g => g.DecimalField); - - Thread.CurrentThread.CurrentCulture = culture; - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_nullable_Decimal_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "nullable-decimal-field", "0", 0m, "0", g => g.NullableDecimalField); - AssertAttribute(reg, "nullable-decimal-field", "20000000000.1234", 20000000000.1234m, "20000000000.1234", g => g.NullableDecimalField); - AssertAttribute(reg, "nullable-decimal-field", null, null, (string)null, g => g.NullableDecimalField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_guid_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - var guid = new Guid("6566f9b4-5245-40de-890d-98b40a4ad656"); - AssertAttribute(reg, "guid-field", "6566f9b4-5245-40de-890d-98b40a4ad656", guid, "6566f9b4-5245-40de-890d-98b40a4ad656", g => g.GuidField); - AssertAttribute(reg, "guid-field", null, new Guid(), "00000000-0000-0000-0000-000000000000", g => g.GuidField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_nullable_guid_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - var guid = new Guid("6566f9b4-5245-40de-890d-98b40a4ad656"); - AssertAttribute(reg, "nullable-guid-field", "6566f9b4-5245-40de-890d-98b40a4ad656", guid, "6566f9b4-5245-40de-890d-98b40a4ad656", g => g.NullableGuidField); - AssertAttribute(reg, "nullable-guid-field", null, null, (Guid?)null, g => g.NullableGuidField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_DateTime_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "date-time-field", "1776-07-04", new DateTime(1776, 07, 04, 0, 0, 0, DateTimeKind.Utc), "1776-07-04T00:00:00", g => g.DateTimeField); - AssertAttribute(reg, "date-time-field", "1776-07-04T00:00:00", new DateTime(1776, 07, 04, 0, 0, 0, DateTimeKind.Utc), "1776-07-04T00:00:00", g => g.DateTimeField); - AssertAttribute(reg, "date-time-field", null, new DateTime(), "0001-01-01T00:00:00", g => g.DateTimeField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_nullable_DateTime_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "nullable-date-time-field", "1776-07-04", new DateTime(1776, 07, 04, 0, 0, 0, DateTimeKind.Utc), "1776-07-04T00:00:00", g => g.NullableDateTimeField); - AssertAttribute(reg, "nullable-date-time-field", "1776-07-04T00:00:00", new DateTime(1776, 07, 04, 0, 0, 0, DateTimeKind.Utc), "1776-07-04T00:00:00", g => g.NullableDateTimeField); - AssertAttribute(reg, "nullable-date-time-field", null, null, (DateTime?)null, g => g.NullableDateTimeField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_DateTimeOffset_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - var testDateTimeOffset1 = new DateTimeOffset(new DateTime(1776, 07, 04), TimeSpan.FromHours(-5)); - var testDateTimeOffset2 = new DateTimeOffset(new DateTime(1776, 07, 04, 12, 30, 0), TimeSpan.FromHours(0)); - var testDateTimeOffset3 = new DateTimeOffset(new DateTime(2015, 03, 11, 04, 31, 0), TimeSpan.FromHours(0)); - AssertAttribute(reg, "date-time-offset-field", "1776-07-04T00:00:00-05:00", testDateTimeOffset1, "1776-07-04T00:00:00.0000000-05:00", g => g.DateTimeOffsetField); - AssertAttribute(reg, "date-time-offset-field", "1776-07-04T12:30:00+00:00", testDateTimeOffset2, "1776-07-04T12:30:00.0000000+00:00", g => g.DateTimeOffsetField); - AssertAttribute(reg, "date-time-offset-field", "2015-03-11T04:31:00.0000000+00:00", testDateTimeOffset3, "2015-03-11T04:31:00.0000000+00:00", g => g.DateTimeOffsetField); - AssertAttribute(reg, "date-time-offset-field", null, new DateTimeOffset(), "0001-01-01T00:00:00.0000000+00:00", g => g.DateTimeOffsetField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_nullable_DateTimeOffset_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - var testDateTimeOffset = new DateTimeOffset(new DateTime(1776, 07, 04), TimeSpan.FromHours(-5)); - AssertAttribute(reg, "nullable-date-time-offset-field", "1776-07-04T00:00:00-05:00", testDateTimeOffset, "1776-07-04T00:00:00.0000000-05:00", - g => g.NullableDateTimeOffsetField); - AssertAttribute(reg, "nullable-date-time-offset-field", null, null, (DateTimeOffset?)null, - g => g.NullableDateTimeOffsetField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_string_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "string-field", "asdf", "asdf", "asdf", g => g.StringField); - AssertAttribute(reg, "string-field", null, null, (string)null, g => g.StringField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_enum_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "enum-field", (int)SampleEnum.Value1, SampleEnum.Value1, (int)SampleEnum.Value1, g => g.EnumField); - AssertAttribute(reg, "enum-field", null, (SampleEnum)0, 0, g => g.EnumField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_nullable_enum_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttribute(reg, "nullable-enum-field", (int)SampleEnum.Value1, SampleEnum.Value1, (int)SampleEnum.Value1, g => g.NullableEnumField); - AssertAttribute(reg, "nullable-enum-field", null, null, (SampleEnum?)null, g => g.NullableEnumField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_to_one_complex_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttributeHelper(reg, "to-one-complex-type-field", - new JObject { { "intProp", 32 }, { "StringProp", "qux" } }, - grabBag => - { - grabBag.ToOneComplexTypeField.Should().NotBeNull(); - grabBag.ToOneComplexTypeField.IntProp.Should().Be(32); - grabBag.ToOneComplexTypeField.StringProp.Should().Be("qux"); - }, - token => - { - ((int)token["intProp"]).Should().Be(32); - ((string)token["StringProp"]).Should().Be("qux"); - }); - AssertAttribute(reg, "to-one-complex-type-field", null, null, (SampleComplexType)null, g => g.ToOneComplexTypeField); - } - - [TestMethod] - public void BuildRegistration_sets_up_correct_attribute_for_to_many_complex_field() - { - // Arrange - var registrar = new ResourceTypeRegistrar(new DefaultNamingConventions(new PluralizationService())); - - // Act - var reg = registrar.BuildRegistration(typeof(AttributeGrabBag)); - - // Assert - AssertAttributeHelper(reg, "to-many-complex-type-field", - new JArray - { - new JObject { { "intProp", 49 }, { "StringProp", "blue" } }, - new JObject { { "intProp", 67 }, { "StringProp", "orange" } } - }, - grabBag => - { - var result = grabBag.ToManyComplexTypeField.ToArray(); - result.Length.Should().Be(2); - result[0].IntProp.Should().Be(49); - result[0].StringProp.Should().Be("blue"); - result[1].IntProp.Should().Be(67); - result[1].StringProp.Should().Be("orange"); - }, - token => - { - var jarray = (JArray) token; - jarray.Count.Should().Be(2); - ((int)jarray[0]["intProp"]).Should().Be(49); - ((string)jarray[0]["StringProp"]).Should().Be("blue"); - ((int)jarray[1]["intProp"]).Should().Be(67); - ((string)jarray[1]["StringProp"]).Should().Be("orange"); - }); - AssertAttribute(reg, "to-many-complex-type-field", null, null, (SampleComplexType[])null, g => g.ToManyComplexTypeField); - } - } -} diff --git a/JSONAPI.Tests/Core/ResourceTypeRegistryTests.cs b/JSONAPI.Tests/Core/ResourceTypeRegistryTests.cs deleted file mode 100644 index 7ffdb336..00000000 --- a/JSONAPI.Tests/Core/ResourceTypeRegistryTests.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System; -using FluentAssertions; -using JSONAPI.Core; -using JSONAPI.Tests.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; - -namespace JSONAPI.Tests.Core -{ - [TestClass] - public class ResourceTypeRegistryTests - { - private class DerivedPost : Post - { - - } - - [TestMethod] - public void GetRegistrationForType_returns_correct_value_for_registered_types() - { - // Arrange - var mockPostRegistration = new Mock(MockBehavior.Strict); - mockPostRegistration.Setup(m => m.Type).Returns(typeof(Post)); - mockPostRegistration.Setup(m => m.ResourceTypeName).Returns("posts"); - - var mockAuthorRegistration = new Mock(MockBehavior.Strict); - mockAuthorRegistration.Setup(m => m.Type).Returns(typeof(Author)); - mockAuthorRegistration.Setup(m => m.ResourceTypeName).Returns("authors"); - - var registry = new ResourceTypeRegistry(); - registry.AddRegistration(mockPostRegistration.Object); - registry.AddRegistration(mockAuthorRegistration.Object); - - // Act - var authorReg = registry.GetRegistrationForType(typeof(Author)); - var postReg = registry.GetRegistrationForType(typeof(Post)); - - // Assert - postReg.Should().BeSameAs(mockPostRegistration.Object); - authorReg.Should().BeSameAs(mockAuthorRegistration.Object); - } - - [TestMethod] - public void GetRegistrationForType_gets_registration_for_closest_registered_base_type_for_unregistered_type() - { - // Arrange - var mockPostRegistration = new Mock(MockBehavior.Strict); - mockPostRegistration.Setup(m => m.Type).Returns(typeof(Post)); - mockPostRegistration.Setup(m => m.ResourceTypeName).Returns("posts"); - - var registry = new ResourceTypeRegistry(); - registry.AddRegistration(mockPostRegistration.Object); - - // Act - var registration = registry.GetRegistrationForType(typeof(DerivedPost)); - - // Assert - registration.Type.Should().Be(typeof(Post)); - } - - [TestMethod] - public void GetRegistrationForType_fails_when_getting_unregistered_type() - { - // Arrange - var registry = new ResourceTypeRegistry(); - - // Act - Action action = () => - { - registry.GetRegistrationForType(typeof(Post)); - }; - - // Assert - action.ShouldThrow().WithMessage("No type registration was found for the type \"Post\"."); - } - - [TestMethod] - public void GetRegistrationForResourceTypeName_fails_when_getting_unregistered_type_name() - { - // Arrange - var registry = new ResourceTypeRegistry(); - - // Act - Action action = () => - { - registry.GetRegistrationForResourceTypeName("posts"); - }; - - // Assert - action.ShouldThrow().WithMessage("No type registration was found for the type name \"posts\"."); - } - - [TestMethod] - public void GetRegistrationForResourceTypeName_returns_correct_value_for_registered_names() - { - // Arrange - var mockPostRegistration = new Mock(MockBehavior.Strict); - mockPostRegistration.Setup(m => m.Type).Returns(typeof(Post)); - mockPostRegistration.Setup(m => m.ResourceTypeName).Returns("posts"); - - var mockAuthorRegistration = new Mock(MockBehavior.Strict); - mockAuthorRegistration.Setup(m => m.Type).Returns(typeof(Author)); - mockAuthorRegistration.Setup(m => m.ResourceTypeName).Returns("authors"); - - var registry = new ResourceTypeRegistry(); - registry.AddRegistration(mockPostRegistration.Object); - registry.AddRegistration(mockAuthorRegistration.Object); - - // Act - var postReg = registry.GetRegistrationForResourceTypeName("posts"); - var authorReg = registry.GetRegistrationForResourceTypeName("authors"); - - // Assert - postReg.Should().BeSameAs(mockPostRegistration.Object); - authorReg.Should().BeSameAs(mockAuthorRegistration.Object); - } - - [TestMethod] - public void TypeIsRegistered_returns_true_if_type_is_registered() - { - // Arrange - var mockPostRegistration = new Mock(MockBehavior.Strict); - mockPostRegistration.Setup(m => m.Type).Returns(typeof(Post)); - mockPostRegistration.Setup(m => m.ResourceTypeName).Returns("posts"); - - var registry = new ResourceTypeRegistry(); - registry.AddRegistration(mockPostRegistration.Object); - - // Act - var isRegistered = registry.TypeIsRegistered(typeof(Post)); - - // Assert - isRegistered.Should().BeTrue(); - } - - [TestMethod] - public void TypeIsRegistered_returns_true_if_parent_type_is_registered() - { - // Arrange - var mockPostRegistration = new Mock(MockBehavior.Strict); - mockPostRegistration.Setup(m => m.Type).Returns(typeof(Post)); - mockPostRegistration.Setup(m => m.ResourceTypeName).Returns("posts"); - - var registry = new ResourceTypeRegistry(); - registry.AddRegistration(mockPostRegistration.Object); - - // Act - var isRegistered = registry.TypeIsRegistered(typeof(DerivedPost)); - - // Assert - isRegistered.Should().BeTrue(); - } - - [TestMethod] - public void TypeIsRegistered_returns_false_if_no_type_in_hierarchy_is_registered() - { - // Arrange - var registry = new ResourceTypeRegistry(); - - // Act - var isRegistered = registry.TypeIsRegistered(typeof(Comment)); - - // Assert - isRegistered.Should().BeFalse(); - } - } -} diff --git a/JSONAPI.Tests/Documents/Builders/ErrorDocumentBuilderTests.cs b/JSONAPI.Tests/Documents/Builders/ErrorDocumentBuilderTests.cs deleted file mode 100644 index e5fef359..00000000 --- a/JSONAPI.Tests/Documents/Builders/ErrorDocumentBuilderTests.cs +++ /dev/null @@ -1,162 +0,0 @@ -using System; -using System.Linq; -using System.Net; -using FluentAssertions; -using JSONAPI.Documents; -using JSONAPI.Documents.Builders; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Tests.Documents.Builders -{ - [TestClass] - public class ErrorDocumentBuilderTests - { - private const string GuidRegex = @"\b[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}\b"; - - [TestMethod] - public void Builds_document_from_exception() - { - // Arrange - Exception theException; - try - { - throw new Exception("This is the exception!"); - } - catch (Exception ex) - { - theException = ex; - } - - // Act - var errorDocumentBuilder = new ErrorDocumentBuilder(); - var document = errorDocumentBuilder.BuildFromException(theException); - - // Assert - document.Errors.Length.Should().Be(1); - var error = document.Errors.First(); - error.Id.Should().MatchRegex(GuidRegex); - error.Title.Should().Be("Unhandled exception"); - error.Detail.Should().Be("An unhandled exception was thrown while processing the request."); - error.Status.Should().Be(HttpStatusCode.InternalServerError); - ((string)error.Metadata.MetaObject["exceptionMessage"]).Should().Be("This is the exception!"); - ((string)error.Metadata.MetaObject["stackTrace"]).Should().NotBeNull(); - } - - [TestMethod] - public void Builds_document_from_exception_with_inner_exception() - { - // Arrange - Exception theException; - try - { - try - { - throw new Exception("This is the inner exception!"); - } - catch (Exception ex) - { - throw new Exception("This is the outer exception!", ex); - } - } - catch (Exception ex) - { - theException = ex; - } - - // Act - var errorDocumentBuilder = new ErrorDocumentBuilder(); - var document = errorDocumentBuilder.BuildFromException(theException); - - // Assert - document.Errors.Length.Should().Be(1); - var error = document.Errors.First(); - error.Id.Should().MatchRegex(GuidRegex); - error.Title.Should().Be("Unhandled exception"); - error.Detail.Should().Be("An unhandled exception was thrown while processing the request."); - error.Status.Should().Be(HttpStatusCode.InternalServerError); - ((string)error.Metadata.MetaObject["exceptionMessage"]).Should().Be("This is the outer exception!"); - ((string)error.Metadata.MetaObject["stackTrace"]).Should().NotBeNull(); - - var inner = (JObject)error.Metadata.MetaObject["innerException"]; - ((string)inner["exceptionMessage"]).Should().Be("This is the inner exception!"); - ((string)inner["stackTrace"]).Should().NotBeNull(); - } - - [TestMethod] - public void Builds_document_from_exception_with_two_levels_deep_inner_exception() - { - // Arrange - Exception theException; - try - { - try - { - try - { - throw new Exception("This is the inner exception!"); - } - catch (Exception ex) - { - throw new Exception("This is the middle exception!", ex); - } - } - catch (Exception ex) - { - throw new Exception("This is the outer exception!", ex); - } - } - catch (Exception ex) - { - theException = ex; - } - - // Act - var errorDocumentBuilder = new ErrorDocumentBuilder(); - var document = errorDocumentBuilder.BuildFromException(theException); - - // Assert - document.Errors.Length.Should().Be(1); - var error = document.Errors.First(); - error.Id.Should().MatchRegex(GuidRegex); - error.Title.Should().Be("Unhandled exception"); - error.Detail.Should().Be("An unhandled exception was thrown while processing the request."); - error.Status.Should().Be(HttpStatusCode.InternalServerError); - ((string)error.Metadata.MetaObject["exceptionMessage"]).Should().Be("This is the outer exception!"); - ((string)error.Metadata.MetaObject["stackTrace"]).Should().NotBeNull(); - - var middle = (JObject)error.Metadata.MetaObject["innerException"]; - ((string)middle["exceptionMessage"]).Should().Be("This is the middle exception!"); - ((string)middle["stackTrace"]).Should().NotBeNull(); - - var inner = (JObject)middle["innerException"]; - ((string)inner["exceptionMessage"]).Should().Be("This is the inner exception!"); - ((string)inner["stackTrace"]).Should().NotBeNull(); - } - - [TestMethod] - public void Builds_document_from_JsonApiException() - { - // Arrange - var mockError = new Mock(MockBehavior.Strict); - JsonApiException theException; - try - { - throw new JsonApiException(mockError.Object); - } - catch (JsonApiException ex) - { - theException = ex; - } - - // Act - var errorDocumentBuilder = new ErrorDocumentBuilder(); - var document = errorDocumentBuilder.BuildFromException(theException); - - // Assert - document.Errors.Length.Should().Be(1); - document.Errors.First().Should().Be(mockError.Object); - } - } -} diff --git a/JSONAPI.Tests/Documents/Builders/FallbackDocumentBuilderTests.cs b/JSONAPI.Tests/Documents/Builders/FallbackDocumentBuilderTests.cs deleted file mode 100644 index a6b9f14d..00000000 --- a/JSONAPI.Tests/Documents/Builders/FallbackDocumentBuilderTests.cs +++ /dev/null @@ -1,151 +0,0 @@ -using System.Linq; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using FluentAssertions; -using JSONAPI.Documents; -using JSONAPI.Documents.Builders; -using JSONAPI.Http; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; - -namespace JSONAPI.Tests.Documents.Builders -{ - [TestClass] - public class FallbackDocumentBuilderTests - { - private const string GuidRegex = @"\b[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}\b"; - - class Fruit - { - public string Id { get; set; } - - public string Name { get; set; } - } - - [TestMethod] - public async Task Creates_single_resource_document_for_registered_non_collection_types() - { - // Arrange - var objectContent = new Fruit { Id = "984", Name = "Kiwi" }; - - var mockDocument = new Mock(MockBehavior.Strict); - var includePathExpression = new string[] {}; - - var singleResourceDocumentBuilder = new Mock(MockBehavior.Strict); - singleResourceDocumentBuilder.Setup(b => b.BuildDocument(objectContent, It.IsAny(), includePathExpression, null, null)).Returns(mockDocument.Object); - - var mockQueryableDocumentBuilder = new Mock(MockBehavior.Strict); - var mockResourceCollectionDocumentBuilder = new Mock(MockBehavior.Strict); - - var cancellationTokenSource = new CancellationTokenSource(); - - var request = new HttpRequestMessage(HttpMethod.Get, "https://www.example.com/fruits"); - var mockBaseUrlService = new Mock(MockBehavior.Strict); - mockBaseUrlService.Setup(s => s.GetBaseUrl(request)).Returns("https://www.example.com"); - - var mockSortExpressionExtractor = new Mock(MockBehavior.Strict); - mockSortExpressionExtractor.Setup(e => e.ExtractSortExpressions(request)).Returns(new[] { "id " }); - - var mockIncludeExpressionExtractor = new Mock(MockBehavior.Strict); - mockIncludeExpressionExtractor.Setup(e => e.ExtractIncludeExpressions(request)).Returns(includePathExpression); - - // Act - var fallbackDocumentBuilder = new FallbackDocumentBuilder(singleResourceDocumentBuilder.Object, - mockQueryableDocumentBuilder.Object, mockResourceCollectionDocumentBuilder.Object, mockSortExpressionExtractor.Object, mockIncludeExpressionExtractor.Object, mockBaseUrlService.Object); - var resultDocument = await fallbackDocumentBuilder.BuildDocument(objectContent, request, cancellationTokenSource.Token); - - // Assert - resultDocument.Should().BeSameAs(mockDocument.Object); - } - - [TestMethod] - public async Task Creates_resource_collection_document_for_queryables() - { - // Arrange - var items = new[] - { - new Fruit {Id = "43", Name = "Strawberry"}, - new Fruit {Id = "43", Name = "Grape"} - }.AsQueryable(); - - var mockDocument = new Mock(MockBehavior.Strict); - - var singleResourceDocumentBuilder = new Mock(MockBehavior.Strict); - - var request = new HttpRequestMessage(); - - var mockBaseUrlService = new Mock(MockBehavior.Strict); - mockBaseUrlService.Setup(s => s.GetBaseUrl(request)).Returns("https://www.example.com/"); - - var sortExpressions = new[] { "id" }; - - var includeExpressions = new string[] { }; - - var cancellationTokenSource = new CancellationTokenSource(); - - var mockQueryableDocumentBuilder = new Mock(MockBehavior.Strict); - mockQueryableDocumentBuilder - .Setup(b => b.BuildDocument(items, request, sortExpressions, cancellationTokenSource.Token, includeExpressions)) - .Returns(Task.FromResult(mockDocument.Object)); - - var mockResourceCollectionDocumentBuilder = new Mock(MockBehavior.Strict); - - var mockSortExpressionExtractor = new Mock(MockBehavior.Strict); - mockSortExpressionExtractor.Setup(e => e.ExtractSortExpressions(request)).Returns(sortExpressions); - - var mockIncludeExpressionExtractor = new Mock(MockBehavior.Strict); - mockIncludeExpressionExtractor.Setup(e => e.ExtractIncludeExpressions(request)).Returns(includeExpressions); - - // Act - var fallbackDocumentBuilder = new FallbackDocumentBuilder(singleResourceDocumentBuilder.Object, - mockQueryableDocumentBuilder.Object, mockResourceCollectionDocumentBuilder.Object, mockSortExpressionExtractor.Object, mockIncludeExpressionExtractor.Object, mockBaseUrlService.Object); - var resultDocument = await fallbackDocumentBuilder.BuildDocument(items, request, cancellationTokenSource.Token); - - // Assert - resultDocument.Should().BeSameAs(mockDocument.Object); - } - - [TestMethod] - public async Task Creates_resource_collection_document_for_non_queryable_enumerables() - { - // Arrange - var items = new[] - { - new Fruit {Id = "43", Name = "Strawberry"}, - new Fruit {Id = "43", Name = "Grape"} - }; - - var mockDocument = new Mock(MockBehavior.Strict); - - var singleResourceDocumentBuilder = new Mock(MockBehavior.Strict); - - var cancellationTokenSource = new CancellationTokenSource(); - - var request = new HttpRequestMessage(HttpMethod.Get, "https://www.example.com/fruits"); - - var mockBaseUrlService = new Mock(MockBehavior.Strict); - mockBaseUrlService.Setup(s => s.GetBaseUrl(request)).Returns("https://www.example.com/"); - - var mockQueryableDocumentBuilder = new Mock(MockBehavior.Strict); - var mockResourceCollectionDocumentBuilder = new Mock(MockBehavior.Strict); - mockResourceCollectionDocumentBuilder - .Setup(b => b.BuildDocument(items, "https://www.example.com/", It.IsAny(), It.IsAny(), null)) - .Returns(() => (mockDocument.Object)); - - var mockSortExpressionExtractor = new Mock(MockBehavior.Strict); - mockSortExpressionExtractor.Setup(e => e.ExtractSortExpressions(request)).Returns(new[] { "id " }); - - var mockIncludeExpressionExtractor = new Mock(MockBehavior.Strict); - mockIncludeExpressionExtractor.Setup(e => e.ExtractIncludeExpressions(request)).Returns(new string[] { }); - - // Act - var fallbackDocumentBuilder = new FallbackDocumentBuilder(singleResourceDocumentBuilder.Object, - mockQueryableDocumentBuilder.Object, mockResourceCollectionDocumentBuilder.Object, mockSortExpressionExtractor.Object, mockIncludeExpressionExtractor.Object, mockBaseUrlService.Object); - var resultDocument = await fallbackDocumentBuilder.BuildDocument(items, request, cancellationTokenSource.Token); - - // Assert - resultDocument.Should().BeSameAs(mockDocument.Object); - } - } -} diff --git a/JSONAPI.Tests/Documents/Builders/RegistryDrivenDocumentBuilderTests.cs b/JSONAPI.Tests/Documents/Builders/RegistryDrivenDocumentBuilderTests.cs deleted file mode 100644 index ff943102..00000000 --- a/JSONAPI.Tests/Documents/Builders/RegistryDrivenDocumentBuilderTests.cs +++ /dev/null @@ -1,122 +0,0 @@ -using FluentAssertions; -using JSONAPI.Documents.Builders; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.Tests.Documents.Builders -{ - [TestClass] - public class RegistryDrivenDocumentBuilderTests - { - [TestMethod] - public void PathExpressionMatchesCurrentPath_is_true_when_pathToInclude_equals_currentPath_with_one_segment() - { - // Arrange - const string currentPath = "posts"; - const string pathToInclude = "posts"; - - // Act - var matches = RegistryDrivenDocumentBuilder.PathExpressionMatchesCurrentPath(currentPath, pathToInclude); - - // Assert - matches.Should().BeTrue(); - } - - [TestMethod] - public void PathExpressionMatchesCurrentPath_is_false_when_pathToInclude_does_not_equal_or_start_with_currentPath() - { - // Arrange - const string currentPath = "posts"; - const string pathToInclude = "comments"; - - // Act - var matches = RegistryDrivenDocumentBuilder.PathExpressionMatchesCurrentPath(currentPath, pathToInclude); - - // Assert - matches.Should().BeFalse(); - } - - [TestMethod] - public void PathExpressionMatchesCurrentPath_is_false_when_pathToInclude_is_empty() - { - // Arrange - const string currentPath = ""; - const string pathToInclude = ""; - - // Act - var matches = RegistryDrivenDocumentBuilder.PathExpressionMatchesCurrentPath(currentPath, pathToInclude); - - // Assert - matches.Should().BeFalse(); - } - - [TestMethod] - public void PathExpressionMatchesCurrentPath_is_false_when_pathToInclude_is_null() - { - // Arrange - const string currentPath = null; - const string pathToInclude = null; - - // Act - var matches = RegistryDrivenDocumentBuilder.PathExpressionMatchesCurrentPath(currentPath, pathToInclude); - - // Assert - matches.Should().BeFalse(); - } - - [TestMethod] - public void PathExpressionMatchesCurrentPath_is_true_when_pathToInclude_equals_currentPath_with_multiple_segments() - { - // Arrange - const string currentPath = "posts.author"; - const string pathToInclude = "posts.author"; - - // Act - var matches = RegistryDrivenDocumentBuilder.PathExpressionMatchesCurrentPath(currentPath, pathToInclude); - - // Assert - matches.Should().BeTrue(); - } - - [TestMethod] - public void PathExpressionMatchesCurrentPath_is_true_when_all_segments_of_currentPath_are_contained_by_pathToInclude() - { - // Arrange - const string currentPath = "posts.author"; - const string pathToInclude = "posts.author.comments"; - - // Act - var matches = RegistryDrivenDocumentBuilder.PathExpressionMatchesCurrentPath(currentPath, pathToInclude); - - // Assert - matches.Should().BeTrue(); - } - - [TestMethod] - public void PathExpressionMatchesCurrentPath_is_false_when_all_segments_of_currentPath_are_contained_by_pathToInclude_but_start_doesnt_match() - { - // Arrange - const string currentPath = "posts.author"; - const string pathToInclude = "author.posts.author"; - - // Act - var matches = RegistryDrivenDocumentBuilder.PathExpressionMatchesCurrentPath(currentPath, pathToInclude); - - // Assert - matches.Should().BeFalse(); - } - - [TestMethod] - public void PathExpressionMatchesCurrentPath_is_false_when_pathToInclude_starts_with_currentPath_but_segments_differ() - { - // Arrange - const string currentPath = "posts.author"; - const string pathToInclude = "posts.authora"; - - // Act - var matches = RegistryDrivenDocumentBuilder.PathExpressionMatchesCurrentPath(currentPath, pathToInclude); - - // Assert - matches.Should().BeFalse(); - } - } -} diff --git a/JSONAPI.Tests/Documents/Builders/RegistryDrivenSingleResourceDocumentBuilderTests.cs b/JSONAPI.Tests/Documents/Builders/RegistryDrivenSingleResourceDocumentBuilderTests.cs deleted file mode 100644 index f5afb353..00000000 --- a/JSONAPI.Tests/Documents/Builders/RegistryDrivenSingleResourceDocumentBuilderTests.cs +++ /dev/null @@ -1,288 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using FluentAssertions; -using JSONAPI.Core; -using JSONAPI.Documents; -using JSONAPI.Documents.Builders; -using JSONAPI.Json; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Tests.Documents.Builders -{ - [TestClass] - public class RegistryDrivenSingleResourceDocumentBuilderTests - { - class Country - { - public string Id { get; set; } - - public string Name { get; set; } - - public Continent Continent { get; set; } - - public ICollection Provinces { get; set; } - - public ICollection Cities { get; set; } - } - - class Province - { - public string Id { get; set; } - - public string Name { get; set; } - - public City Capital { get; set; } - } - - class City - { - public string Id { get; set; } - - public string Name { get; set; } - } - - class Continent - { - public string Id { get; set; } - - public string Name { get; set; } - - public ICollection Countries { get; set; } - } - - [TestMethod] - public void Returns_correct_document_for_resource() - { - // Arrange - var city1 = new City - { - Id = "10", - Name = "Madrid" - }; - - var city2 = new City - { - Id = "11", - Name = "Barcelona" - }; - - var city3 = new City - { - Id = "12", - Name = "Badajoz" - }; - - var province1 = new Province - { - Id = "506", - Name = "Badajoz", - Capital = city3 - }; - - var province2 = new Province - { - Id = "507", - Name = "Cuenca", - Capital = null // Leaving null to test a null to-one - }; - - var continent = new Continent - { - Id = "1", - Name = "Europe" - }; - - var country = new Country - { - Id = "4", - Name = "Spain", - Continent = continent, - Provinces = new List { province1, province2 }, - Cities = new List { city1, city2, city3 } - }; - - - // Country registration - var countryName = - new ResourceTypeAttribute( - new PrimitiveTypeAttributeValueConverter(typeof(Country).GetProperty("Name")), null, "name"); - var countryCities = - new ToManyResourceTypeRelationship(typeof(Country).GetProperty("Cities"), "cities", typeof(City), null, null); - var countryProvinces = - new ToManyResourceTypeRelationship(typeof(Country).GetProperty("Provinces"), "provinces", typeof(Province), null, null); - var countryContinent = - new ToOneResourceTypeRelationship(typeof(Country).GetProperty("Continent"), "continent", typeof(Continent), null, null); - var countryRegistration = new Mock(MockBehavior.Strict); - countryRegistration.Setup(m => m.GetIdForResource(It.IsAny())).Returns((Country c) => country.Id); - countryRegistration.Setup(m => m.ResourceTypeName).Returns("countries"); - countryRegistration.Setup(m => m.Attributes).Returns(new[] { countryName }); - countryRegistration - .Setup(m => m.Relationships) - .Returns(() => new ResourceTypeRelationship[] { countryCities, countryProvinces, countryContinent }); - - - // City registration - var cityName = - new ResourceTypeAttribute( - new PrimitiveTypeAttributeValueConverter(typeof(City).GetProperty("Name")), null, "name"); - var cityRegistration = new Mock(MockBehavior.Strict); - cityRegistration.Setup(m => m.ResourceTypeName).Returns("cities"); - cityRegistration.Setup(m => m.GetIdForResource(It.IsAny())).Returns((City c) => c.Id); - cityRegistration.Setup(m => m.Attributes).Returns(new[] { cityName }); - cityRegistration.Setup(m => m.Relationships).Returns(new ResourceTypeRelationship[] { }); - - - // Province registration - var provinceName = - new ResourceTypeAttribute( - new PrimitiveTypeAttributeValueConverter(typeof(Province).GetProperty("Name")), null, "name"); - var provinceCapital = new ToOneResourceTypeRelationship(typeof(Province).GetProperty("Capital"), "capital", typeof(City), null, null); - var provinceRegistration = new Mock(MockBehavior.Strict); - provinceRegistration.Setup(m => m.ResourceTypeName).Returns("provinces"); - provinceRegistration.Setup(m => m.GetIdForResource(It.IsAny())).Returns((Province c) => c.Id); - provinceRegistration.Setup(m => m.Attributes).Returns(new[] { provinceName }); - provinceRegistration - .Setup(m => m.Relationships) - .Returns(() => new ResourceTypeRelationship[] { provinceCapital }); - - - // Continent registration - var continentName = - new ResourceTypeAttribute( - new PrimitiveTypeAttributeValueConverter(typeof(Continent).GetProperty("Name")), null, "name"); - var continentCountries = - new ToManyResourceTypeRelationship(typeof(Continent).GetProperty("Countries"), "countries", typeof(Country), null, null); - var continentRegistration = new Mock(MockBehavior.Strict); - continentRegistration.Setup(m => m.ResourceTypeName).Returns("continents"); - continentRegistration.Setup(m => m.GetIdForResource(It.IsAny())).Returns((Continent c) => c.Id); - continentRegistration.Setup(m => m.Attributes).Returns(new[] { continentName }); - continentRegistration - .Setup(m => m.Relationships) - .Returns(() => new ResourceTypeRelationship[] { continentCountries }); - - var mockRegistry = new Mock(MockBehavior.Strict); - mockRegistry.Setup(r => r.GetRegistrationForType(typeof(Country))).Returns(countryRegistration.Object); - mockRegistry.Setup(r => r.GetRegistrationForType(typeof(City))).Returns(cityRegistration.Object); - mockRegistry.Setup(r => r.GetRegistrationForType(typeof(Province))).Returns(provinceRegistration.Object); - mockRegistry.Setup(r => r.GetRegistrationForType(typeof(Continent))).Returns(continentRegistration.Object); - - var linkConventions = new DefaultLinkConventions(); - - var metadataObject = new JObject(); - metadataObject["baz"] = "qux"; - var metadata = new BasicMetadata(metadataObject); - - // Act - var documentBuilder = new RegistryDrivenSingleResourceDocumentBuilder(mockRegistry.Object, linkConventions); - var document = documentBuilder.BuildDocument(country, "http://www.example.com", new[] { "provinces.capital", "continent" }, metadata, null); - - // Assert - document.PrimaryData.Id.Should().Be("4"); - document.PrimaryData.Type.Should().Be("countries"); - ((string) document.PrimaryData.Attributes["name"]).Should().Be("Spain"); - document.PrimaryData.Relationships.Count.Should().Be(3); - - var citiesRelationship = document.PrimaryData.Relationships.First(); - citiesRelationship.Key.Should().Be("cities"); - citiesRelationship.Value.SelfLink.Href.Should().Be("http://www.example.com/countries/4/relationships/cities"); - citiesRelationship.Value.RelatedResourceLink.Href.Should().Be("http://www.example.com/countries/4/cities"); - citiesRelationship.Value.Linkage.Should().BeNull(); - - var provincesRelationship = document.PrimaryData.Relationships.Skip(1).First(); - provincesRelationship.Key.Should().Be("provinces"); - provincesRelationship.Value.SelfLink.Href.Should().Be("http://www.example.com/countries/4/relationships/provinces"); - provincesRelationship.Value.RelatedResourceLink.Href.Should().Be("http://www.example.com/countries/4/provinces"); - provincesRelationship.Value.Linkage.IsToMany.Should().BeTrue(); - provincesRelationship.Value.Linkage.Identifiers[0].Type.Should().Be("provinces"); - provincesRelationship.Value.Linkage.Identifiers[0].Id.Should().Be("506"); - provincesRelationship.Value.Linkage.Identifiers[1].Type.Should().Be("provinces"); - provincesRelationship.Value.Linkage.Identifiers[1].Id.Should().Be("507"); - - var continentRelationship = document.PrimaryData.Relationships.Skip(2).First(); - AssertToOneRelationship(continentRelationship, "continent", - "http://www.example.com/countries/4/relationships/continent", - "http://www.example.com/countries/4/continent", - "continents", "1"); - - document.RelatedData.Length.Should().Be(4); // 2 provinces, 1 city, and 1 continent - - var province1RelatedData = document.RelatedData[0]; - province1RelatedData.Id.Should().Be("506"); - province1RelatedData.Attributes["name"].Value().Should().Be("Badajoz"); - province1RelatedData.Type.Should().Be("provinces"); - province1RelatedData.Relationships.Count.Should().Be(1); - - var province1CapitalRelationship = province1RelatedData.Relationships.First(); - AssertToOneRelationship(province1CapitalRelationship, "capital", - "http://www.example.com/provinces/506/relationships/capital", - "http://www.example.com/provinces/506/capital", - "cities", "12"); - - var province2RelatedData = document.RelatedData[1]; - province2RelatedData.Id.Should().Be("507"); - province2RelatedData.Type.Should().Be("provinces"); - province2RelatedData.Attributes["name"].Value().Should().Be("Cuenca"); - - var province2CapitalRelationship = province2RelatedData.Relationships.First(); - AssertEmptyToOneRelationship(province2CapitalRelationship, "capital", - "http://www.example.com/provinces/507/relationships/capital", - "http://www.example.com/provinces/507/capital"); - - var city3RelatedData = document.RelatedData[2]; - city3RelatedData.Id.Should().Be("12"); - city3RelatedData.Type.Should().Be("cities"); - city3RelatedData.Attributes["name"].Value().Should().Be("Badajoz"); - - var continentRelatedData = document.RelatedData[3]; - continentRelatedData.Id.Should().Be("1"); - continentRelatedData.Type.Should().Be("continents"); - continentRelatedData.Attributes["name"].Value().Should().Be("Europe"); - continentRelatedData.Relationships.Count.Should().Be(1); - var continentCountriesRelationship = continentRelatedData.Relationships.First(); - continentCountriesRelationship.Key.Should().Be("countries"); - continentCountriesRelationship.Value.SelfLink.Href.Should().Be("http://www.example.com/continents/1/relationships/countries"); - continentCountriesRelationship.Value.RelatedResourceLink.Href.Should().Be("http://www.example.com/continents/1/countries"); - continentCountriesRelationship.Value.Linkage.Should().BeNull(); - - ((string) document.Metadata.MetaObject["baz"]).Should().Be("qux"); - } - - [TestMethod] - public void Returns_correct_document_for_null_resource() - { - // Arrange - var mockRegistry = new Mock(MockBehavior.Strict); - var linkConventions = new DefaultLinkConventions(); - - // Act - var documentBuilder = new RegistryDrivenSingleResourceDocumentBuilder(mockRegistry.Object, linkConventions); - var document = documentBuilder.BuildDocument(null, "http://www.example.com", null, null, null); - - // Assert - document.PrimaryData.Should().BeNull(); - } - - private void AssertToOneRelationship(KeyValuePair relationshipPair, string keyName, string selfLink, string relatedResourceLink, - string linkageType, string linkageId) - { - relationshipPair.Key.Should().Be(keyName); - relationshipPair.Value.SelfLink.Href.Should().Be(selfLink); - relationshipPair.Value.RelatedResourceLink.Href.Should().Be(relatedResourceLink); - relationshipPair.Value.Linkage.IsToMany.Should().BeFalse(); - relationshipPair.Value.Linkage.Identifiers.Length.Should().Be(1); - relationshipPair.Value.Linkage.Identifiers[0].Type.Should().Be(linkageType); - relationshipPair.Value.Linkage.Identifiers[0].Id.Should().Be(linkageId); - } - - private void AssertEmptyToOneRelationship(KeyValuePair relationshipPair, string keyName, string selfLink, string relatedResourceLink) - { - relationshipPair.Key.Should().Be(keyName); - relationshipPair.Value.SelfLink.Href.Should().Be(selfLink); - relationshipPair.Value.RelatedResourceLink.Href.Should().Be(relatedResourceLink); - relationshipPair.Value.Linkage.IsToMany.Should().BeFalse(); - relationshipPair.Value.Linkage.Identifiers.Length.Should().Be(0); - } - } -} diff --git a/JSONAPI.Tests/Documents/DefaultLinkConventionsTests.cs b/JSONAPI.Tests/Documents/DefaultLinkConventionsTests.cs deleted file mode 100644 index f34c93bd..00000000 --- a/JSONAPI.Tests/Documents/DefaultLinkConventionsTests.cs +++ /dev/null @@ -1,190 +0,0 @@ -using System.Collections.Generic; -using FluentAssertions; -using JSONAPI.Core; -using JSONAPI.Documents; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; - -namespace JSONAPI.Tests.Documents -{ - [TestClass] - public class DefaultLinkConventionsTests - { - class Country - { - public string Id { get; set; } - - public ICollection Cities { get; set; } - } - - class City - { - public string Id { get; set; } - } - - [TestMethod] - public void GetRelationshipLink_returns_default_url_for_relationship() - { - // Arrange - var relationshipOwner = new Country { Id = "45" }; - var relationshipProperty = new ToManyResourceTypeRelationship(typeof (Country).GetProperty("Cities"), - "cities", typeof (City), null, null); - var mockTypeRegistration = new Mock(MockBehavior.Strict); - mockTypeRegistration.Setup(r => r.ResourceTypeName).Returns("countries"); - mockTypeRegistration.Setup(r => r.GetIdForResource(relationshipOwner)).Returns("45"); - var mockRegistry = new Mock(MockBehavior.Strict); - mockRegistry.Setup(m => m.GetRegistrationForType(typeof(Country))).Returns(mockTypeRegistration.Object); - - // Act - var conventions = new DefaultLinkConventions(); - var relationshipLink = conventions.GetRelationshipLink(relationshipOwner, mockRegistry.Object, relationshipProperty, "https://www.example.com"); - - // Assert - relationshipLink.Href.Should().Be("https://www.example.com/countries/45/relationships/cities"); - } - - [TestMethod] - public void GetRelationshipLink_returns_default_url_for_relationship_when_base_url_has_trailing_slash() - { - // Arrange - var relationshipOwner = new Country { Id = "45" }; - var relationshipProperty = new ToManyResourceTypeRelationship(typeof(Country).GetProperty("Cities"), - "cities", typeof(City), null, null); - var mockTypeRegistration = new Mock(MockBehavior.Strict); - mockTypeRegistration.Setup(r => r.ResourceTypeName).Returns("countries"); - mockTypeRegistration.Setup(r => r.GetIdForResource(relationshipOwner)).Returns("45"); - var mockRegistry = new Mock(MockBehavior.Strict); - mockRegistry.Setup(m => m.GetRegistrationForType(typeof(Country))).Returns(mockTypeRegistration.Object); - - // Act - var conventions = new DefaultLinkConventions(); - var relationshipLink = conventions.GetRelationshipLink(relationshipOwner, mockRegistry.Object, relationshipProperty, "https://www.example.com"); - - // Assert - relationshipLink.Href.Should().Be("https://www.example.com/countries/45/relationships/cities"); - } - - [TestMethod] - public void GetRelationshipLink_is_correct_if_template_is_present() - { - // Arrange - var relationshipOwner = new Country { Id = "45" }; - var relationshipProperty = new ToManyResourceTypeRelationship(typeof(Country).GetProperty("Cities"), - "cities", typeof(City), "foo/{1}/bar", null); - var mockTypeRegistration = new Mock(MockBehavior.Strict); - mockTypeRegistration.Setup(r => r.GetIdForResource(relationshipOwner)).Returns("45"); - var mockRegistry = new Mock(MockBehavior.Strict); - mockRegistry.Setup(m => m.GetRegistrationForType(typeof(Country))).Returns(mockTypeRegistration.Object); - - // Act - var conventions = new DefaultLinkConventions(); - var relationshipLink = conventions.GetRelationshipLink(relationshipOwner, mockRegistry.Object, relationshipProperty, "https://www.example.com"); - - // Assert - relationshipLink.Href.Should().Be("https://www.example.com/foo/45/bar"); - } - - [TestMethod] - public void GetRelationshipLink_is_correct_if_template_is_present_and_base_url_has_trailing_slash() - { - // Arrange - var relationshipOwner = new Country { Id = "45" }; - var relationshipProperty = new ToManyResourceTypeRelationship(typeof(Country).GetProperty("Cities"), - "cities", typeof(City), "foo/{1}/bar", null); - var mockTypeRegistration = new Mock(MockBehavior.Strict); - mockTypeRegistration.Setup(r => r.GetIdForResource(relationshipOwner)).Returns("45"); - var mockRegistry = new Mock(MockBehavior.Strict); - mockRegistry.Setup(m => m.GetRegistrationForType(typeof(Country))).Returns(mockTypeRegistration.Object); - - // Act - var conventions = new DefaultLinkConventions(); - var relationshipLink = conventions.GetRelationshipLink(relationshipOwner, mockRegistry.Object, relationshipProperty, "https://www.example.com"); - - // Assert - relationshipLink.Href.Should().Be("https://www.example.com/foo/45/bar"); - } - - [TestMethod] - public void GetRelatedResourceLink_returns_default_url_for_relationship() - { - // Arrange - var relationshipOwner = new Country { Id = "45" }; - var relationshipProperty = new ToManyResourceTypeRelationship(typeof(Country).GetProperty("Cities"), - "cities", typeof(City), null, null); - var mockTypeRegistration = new Mock(MockBehavior.Strict); - mockTypeRegistration.Setup(r => r.ResourceTypeName).Returns("countries"); - mockTypeRegistration.Setup(r => r.GetIdForResource(relationshipOwner)).Returns("45"); - var mockRegistry = new Mock(MockBehavior.Strict); - mockRegistry.Setup(m => m.GetRegistrationForType(typeof(Country))).Returns(mockTypeRegistration.Object); - - // Act - var conventions = new DefaultLinkConventions(); - var relationshipLink = conventions.GetRelatedResourceLink(relationshipOwner, mockRegistry.Object, relationshipProperty, "https://www.example.com"); - - // Assert - relationshipLink.Href.Should().Be("https://www.example.com/countries/45/cities"); - } - - [TestMethod] - public void GetRelatedResourceLink_returns_default_url_for_relationship_when_base_url_has_trailing_slash() - { - // Arrange - var relationshipOwner = new Country { Id = "45" }; - var relationshipProperty = new ToManyResourceTypeRelationship(typeof(Country).GetProperty("Cities"), - "cities", typeof(City), null, null); - var mockTypeRegistration = new Mock(MockBehavior.Strict); - mockTypeRegistration.Setup(r => r.ResourceTypeName).Returns("countries"); - mockTypeRegistration.Setup(r => r.GetIdForResource(relationshipOwner)).Returns("45"); - var mockRegistry = new Mock(MockBehavior.Strict); - mockRegistry.Setup(m => m.GetRegistrationForType(typeof(Country))).Returns(mockTypeRegistration.Object); - - // Act - var conventions = new DefaultLinkConventions(); - var relationshipLink = conventions.GetRelatedResourceLink(relationshipOwner, mockRegistry.Object, relationshipProperty, "https://www.example.com"); - - // Assert - relationshipLink.Href.Should().Be("https://www.example.com/countries/45/cities"); - } - - [TestMethod] - public void GetRelatedResourceLink_is_correct_if_template_is_present() - { - // Arrange - var relationshipOwner = new Country { Id = "45" }; - var relationshipProperty = new ToManyResourceTypeRelationship(typeof(Country).GetProperty("Cities"), - "cities", typeof(City), null, "bar/{1}/qux"); - var mockTypeRegistration = new Mock(MockBehavior.Strict); - mockTypeRegistration.Setup(r => r.GetIdForResource(relationshipOwner)).Returns("45"); - var mockRegistry = new Mock(MockBehavior.Strict); - mockRegistry.Setup(m => m.GetRegistrationForType(typeof(Country))).Returns(mockTypeRegistration.Object); - - // Act - var conventions = new DefaultLinkConventions(); - var relationshipLink = conventions.GetRelatedResourceLink(relationshipOwner, mockRegistry.Object, relationshipProperty, "https://www.example.com"); - - // Assert - relationshipLink.Href.Should().Be("https://www.example.com/bar/45/qux"); - } - - [TestMethod] - public void GetRelatedResourceLink_is_correct_if_template_is_present_and_base_url_has_trailing_slash() - { - // Arrange - var relationshipOwner = new Country { Id = "45" }; - var relationshipProperty = new ToManyResourceTypeRelationship(typeof(Country).GetProperty("Cities"), - "cities", typeof(City), null, "bar/{1}/qux"); - var mockTypeRegistration = new Mock(MockBehavior.Strict); - mockTypeRegistration.Setup(r => r.GetIdForResource(relationshipOwner)).Returns("45"); - var mockRegistry = new Mock(MockBehavior.Strict); - mockRegistry.Setup(m => m.GetRegistrationForType(typeof(Country))).Returns(mockTypeRegistration.Object); - - // Act - var conventions = new DefaultLinkConventions(); - var relationshipLink = conventions.GetRelatedResourceLink(relationshipOwner, mockRegistry.Object, relationshipProperty, "https://www.example.com"); - - // Assert - relationshipLink.Href.Should().Be("https://www.example.com/bar/45/qux"); - } - - } -} diff --git a/JSONAPI.Tests/Documents/ToManyResourceLinkageTests.cs b/JSONAPI.Tests/Documents/ToManyResourceLinkageTests.cs deleted file mode 100644 index 80196eba..00000000 --- a/JSONAPI.Tests/Documents/ToManyResourceLinkageTests.cs +++ /dev/null @@ -1,47 +0,0 @@ -using FluentAssertions; -using JSONAPI.Documents; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; - -namespace JSONAPI.Tests.Documents -{ - [TestClass] - public class ToManyResourceLinkageTests - { - [TestMethod] - public void Identifiers_is_correct_for_present_identifiers() - { - var mockIdentifier1 = new Mock(MockBehavior.Strict); - mockIdentifier1.Setup(i => i.Type).Returns("countries"); - mockIdentifier1.Setup(i => i.Id).Returns("1000"); - - var mockIdentifier2 = new Mock(MockBehavior.Strict); - mockIdentifier2.Setup(i => i.Type).Returns("cities"); - mockIdentifier2.Setup(i => i.Id).Returns("4000"); - - var linkage = new ToManyResourceLinkage(new [] { mockIdentifier1.Object, mockIdentifier2.Object }); - - linkage.Identifiers.Length.Should().Be(2); - linkage.Identifiers[0].Type.Should().Be("countries"); - linkage.Identifiers[0].Id.Should().Be("1000"); - linkage.Identifiers[1].Type.Should().Be("cities"); - linkage.Identifiers[1].Id.Should().Be("4000"); - } - - [TestMethod] - public void Returns_corrent_LinkageToken_for_null_identifiers() - { - var linkage = new ToManyResourceLinkage(null); - - linkage.Identifiers.Length.Should().Be(0); - } - - [TestMethod] - public void Returns_corrent_LinkageToken_for_empty_identifiers() - { - var linkage = new ToManyResourceLinkage(new IResourceIdentifier[] { }); - - linkage.Identifiers.Length.Should().Be(0); - } - } -} \ No newline at end of file diff --git a/JSONAPI.Tests/Documents/ToOneResourceLinkageTests.cs b/JSONAPI.Tests/Documents/ToOneResourceLinkageTests.cs deleted file mode 100644 index 7c524612..00000000 --- a/JSONAPI.Tests/Documents/ToOneResourceLinkageTests.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Linq; -using FluentAssertions; -using JSONAPI.Documents; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; - -namespace JSONAPI.Tests.Documents -{ - [TestClass] - public class ToOneResourceLinkageTests - { - [TestMethod] - public void Identifiers_is_correct_for_present_identifier() - { - var mockIdentifier = new Mock(MockBehavior.Strict); - mockIdentifier.Setup(i => i.Type).Returns("countries"); - mockIdentifier.Setup(i => i.Id).Returns("1000"); - - var linkage = new ToOneResourceLinkage(mockIdentifier.Object); - - linkage.Identifiers.Length.Should().Be(1); - linkage.Identifiers.First().Type.Should().Be("countries"); - linkage.Identifiers.First().Id.Should().Be("1000"); - } - - [TestMethod] - public void Identifiers_is_correct_for_missing_identifier() - { - var linkage = new ToOneResourceLinkage(null); - - linkage.Identifiers.Length.Should().Be(0); - } - } -} \ No newline at end of file diff --git a/JSONAPI.Tests/Extensions/TypeExtensionsTests.cs b/JSONAPI.Tests/Extensions/TypeExtensionsTests.cs deleted file mode 100644 index 9d593abc..00000000 --- a/JSONAPI.Tests/Extensions/TypeExtensionsTests.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using JSONAPI.Extensions; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Tests.Extensions -{ - [TestClass] - public class TypeExtensionsTests - { - private enum TestEnum - { - - } - - [TestMethod] - public void CanWriteAsJsonApiAttributeTest() - { - Assert.IsTrue(typeof(Byte).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for Byte!"); - Assert.IsTrue(typeof(Byte?).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for nullable Byte!"); - Assert.IsTrue(typeof(SByte).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for SByte!"); - Assert.IsTrue(typeof(SByte?).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for nullable SByte!"); - Assert.IsTrue(typeof(UInt16).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for UInt16!"); - Assert.IsTrue(typeof(UInt16?).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for nullable UInt16!"); - Assert.IsTrue(typeof(Int16).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for Int16!"); - Assert.IsTrue(typeof(Int16?).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for nullable Int16!"); - Assert.IsTrue(typeof(UInt32).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for UInt32!"); - Assert.IsTrue(typeof(UInt32?).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for nullable UInt32!"); - Assert.IsTrue(typeof(Int32).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for Int32!"); - Assert.IsTrue(typeof(Int32?).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for nullable Int32!"); - Assert.IsTrue(typeof(UInt64).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for UInt64!"); - Assert.IsTrue(typeof(UInt64?).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for nullable UInt64!"); - Assert.IsTrue(typeof(Int64).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for Int64!"); - Assert.IsTrue(typeof(Int64?).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for nullable Int64!"); - Assert.IsTrue(typeof(Double).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for Double!"); - Assert.IsTrue(typeof(Double?).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for nullable Double!"); - Assert.IsTrue(typeof(Single).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for Single!"); - Assert.IsTrue(typeof(Single?).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for nullable Single!"); - Assert.IsTrue(typeof(Decimal).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for Decimal!"); - Assert.IsTrue(typeof(Decimal?).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for nullable Decimal!"); - Assert.IsTrue(typeof(DateTime).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for DateTime!"); - Assert.IsTrue(typeof(DateTime?).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for nullable DateTime!"); - Assert.IsTrue(typeof(DateTimeOffset).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for DateTimeOffset!"); - Assert.IsTrue(typeof(DateTimeOffset?).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for nullable DateTimeOffset!"); - Assert.IsTrue(typeof(Guid).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for Guid!"); - Assert.IsTrue(typeof(Guid?).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for nullable Guid!"); - Assert.IsTrue(typeof(String).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for String!"); - Assert.IsTrue(typeof(TestEnum).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for enum!"); - Assert.IsTrue(typeof(TestEnum?).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for nullable enum!"); - Assert.IsTrue(typeof(JToken).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for JToken!"); - Assert.IsTrue(typeof(JObject).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for JObject!"); - Assert.IsTrue(typeof(JArray).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for Jarray!"); - Assert.IsFalse(typeof(Object).CanWriteAsJsonApiAttribute(), "CanWriteTypeAsAttribute returned wrong answer for Object!"); - } - - } -} diff --git a/JSONAPI.Tests/Http/BaseUrlServiceTest.cs b/JSONAPI.Tests/Http/BaseUrlServiceTest.cs deleted file mode 100644 index 304ae60f..00000000 --- a/JSONAPI.Tests/Http/BaseUrlServiceTest.cs +++ /dev/null @@ -1,287 +0,0 @@ -using System; -using System.Net.Http; -using FluentAssertions; -using JSONAPI.Http; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.Tests.Http -{ - [TestClass] - public class BaseUrlServiceTest - { - [TestMethod] - public void BaseUrlRootTest() - { - // Arrange - const string uri = "http://api.example.com/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService(); - - // Act - var baseUrl =baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("http://api.example.com/"); - } - - [TestMethod] - public void BaseUrlOneLevelTest() - { - // Arrange - const string uri = "http://api.example.com/api/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService("api"); - - // Act - var baseUrl = baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("http://api.example.com/api/"); - } - - [TestMethod] - public void BaseUrlOneLevelSlashTest() - { - // Arrange - const string uri = "http://api.example.com/api/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService("/api"); - - // Act - var baseUrl = baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("http://api.example.com/api/"); - } - - [TestMethod] - public void BaseUrlOneLevelSlash2Test() - { - // Arrange - const string uri = "http://api.example.com/api/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService("api/"); - - // Act - var baseUrl = baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("http://api.example.com/api/"); - } - - [TestMethod] - public void BaseUrlTwoLevelTest() - { - // Arrange - const string uri = "http://api.example.com/api/superapi/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService("api/superapi"); - - // Act - var baseUrl = baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("http://api.example.com/api/superapi/"); - } - - [TestMethod] - public void BaseUrlTwoLevelSlashTest() - { - // Arrange - const string uri = "http://api.example.com/api/superapi/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService("api/superapi/"); - - // Act - var baseUrl = baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("http://api.example.com/api/superapi/"); - } - - [TestMethod] - public void BaseUrlTwoLevelSlash2Test() - { - // Arrange - const string uri = "http://api.example.com/api/superapi/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService("/api/superapi/"); - - // Act - var baseUrl = baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("http://api.example.com/api/superapi/"); - } - - [TestMethod] - public void BaseUrlConflictingNameTest() - { - // Arrange - const string uri = "http://api.example.com/api/superapi?sort=api-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService("api"); - - // Act - var baseUrl = baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("http://api.example.com/api/"); - } - - - [TestMethod] - public void BaseUrlPublicOriginTest() - { - // Arrange - const string uri = "http://wwwhost123/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService(new Uri("http://api.example.com/"), ""); - - // Act - var baseUrl = baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("http://api.example.com/"); - } - - [TestMethod] - public void BaseUrlPublicOriginNoSlashTest() - { - // Arrange - const string uri = "http://wwwhost123/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService(new Uri("http://api.example.com"), ""); - - // Act - var baseUrl = baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("http://api.example.com/"); - } - - [TestMethod] - public void BaseUrlPublicOriginHttpsTest() - { - // Arrange - const string uri = "http://wwwhost123/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService(new Uri("https://api.example.com/"), ""); - - // Act - var baseUrl = baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("https://api.example.com/"); - } - - [TestMethod] - public void BaseUrlPublicOriginHttpsHighPortTest() - { - // Arrange - const string uri = "http://wwwhost123/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService(new Uri("https://api.example.com:12443/"), ""); - - // Act - var baseUrl = baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("https://api.example.com:12443/"); - } - - [TestMethod] - public void BaseUrlPublicOriginInternalPortTest() - { - // Arrange - const string uri = "http://wwwhost123:8080/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService(new Uri("http://api.example.com/"), ""); - - // Act - var baseUrl = baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("http://api.example.com/"); - } - - - - [TestMethod] - public void BaseUrlPublicOriginContextPathTest() - { - // Arrange - const string uri = "http://wwwhost123/api/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService(new Uri("http://api.example.com/"), "api"); - - // Act - var baseUrl = baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("http://api.example.com/api/"); - } - - [TestMethod] - public void BaseUrlPublicOriginNoSlashContextPathTest() - { - // Arrange - const string uri = "http://wwwhost123/api/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService(new Uri("http://api.example.com"), "/api/"); - - // Act - var baseUrl = baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("http://api.example.com/api/"); - } - - [TestMethod] - public void BaseUrlPublicOriginHttpsContextPathTest() - { - // Arrange - const string uri = "http://wwwhost123/api/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService(new Uri("https://api.example.com/"), "/api"); - - // Act - var baseUrl = baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("https://api.example.com/api/"); - } - - [TestMethod] - public void BaseUrlPublicOriginHttpsHighPortContextPathTest() - { - // Arrange - const string uri = "http://wwwhost123/api/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService(new Uri("https://api.example.com:12443/"), "api"); - - // Act - var baseUrl = baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("https://api.example.com:12443/api/"); - } - - [TestMethod] - public void BaseUrlPublicOriginInternalPortContextPathTest() - { - // Arrange - const string uri = "http://wwwhost123:8080/api/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var baseUrlService = new BaseUrlService(new Uri("http://api.example.com/"), "api"); - - // Act - var baseUrl = baseUrlService.GetBaseUrl(request); - - // Assert - baseUrl.Should().BeEquivalentTo("http://api.example.com/api/"); - } - - - } -} diff --git a/JSONAPI.Tests/Http/DefaultIncludeExpressionExtractorTests.cs b/JSONAPI.Tests/Http/DefaultIncludeExpressionExtractorTests.cs deleted file mode 100644 index 0fb65380..00000000 --- a/JSONAPI.Tests/Http/DefaultIncludeExpressionExtractorTests.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Net.Http; -using FluentAssertions; -using JSONAPI.Http; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.Tests.Http -{ - [TestClass] - public class DefaultIncludeExpressionExtractorTests - { - [TestMethod] - public void ExtractsSingleIncludeExpressionFromUri() - { - // Arrange - const string uri = "http://api.example.com/dummies?include=boss"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - - // Act - var extractor = new DefaultIncludeExpressionExtractor(); - var inclExpressions = extractor.ExtractIncludeExpressions(request); - - // Assert - inclExpressions.Should().BeEquivalentTo("boss"); - } - - - [TestMethod] - public void ExtractsMultipleIncludeExpressionsFromUri() - { - // Arrange - const string uri = "http://api.example.com/dummies?include=boss,office-address"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - - // Act - var extractor = new DefaultIncludeExpressionExtractor(); - var inclExpressions = extractor.ExtractIncludeExpressions(request); - - // Assert - inclExpressions.Should().BeEquivalentTo("boss", "office-address"); - } - - [TestMethod] - public void ExtractsNothingWhenThereIsNoIncludeParam() - { - // Arrange - const string uri = "http://api.example.com/dummies"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - - // Act - var extractor = new DefaultIncludeExpressionExtractor(); - var inclExpression = extractor.ExtractIncludeExpressions(request); - - // Assert - inclExpression.Length.Should().Be(0); - } - } -} diff --git a/JSONAPI.Tests/Http/DefaultSortExpressionExtractorTests.cs b/JSONAPI.Tests/Http/DefaultSortExpressionExtractorTests.cs deleted file mode 100644 index 85b6003b..00000000 --- a/JSONAPI.Tests/Http/DefaultSortExpressionExtractorTests.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System.Net.Http; -using FluentAssertions; -using JSONAPI.Http; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace JSONAPI.Tests.Http -{ - [TestClass] - public class DefaultSortExpressionExtractorTests - { - [TestMethod] - public void ExtractsSingleSortExpressionFromUri() - { - // Arrange - const string uri = "http://api.example.com/dummies?sort=first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - - // Act - var extractor = new DefaultSortExpressionExtractor(); - var sortExpressions = extractor.ExtractSortExpressions(request); - - // Assert - sortExpressions.Should().BeEquivalentTo("first-name"); - } - - [TestMethod] - public void ExtractsSingleDescendingSortExpressionFromUri() - { - // Arrange - const string uri = "http://api.example.com/dummies?sort=-first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - - // Act - var extractor = new DefaultSortExpressionExtractor(); - var sortExpressions = extractor.ExtractSortExpressions(request); - - // Assert - sortExpressions.Should().BeEquivalentTo("-first-name"); - } - - [TestMethod] - public void ExtractsMultipleSortExpressionsFromUri() - { - // Arrange - const string uri = "http://api.example.com/dummies?sort=last-name,first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - - // Act - var extractor = new DefaultSortExpressionExtractor(); - var sortExpressions = extractor.ExtractSortExpressions(request); - - // Assert - sortExpressions.Should().BeEquivalentTo("last-name", "first-name"); - } - - [TestMethod] - public void ExtractsMultipleSortExpressionsFromUriWithDifferentDirections() - { - // Arrange - const string uri = "http://api.example.com/dummies?sort=last-name,-first-name"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - - // Act - var extractor = new DefaultSortExpressionExtractor(); - var sortExpressions = extractor.ExtractSortExpressions(request); - - // Assert - sortExpressions.Should().BeEquivalentTo("last-name", "-first-name"); - } - - [TestMethod] - public void ExtractsNothingWhenThereIsNoSortParam() - { - // Arrange - const string uri = "http://api.example.com/dummies"; - var request = new HttpRequestMessage(HttpMethod.Get, uri); - - // Act - var extractor = new DefaultSortExpressionExtractor(); - var sortExpressions = extractor.ExtractSortExpressions(request); - - // Assert - sortExpressions.Length.Should().Be(0); - } - } -} diff --git a/JSONAPI.Tests/JSONAPI.Tests.csproj b/JSONAPI.Tests/JSONAPI.Tests.csproj deleted file mode 100644 index 7f487003..00000000 --- a/JSONAPI.Tests/JSONAPI.Tests.csproj +++ /dev/null @@ -1,200 +0,0 @@ - - - - Debug - AnyCPU - - - 2.0 - {8299ECFA-EA68-4C1D-9488-0D213D15D644} - Library - Properties - JSONAPI.Tests - JSONAPI.Tests - v4.5 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - ..\ - true - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - - ..\packages\FluentAssertions.3.2.2\lib\net45\FluentAssertions.dll - - - ..\packages\FluentAssertions.3.2.2\lib\net45\FluentAssertions.Core.dll - - - - False - ..\packages\Moq.4.2.1502.0911\lib\net40\Moq.dll - - - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - - - - 3.5 - - - - False - ..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll - - - False - ..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll - - - False - ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.2\lib\net45\System.Web.Http.WebHost.dll - - - - - - - False - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {0fe799ec-b6c5-499b-b56c-b97613342f6c} - JSONAPI.Tests.SingleControllerWebApp - - - {52b19fd6-efaa-45b5-9c3e-a652e27608d1} - JSONAPI - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.Tests/Json/ErrorDocumentFormatterTests.cs b/JSONAPI.Tests/Json/ErrorDocumentFormatterTests.cs deleted file mode 100644 index 34ce4a1e..00000000 --- a/JSONAPI.Tests/Json/ErrorDocumentFormatterTests.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Threading.Tasks; -using JSONAPI.Documents; -using JSONAPI.Json; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using Newtonsoft.Json; - -namespace JSONAPI.Tests.Json -{ - [TestClass] - public class ErrorDocumentFormatterTests : JsonApiFormatterTestsBase - { - [TestMethod] - public async Task Serialize_ErrorDocument() - { - var error1 = new Mock(MockBehavior.Strict); - var error2 = new Mock(MockBehavior.Strict); - - var mockErrorFormatter = new Mock(MockBehavior.Strict); - mockErrorFormatter.Setup(s => s.Serialize(error1.Object, It.IsAny())) - .Returns((IError error, JsonWriter writer) => - { - writer.WriteValue("first error would go here"); - return Task.FromResult(0); - }); - mockErrorFormatter.Setup(s => s.Serialize(error2.Object, It.IsAny())) - .Returns((IError error, JsonWriter writer) => - { - writer.WriteValue("second error would go here"); - return Task.FromResult(0); - }); - - var mockMetadata = new Mock(MockBehavior.Strict); - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - mockMetadataFormatter.Setup(s => s.Serialize(mockMetadata.Object, It.IsAny())) - .Returns((IMetadata metadata, JsonWriter writer) => - { - writer.WriteValue("metadata goes here"); - return Task.FromResult(0); - }); - - IErrorDocument document = new ErrorDocument(new[] { error1.Object, error2.Object }, mockMetadata.Object); - - var formatter = new ErrorDocumentFormatter(mockErrorFormatter.Object, mockMetadataFormatter.Object); - await AssertSerializeOutput(formatter, document, "Json/Fixtures/ErrorDocumentFormatter/Serialize_ErrorDocument.json"); - } - } -} diff --git a/JSONAPI.Tests/Json/ErrorFormatterTests.cs b/JSONAPI.Tests/Json/ErrorFormatterTests.cs deleted file mode 100644 index 9865d662..00000000 --- a/JSONAPI.Tests/Json/ErrorFormatterTests.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System.Net; -using System.Threading.Tasks; -using JSONAPI.Documents; -using JSONAPI.Json; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Tests.Json -{ - [TestClass] - public class ErrorFormatterTests : JsonApiFormatterTestsBase - { - [TestMethod] - public async Task Serialize_error_with_only_id() - { - var error = new Mock(); - error.Setup(e => e.Id).Returns("123456"); - - var formatter = new ErrorFormatter(null, null); - await AssertSerializeOutput(formatter, error.Object, "Json/Fixtures/ErrorFormatter/Serialize_error_with_only_id.json"); - } - - [TestMethod] - public async Task Serialize_error_with_all_possible_members() - { - var mockAboutLink = new Mock(MockBehavior.Strict); - mockAboutLink.Setup(l => l.Href).Returns("http://example.com/my-about-link"); - - var mockMetadata = new Mock(MockBehavior.Strict); - mockMetadata.Setup(m => m.MetaObject).Returns(() => - { - var obj = new JObject(); - obj["foo"] = "qux"; - return obj; - }); - - var error = new Mock(MockBehavior.Strict); - error.Setup(e => e.Id).Returns("654321"); - error.Setup(e => e.AboutLink).Returns(mockAboutLink.Object); - error.Setup(e => e.Status).Returns(HttpStatusCode.BadRequest); - error.Setup(e => e.Code).Returns("9000"); - error.Setup(e => e.Title).Returns("Some error occurred."); - error.Setup(e => e.Detail).Returns("The thingamabob fell through the whatsit."); - error.Setup(e => e.Pointer).Returns("/data/attributes/bob"); - error.Setup(e => e.Parameter).Returns("sort"); - error.Setup(e => e.Metadata).Returns(mockMetadata.Object); - - var mockLinkFormatter = new Mock(MockBehavior.Strict); - mockLinkFormatter.Setup(s => s.Serialize(mockAboutLink.Object, It.IsAny())) - .Returns((ILink link, JsonWriter writer) => - { - writer.WriteValue(link.Href); - return Task.FromResult(0); - }); - - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - mockMetadataFormatter.Setup(s => s.Serialize(mockMetadata.Object, It.IsAny())) - .Returns((IMetadata metadata, JsonWriter writer) => - { - metadata.MetaObject.WriteTo(writer); - return Task.FromResult(0); - }); - - var formatter = new ErrorFormatter(mockLinkFormatter.Object, mockMetadataFormatter.Object); - await AssertSerializeOutput(formatter, error.Object, "Json/Fixtures/ErrorFormatter/Serialize_error_with_all_possible_members.json"); - } - } -} diff --git a/JSONAPI.Tests/Json/Fixtures/ErrorDocumentFormatter/Serialize_ErrorDocument.json b/JSONAPI.Tests/Json/Fixtures/ErrorDocumentFormatter/Serialize_ErrorDocument.json deleted file mode 100644 index 7a47977f..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ErrorDocumentFormatter/Serialize_ErrorDocument.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "errors": [ "first error would go here", "second error would go here" ], - "meta": "metadata goes here" -} \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/ErrorFormatter/Serialize_error_with_all_possible_members.json b/JSONAPI.Tests/Json/Fixtures/ErrorFormatter/Serialize_error_with_all_possible_members.json deleted file mode 100644 index 375f2135..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ErrorFormatter/Serialize_error_with_all_possible_members.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "id": "654321", - "links": { - "about": "http://example.com/my-about-link" - }, - "status": "400", - "code": "9000", - "title": "Some error occurred.", - "detail": "The thingamabob fell through the whatsit.", - "source": { - "pointer": "/data/attributes/bob", - "parameter": "sort" - }, - "meta": { - "foo": "qux" - } -} \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/ErrorFormatter/Serialize_error_with_only_id.json b/JSONAPI.Tests/Json/Fixtures/ErrorFormatter/Serialize_error_with_only_id.json deleted file mode 100644 index 62caed7b..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ErrorFormatter/Serialize_error_with_only_id.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "id": "123456" -} \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/JsonApiFormatter/Serialize_ErrorDocument.json b/JSONAPI.Tests/Json/Fixtures/JsonApiFormatter/Serialize_ErrorDocument.json deleted file mode 100644 index 3253e614..00000000 --- a/JSONAPI.Tests/Json/Fixtures/JsonApiFormatter/Serialize_ErrorDocument.json +++ /dev/null @@ -1 +0,0 @@ -"ErrorDocument output goes here." \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/JsonApiFormatter/Serialize_HttpError.json b/JSONAPI.Tests/Json/Fixtures/JsonApiFormatter/Serialize_HttpError.json deleted file mode 100644 index 849578d6..00000000 --- a/JSONAPI.Tests/Json/Fixtures/JsonApiFormatter/Serialize_HttpError.json +++ /dev/null @@ -1 +0,0 @@ -"HttpError document" \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/JsonApiFormatter/Serialize_ResourceCollectionDocument.json b/JSONAPI.Tests/Json/Fixtures/JsonApiFormatter/Serialize_ResourceCollectionDocument.json deleted file mode 100644 index a6b86650..00000000 --- a/JSONAPI.Tests/Json/Fixtures/JsonApiFormatter/Serialize_ResourceCollectionDocument.json +++ /dev/null @@ -1 +0,0 @@ -"ResourceCollectionDocument output goes here." \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/JsonApiFormatter/Serialize_SingleResourceDocument.json b/JSONAPI.Tests/Json/Fixtures/JsonApiFormatter/Serialize_SingleResourceDocument.json deleted file mode 100644 index 5f1392e6..00000000 --- a/JSONAPI.Tests/Json/Fixtures/JsonApiFormatter/Serialize_SingleResourceDocument.json +++ /dev/null @@ -1 +0,0 @@ -"SingleResourceDocument output goes here." \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/JsonApiFormatter/Writes_error_for_anything_else.json b/JSONAPI.Tests/Json/Fixtures/JsonApiFormatter/Writes_error_for_anything_else.json deleted file mode 100644 index 8953b462..00000000 --- a/JSONAPI.Tests/Json/Fixtures/JsonApiFormatter/Writes_error_for_anything_else.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "title": "Unexpected Content", - "detail": "The JsonApiFormatter was asked to serialize an unsupported object.", - "meta": { - "objectTypeName": "Color" - } -} \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/LinkFormatter/Serialize_link_with_metadata.json b/JSONAPI.Tests/Json/Fixtures/LinkFormatter/Serialize_link_with_metadata.json deleted file mode 100644 index 8732417d..00000000 --- a/JSONAPI.Tests/Json/Fixtures/LinkFormatter/Serialize_link_with_metadata.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "href": "http://www.example.com", - "meta": "IMetadata placeholder 1" -} diff --git a/JSONAPI.Tests/Json/Fixtures/LinkFormatter/Serialize_link_without_metadata.json b/JSONAPI.Tests/Json/Fixtures/LinkFormatter/Serialize_link_without_metadata.json deleted file mode 100644 index dcd97f37..00000000 --- a/JSONAPI.Tests/Json/Fixtures/LinkFormatter/Serialize_link_without_metadata.json +++ /dev/null @@ -1 +0,0 @@ -"http://www.example.com" \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/MetadataFormatter/Deserialize_metadata.json b/JSONAPI.Tests/Json/Fixtures/MetadataFormatter/Deserialize_metadata.json deleted file mode 100644 index e25b53f1..00000000 --- a/JSONAPI.Tests/Json/Fixtures/MetadataFormatter/Deserialize_metadata.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "foo": 13, - "baz": { - "orange": "qux" - } -} \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/MetadataFormatter/Deserialize_null_metadata.json b/JSONAPI.Tests/Json/Fixtures/MetadataFormatter/Deserialize_null_metadata.json deleted file mode 100644 index c296c2ee..00000000 --- a/JSONAPI.Tests/Json/Fixtures/MetadataFormatter/Deserialize_null_metadata.json +++ /dev/null @@ -1 +0,0 @@ -null \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/MetadataFormatter/Serialize_metadata.json b/JSONAPI.Tests/Json/Fixtures/MetadataFormatter/Serialize_metadata.json deleted file mode 100644 index 2d017971..00000000 --- a/JSONAPI.Tests/Json/Fixtures/MetadataFormatter/Serialize_metadata.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "banana": { - "color": "yellow", - "foo": 3 - }, - "bar": "1776-07-04T00:00:00" -} diff --git a/JSONAPI.Tests/Json/Fixtures/MetadataFormatter/Serialize_null_metadata.json b/JSONAPI.Tests/Json/Fixtures/MetadataFormatter/Serialize_null_metadata.json deleted file mode 100644 index c296c2ee..00000000 --- a/JSONAPI.Tests/Json/Fixtures/MetadataFormatter/Serialize_null_metadata.json +++ /dev/null @@ -1 +0,0 @@ -null \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Deserialize_relationship_object.json b/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Deserialize_relationship_object.json deleted file mode 100644 index 64d48492..00000000 --- a/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Deserialize_relationship_object.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "data": "linkage goes here", - "meta": "metadata goes here" -} diff --git a/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_all_possible_members.json b/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_all_possible_members.json deleted file mode 100644 index df52b8c7..00000000 --- a/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_all_possible_members.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "links": { - "self": "some self link", - "related": "some related link" - }, - "data": "linkage goes here", - "meta": "metadata goes here" -} diff --git a/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_linkage_only.json b/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_linkage_only.json deleted file mode 100644 index 162a60d0..00000000 --- a/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_linkage_only.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "data": "linkage goes here" -} diff --git a/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_meta_only.json b/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_meta_only.json deleted file mode 100644 index ad2678c4..00000000 --- a/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_meta_only.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "meta": "IMetadata placeholder 1" -} diff --git a/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_related_link_only.json b/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_related_link_only.json deleted file mode 100644 index c3f2d720..00000000 --- a/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_related_link_only.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "links": { - "related": "some related link" - } -} diff --git a/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_self_link_and_related_link.json b/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_self_link_and_related_link.json deleted file mode 100644 index 45b3193f..00000000 --- a/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_self_link_and_related_link.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "links": { - "self": "some self link", - "related": "some related link" - } -} diff --git a/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_self_link_only.json b/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_self_link_only.json deleted file mode 100644 index e20248f6..00000000 --- a/JSONAPI.Tests/Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_self_link_only.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "links": { - "self": "some self link" - } -} diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Deserialize_document_with_metadata.json b/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Deserialize_document_with_metadata.json deleted file mode 100644 index bc14ed66..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Deserialize_document_with_metadata.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "meta": "metadata goes here" -} diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Deserialize_document_with_primary_data.json b/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Deserialize_document_with_primary_data.json deleted file mode 100644 index 14f2af6d..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Deserialize_document_with_primary_data.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "data": ["PD1", "PD2"] -} diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Deserialize_document_with_primary_data_and_unknown_top_level_key.json b/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Deserialize_document_with_primary_data_and_unknown_top_level_key.json deleted file mode 100644 index d3308a60..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Deserialize_document_with_primary_data_and_unknown_top_level_key.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "data": [ "PD1", "PD2" ], - "unknownTopLevelKey": { - "foo": "bar" - } -} diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Deserialize_empty_document.json b/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Deserialize_empty_document.json deleted file mode 100644 index 901cfebb..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Deserialize_empty_document.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "data": [ ] -} diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Serialize_ResourceCollectionDocument_for_all_possible_members.json b/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Serialize_ResourceCollectionDocument_for_all_possible_members.json deleted file mode 100644 index fad9ad33..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Serialize_ResourceCollectionDocument_for_all_possible_members.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "meta": "Placeholder metadata object", - "data": [ - "Primary data 1", - "Primary data 2" - ], - "included": [ - "Related data object 1", - "Related data object 2", - "Related data object 3" - ] -} \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Serialize_ResourceCollectionDocument_for_primary_data_only.json b/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Serialize_ResourceCollectionDocument_for_primary_data_only.json deleted file mode 100644 index 1a857170..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Serialize_ResourceCollectionDocument_for_primary_data_only.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "data": [ - "Primary data 1", - "Primary data 2" - ] -} \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Serialize_ResourceCollectionDocument_for_primary_data_only_and_metadata.json b/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Serialize_ResourceCollectionDocument_for_primary_data_only_and_metadata.json deleted file mode 100644 index 6d770373..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceCollectionDocumentFormatter/Serialize_ResourceCollectionDocument_for_primary_data_only_and_metadata.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "meta": "Placeholder metadata object", - "data": [ - "Primary data 1", - "Primary data 2" - ] -} \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Deserialize_fails_on_integer.json b/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Deserialize_fails_on_integer.json deleted file mode 100644 index 4825c991..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Deserialize_fails_on_integer.json +++ /dev/null @@ -1 +0,0 @@ -9 \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Deserialize_fails_on_string.json b/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Deserialize_fails_on_string.json deleted file mode 100644 index e191fdf7..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Deserialize_fails_on_string.json +++ /dev/null @@ -1 +0,0 @@ -"asdf" \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Deserialize_null_to_one_linkage.json b/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Deserialize_null_to_one_linkage.json deleted file mode 100644 index c296c2ee..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Deserialize_null_to_one_linkage.json +++ /dev/null @@ -1 +0,0 @@ -null \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Deserialize_to_many_linkage.json b/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Deserialize_to_many_linkage.json deleted file mode 100644 index a9f0e254..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Deserialize_to_many_linkage.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "type": "posts", - "id": "12" - }, - { - "type": "comments", - "id": "9510" - } -] diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Deserialize_to_one_linkage.json b/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Deserialize_to_one_linkage.json deleted file mode 100644 index cfdfa763..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Deserialize_to_one_linkage.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "type": "people", - "id": "abc123" -} \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Serialize_empty_toMany_linkage.json b/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Serialize_empty_toMany_linkage.json deleted file mode 100644 index ad47dbb9..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Serialize_empty_toMany_linkage.json +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Serialize_linkage.json b/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Serialize_linkage.json deleted file mode 100644 index 9c056cb8..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Serialize_linkage.json +++ /dev/null @@ -1 +0,0 @@ -"linkage goes here" \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Serialize_null_toOne_linkage.json b/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Serialize_null_toOne_linkage.json deleted file mode 100644 index c296c2ee..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Serialize_null_toOne_linkage.json +++ /dev/null @@ -1 +0,0 @@ -null \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Serialize_present_toMany_linkage.json b/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Serialize_present_toMany_linkage.json deleted file mode 100644 index 4872d17c..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Serialize_present_toMany_linkage.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "type": "countries", - "id": "11000" - }, - { - "type": "cities", - "id": "4100" - } -] diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Serialize_present_toOne_linkage.json b/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Serialize_present_toOne_linkage.json deleted file mode 100644 index fda81544..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceLinkageFormatter/Serialize_present_toOne_linkage.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "type": "countries", - "id": "11000" -} diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Deserialize_resource_object.json b/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Deserialize_resource_object.json deleted file mode 100644 index 05d00303..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Deserialize_resource_object.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "type": "posts", - "id": "123456", - "attributes": { - "title": "Another awesome post", - "likes": 43, - "some-complex-attribute": { - "qux": 5 - } - }, - "relationships": { - "author": "AUTHOR_RELATIONSHIP", - "comments": "COMMENTS_RELATIONSHIP" - }, - "meta": "metadata goes here" -} diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_null_resource.json b/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_null_resource.json deleted file mode 100644 index c296c2ee..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_null_resource.json +++ /dev/null @@ -1 +0,0 @@ -null \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_all_possible_members.json b/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_all_possible_members.json deleted file mode 100644 index d8cdb8fb..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_all_possible_members.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "type": "states", - "id": "1400", - "attributes": { - "name": "New York", - "population": 19746227, - "foo": null - }, - "relationships": { - "capital": "IRelationship Placeholder - capital", - "neighbors": "IRelationship Placeholder - neighbors" - }, - "links": { - "self": "ILink placeholder 1" - }, - "meta": "IMetadata placeholder 1" -} diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_attributes.json b/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_attributes.json deleted file mode 100644 index 5a340809..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_attributes.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "type": "shapes", - "id": "1400", - "attributes": { - "name": "Triangle", - "sides": 3, - "foo": null - } -} diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_links.json b/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_links.json deleted file mode 100644 index afc23a5f..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_links.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "type": "states", - "id": "1400", - "links": { - "self": "ILink placeholder 1" - } -} diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_metadata.json b/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_metadata.json deleted file mode 100644 index 3e4b60a2..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_metadata.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "states", - "id": "1400", - "meta": "IMetadata placeholder 1" -} diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_only_null_relationships.json b/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_only_null_relationships.json deleted file mode 100644 index 882c252c..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_only_null_relationships.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "type": "states", - "id": "1400" -} diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_relationships.json b/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_relationships.json deleted file mode 100644 index f81f9437..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_relationships.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "type": "states", - "id": "1400", - "relationships": { - "capital": "IRelationship Placeholder - capital", - "neighbors": "IRelationship Placeholder - neighbors" - } -} diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_unsigned_long_integer_greater_than_int64_maxvalue.json b/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_unsigned_long_integer_greater_than_int64_maxvalue.json deleted file mode 100644 index d80019b3..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_unsigned_long_integer_greater_than_int64_maxvalue.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "type": "samples", - "id": "2010", - "attributes": { - "uInt64Field": 9223372036854775808, - "nullableUInt64Field": 9223372036854775808 - } -} diff --git a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_without_attributes.json b/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_without_attributes.json deleted file mode 100644 index c5262609..00000000 --- a/JSONAPI.Tests/Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_without_attributes.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "type": "countries", - "id": "1100" -} diff --git a/JSONAPI.Tests/Json/Fixtures/SingleResourceDocumentFormatter/Deserialize_document_with_resource.json b/JSONAPI.Tests/Json/Fixtures/SingleResourceDocumentFormatter/Deserialize_document_with_resource.json deleted file mode 100644 index f71c9008..00000000 --- a/JSONAPI.Tests/Json/Fixtures/SingleResourceDocumentFormatter/Deserialize_document_with_resource.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "data": "primary data goes here" -} diff --git a/JSONAPI.Tests/Json/Fixtures/SingleResourceDocumentFormatter/Deserialize_null_document.json b/JSONAPI.Tests/Json/Fixtures/SingleResourceDocumentFormatter/Deserialize_null_document.json deleted file mode 100644 index 6de058ab..00000000 --- a/JSONAPI.Tests/Json/Fixtures/SingleResourceDocumentFormatter/Deserialize_null_document.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "data": null -} diff --git a/JSONAPI.Tests/Json/Fixtures/SingleResourceDocumentFormatter/Serialize_SingleResourceDocument_for_all_possible_members.json b/JSONAPI.Tests/Json/Fixtures/SingleResourceDocumentFormatter/Serialize_SingleResourceDocument_for_all_possible_members.json deleted file mode 100644 index b7b7d01d..00000000 --- a/JSONAPI.Tests/Json/Fixtures/SingleResourceDocumentFormatter/Serialize_SingleResourceDocument_for_all_possible_members.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "data": "Primary data object", - "included": [ - "Related data object 1", - "Related data object 2", - "Related data object 3" - ], - "meta": "Placeholder metadata object" -} \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/SingleResourceDocumentFormatter/Serialize_SingleResourceDocument_for_primary_data_and_metadata.json b/JSONAPI.Tests/Json/Fixtures/SingleResourceDocumentFormatter/Serialize_SingleResourceDocument_for_primary_data_and_metadata.json deleted file mode 100644 index 0cb3c38d..00000000 --- a/JSONAPI.Tests/Json/Fixtures/SingleResourceDocumentFormatter/Serialize_SingleResourceDocument_for_primary_data_and_metadata.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "data": "Placeholder resource object", - "meta": "Placeholder metadata object" -} \ No newline at end of file diff --git a/JSONAPI.Tests/Json/Fixtures/SingleResourceDocumentFormatter/Serialize_SingleResourceDocument_for_primary_data_only.json b/JSONAPI.Tests/Json/Fixtures/SingleResourceDocumentFormatter/Serialize_SingleResourceDocument_for_primary_data_only.json deleted file mode 100644 index d35a386b..00000000 --- a/JSONAPI.Tests/Json/Fixtures/SingleResourceDocumentFormatter/Serialize_SingleResourceDocument_for_primary_data_only.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "data": "Placeholder resource object" -} \ No newline at end of file diff --git a/JSONAPI.Tests/Json/JsonApiFormatterTests.cs b/JSONAPI.Tests/Json/JsonApiFormatterTests.cs deleted file mode 100644 index 9e5008f8..00000000 --- a/JSONAPI.Tests/Json/JsonApiFormatterTests.cs +++ /dev/null @@ -1,189 +0,0 @@ -using System; -using System.Threading.Tasks; -using System.Web.Http; -using FluentAssertions; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Newtonsoft.Json; -using JSONAPI.Json; -using System.IO; -using System.Net; -using JSONAPI.Documents; -using JSONAPI.Documents.Builders; -using Moq; - -namespace JSONAPI.Tests.Json -{ - [TestClass] - public class JsonApiFormatterTests - { - private JsonApiFormatter BuildFormatter(ISingleResourceDocumentFormatter singleResourceDocumentFormatter = null, - IResourceCollectionDocumentFormatter resourceCollectionDocumentFormatter = null, - IErrorDocumentFormatter errorDocumentFormatter = null, - IErrorDocumentBuilder errorDocumentBuilder = null) - { - - singleResourceDocumentFormatter = singleResourceDocumentFormatter ?? new Mock(MockBehavior.Strict).Object; - resourceCollectionDocumentFormatter = resourceCollectionDocumentFormatter ?? new Mock(MockBehavior.Strict).Object; - errorDocumentFormatter = errorDocumentFormatter ?? new Mock(MockBehavior.Strict).Object; - errorDocumentBuilder = errorDocumentBuilder ?? new ErrorDocumentBuilder(); - return new JsonApiFormatter(singleResourceDocumentFormatter, resourceCollectionDocumentFormatter, errorDocumentFormatter, errorDocumentBuilder); - } - - [TestMethod] - public void Serialize_SingleResourceDocument() - { - // Arrange - var mockSingleResourceDocument = new Mock(MockBehavior.Strict); - var singleResourceDocumentFormatter = new Mock(MockBehavior.Strict); - singleResourceDocumentFormatter.Setup(s => s.Serialize(mockSingleResourceDocument.Object, It.IsAny())) - .Returns((ISingleResourceDocument p, JsonWriter writer) => - { - writer.WriteValue("SingleResourceDocument output goes here."); - return Task.FromResult(0); - }); - - var formatter = BuildFormatter(singleResourceDocumentFormatter.Object); - var stream = new MemoryStream(); - - // Act - formatter.WriteToStreamAsync(mockSingleResourceDocument.Object.GetType(), mockSingleResourceDocument.Object, stream, null, null).Wait(); - - // Assert - TestHelpers.StreamContentsMatchFixtureContents(stream, "Json/Fixtures/JsonApiFormatter/Serialize_SingleResourceDocument.json"); - } - - [TestMethod] - public void Serialize_ResourceCollectionDocument() - { - // Arrange - var mockResourceCollectionDocument = new Mock(MockBehavior.Strict); - var resourceCollectionDocumentFormatter = new Mock(MockBehavior.Strict); - resourceCollectionDocumentFormatter.Setup(s => s.Serialize(mockResourceCollectionDocument.Object, It.IsAny())) - .Returns((IResourceCollectionDocument p, JsonWriter writer) => - { - writer.WriteValue("ResourceCollectionDocument output goes here."); - return Task.FromResult(0); - }); - - var formatter = BuildFormatter(resourceCollectionDocumentFormatter: resourceCollectionDocumentFormatter.Object); - var stream = new MemoryStream(); - - // Act - formatter.WriteToStreamAsync(mockResourceCollectionDocument.Object.GetType(), mockResourceCollectionDocument.Object, stream, null, null).Wait(); - - // Assert - TestHelpers.StreamContentsMatchFixtureContents(stream, "Json/Fixtures/JsonApiFormatter/Serialize_ResourceCollectionDocument.json"); - } - - [TestMethod] - public void Serialize_ErrorDocument() - { - // Arrange - var errorDocument = new Mock(MockBehavior.Strict); - var errorDocumentFormatter = new Mock(MockBehavior.Strict); - errorDocumentFormatter.Setup(s => s.Serialize(errorDocument.Object, It.IsAny())) - .Returns((IErrorDocument p, JsonWriter writer) => - { - writer.WriteValue("ErrorDocument output goes here."); - return Task.FromResult(0); - }); - - var formatter = BuildFormatter(errorDocumentFormatter: errorDocumentFormatter.Object); - var stream = new MemoryStream(); - - // Act - formatter.WriteToStreamAsync(errorDocument.Object.GetType(), errorDocument.Object, stream, null, null).Wait(); - - // Assert - TestHelpers.StreamContentsMatchFixtureContents(stream, "Json/Fixtures/JsonApiFormatter/Serialize_ErrorDocument.json"); - } - - [TestMethod] - public void Serialize_HttpError() - { - // Arrange - var httpError = new HttpError(new Exception("This is the exception message"), true); - var mockErrorDocumentBuilder = new Mock(MockBehavior.Strict); - var mockErrorDocument = new Mock(MockBehavior.Strict); - mockErrorDocumentBuilder.Setup(b => b.BuildFromHttpError(httpError, HttpStatusCode.InternalServerError)) - .Returns(mockErrorDocument.Object); - - var mockErrorDocumentFormatter = new Mock(MockBehavior.Strict); - mockErrorDocumentFormatter.Setup(s => s.Serialize(mockErrorDocument.Object, It.IsAny())) - .Returns((IErrorDocument errorDocument, JsonWriter writer) => - { - writer.WriteValue("HttpError document"); - return Task.FromResult(0); - }); - - var stream = new MemoryStream(); - - // Act - var formatter = BuildFormatter(errorDocumentBuilder: mockErrorDocumentBuilder.Object, errorDocumentFormatter: mockErrorDocumentFormatter.Object); - formatter.WriteToStreamAsync(httpError.GetType(), httpError, stream, null, null).Wait(); - - // Assert - TestHelpers.StreamContentsMatchFixtureContents(stream, "Json/Fixtures/JsonApiFormatter/Serialize_HttpError.json"); - } - - private class Color - { - public string Id { get; set; } - - public string Name { get; set; } - } - - [TestMethod] - public void Writes_error_for_anything_else() - { - // Arrange - var formatter = BuildFormatter(); - var stream = new MemoryStream(); - - // Act - var resource = new Color { Id = "1", Name = "Blue" }; - formatter.WriteToStreamAsync(resource.GetType(), resource, stream, null, null).Wait(); - - // Assert - TestHelpers.StreamContentsMatchFixtureContents(stream, "Json/Fixtures/JsonApiFormatter/Writes_error_for_anything_else.json"); - } - - [TestMethod] - public void ReadFromStreamAsync_deserializes_ISingleResourceDocument() - { - // Arrange - var mockSingleResourceDocument = new Mock(MockBehavior.Strict); - var singleResourceDocumentFormatter = new Mock(MockBehavior.Strict); - singleResourceDocumentFormatter.Setup(s => s.Deserialize(It.IsAny(), "")) - .Returns(Task.FromResult(mockSingleResourceDocument.Object)); - - var formatter = BuildFormatter(singleResourceDocumentFormatter.Object); - var stream = new MemoryStream(); - - // Act - var deserialized = formatter.ReadFromStreamAsync(typeof(ISingleResourceDocument), stream, null, null).Result; - - // Assert - deserialized.Should().BeSameAs(mockSingleResourceDocument.Object); - } - - [TestMethod] - public void ReadFromStreamAsync_deserializes_IResourceCollectionDocument() - { - // Arrange - var mockResourceCollectionDocument = new Mock(MockBehavior.Strict); - var resourceCollectionDocumentFormatter = new Mock(MockBehavior.Strict); - resourceCollectionDocumentFormatter.Setup(s => s.Deserialize(It.IsAny(), "")) - .Returns(Task.FromResult(mockResourceCollectionDocument.Object)); - - var formatter = BuildFormatter(resourceCollectionDocumentFormatter: resourceCollectionDocumentFormatter.Object); - var stream = new MemoryStream(); - - // Act - var deserialized = formatter.ReadFromStreamAsync(typeof(IResourceCollectionDocument), stream, null, null).Result; - - // Assert - deserialized.Should().BeSameAs(mockResourceCollectionDocument.Object); - } - } -} diff --git a/JSONAPI.Tests/Json/JsonApiFormatterTestsBase.cs b/JSONAPI.Tests/Json/JsonApiFormatterTestsBase.cs deleted file mode 100644 index c4e60065..00000000 --- a/JSONAPI.Tests/Json/JsonApiFormatterTestsBase.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.IO; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using FluentAssertions; -using JSONAPI.Json; -using Newtonsoft.Json; - -namespace JSONAPI.Tests.Json -{ - public abstract class JsonApiFormatterTestsBase - { - protected async Task AssertSerializeOutput(TFormatter formatter, TComponent component, string expectedJsonFile) - where TFormatter : IJsonApiFormatter - { - var output = await GetSerializedString(formatter, component); - - // Assert - var expectedJson = TestHelpers.ReadEmbeddedFile(expectedJsonFile); - var minifiedExpectedJson = JsonHelpers.MinifyJson(expectedJson); - output.Should().Be(minifiedExpectedJson); - } - - protected async Task GetSerializedString(TFormatter formatter, TComponent component) - where TFormatter : IJsonApiFormatter - { - using (var stream = new MemoryStream()) - { - using (var textWriter = new StreamWriter(stream)) - { - using (var writer = new JsonTextWriter(textWriter)) - { - await formatter.Serialize(component, writer); - writer.Flush(); - return Encoding.ASCII.GetString(stream.ToArray()); - } - } - } - } - - protected async Task GetDeserializedOutput(TFormatter formatter, string requestFileName) - where TFormatter : IJsonApiFormatter - { - var resourcePath = "JSONAPI.Tests." + requestFileName.Replace("\\", ".").Replace("/", "."); - using (var resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourcePath)) - { - // ReSharper disable once AssignNullToNotNullAttribute - using (var textReader = new StreamReader(resourceStream)) - { - using (var reader = new JsonTextReader(textReader)) - { - reader.Read(); - var deserialized = await formatter.Deserialize(reader, ""); - reader.Read().Should().BeFalse(); // There should be nothing left to read. - return deserialized; - } - } - } - } - } -} diff --git a/JSONAPI.Tests/Json/LinkFormatterTests.cs b/JSONAPI.Tests/Json/LinkFormatterTests.cs deleted file mode 100644 index 3c871686..00000000 --- a/JSONAPI.Tests/Json/LinkFormatterTests.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Threading.Tasks; -using JSONAPI.Documents; -using JSONAPI.Json; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using Newtonsoft.Json; - -namespace JSONAPI.Tests.Json -{ - [TestClass] - public class LinkFormatterTests : JsonApiFormatterTestsBase - { - [TestMethod] - public async Task Serialize_link_without_metadata() - { - ILink link = new Link("http://www.example.com", null); - - var formatter = new LinkFormatter(null); - await AssertSerializeOutput(formatter, link, "Json/Fixtures/LinkFormatter/Serialize_link_without_metadata.json"); - } - - [TestMethod] - public async Task Serialize_link_with_metadata() - { - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - mockMetadataFormatter.Setup(m => m.Serialize(It.IsAny(), It.IsAny())) - .Returns((IMetadata metadata, JsonWriter writer) => - { - writer.WriteValue("IMetadata placeholder 1"); - return Task.FromResult(0); - }).Verifiable(); - - var mockMetadata = new Mock(MockBehavior.Strict); - ILink link = new Link("http://www.example.com", mockMetadata.Object); - - var formatter = new LinkFormatter(mockMetadataFormatter.Object); - await AssertSerializeOutput(formatter, link, "Json/Fixtures/LinkFormatter/Serialize_link_with_metadata.json"); - mockMetadataFormatter.Verify(s => s.Serialize(mockMetadata.Object, It.IsAny()), Times.Once); - } - } -} diff --git a/JSONAPI.Tests/Json/MetadataFormatterTests.cs b/JSONAPI.Tests/Json/MetadataFormatterTests.cs deleted file mode 100644 index 4d925451..00000000 --- a/JSONAPI.Tests/Json/MetadataFormatterTests.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Threading.Tasks; -using FluentAssertions; -using JSONAPI.Documents; -using JSONAPI.Json; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Tests.Json -{ - [TestClass] - public class MetadataFormatterTests : JsonApiFormatterTestsBase - { - [TestMethod] - public async Task Serialize_null_metadata() - { - var formatter = new MetadataFormatter(); - await AssertSerializeOutput(formatter, (IMetadata)null, "Json/Fixtures/MetadataFormatter/Serialize_null_metadata.json"); - } - - [TestMethod] - public async Task Serialize_metadata() - { - var mockMetadata = new Mock(MockBehavior.Strict); - mockMetadata.Setup(m => m.MetaObject) - .Returns(() => - { - var subObject = new JObject(); - subObject["color"] = "yellow"; - subObject["foo"] = 3; - - var obj = new JObject(); - obj["banana"] = subObject; - obj["bar"] = new DateTime(1776, 07, 04); - return obj; - }); - - var formatter = new MetadataFormatter(); - await AssertSerializeOutput(formatter, mockMetadata.Object, "Json/Fixtures/MetadataFormatter/Serialize_metadata.json"); - } - - [TestMethod] - public void Serialize_metadata_should_fail_if_object_is_null() - { - var mockMetadata = new Mock(MockBehavior.Strict); - mockMetadata.Setup(m => m.MetaObject) - .Returns(() => null); - - var formatter = new MetadataFormatter(); - - Func action = async () => - { - await - GetSerializedString(formatter, mockMetadata.Object); - }; - action.ShouldThrow() - .WithMessage("The meta object cannot be null."); - } - - [TestMethod] - public void Deserialize_null_metadata() - { - // Arrange - - // Act - var formatter = new MetadataFormatter(); - var metadata = - GetDeserializedOutput(formatter, - "Json/Fixtures/MetadataFormatter/Deserialize_null_metadata.json").Result; - - // Assert - metadata.Should().BeNull(); - } - - [TestMethod] - public void Deserialize_metadata() - { - // Arrange - - // Act - var formatter = new MetadataFormatter(); - var metadata = - GetDeserializedOutput(formatter, - "Json/Fixtures/MetadataFormatter/Deserialize_metadata.json").Result; - - // Assert - ((int) metadata.MetaObject["foo"]).Should().Be(13); - var baz = (JObject) metadata.MetaObject["baz"]; - ((string) baz["orange"]).Should().Be("qux"); - } - } -} diff --git a/JSONAPI.Tests/Json/RelationshipObjectFormatterTests.cs b/JSONAPI.Tests/Json/RelationshipObjectFormatterTests.cs deleted file mode 100644 index b5d687ff..00000000 --- a/JSONAPI.Tests/Json/RelationshipObjectFormatterTests.cs +++ /dev/null @@ -1,230 +0,0 @@ -using System; -using System.Threading.Tasks; -using FluentAssertions; -using JSONAPI.Documents; -using JSONAPI.Json; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using Newtonsoft.Json; - -namespace JSONAPI.Tests.Json -{ - [TestClass] - public class RelationshipObjectFormatterTests : JsonApiFormatterTestsBase - { - [TestMethod] - public void Serialize_relationship_with_no_required_fields() - { - var formatter = new RelationshipObjectFormatter(null, null, null); - IRelationshipObject relationshipObject = new RelationshipObject(null, null, null); - - Func action = async () => - { - await - GetSerializedString(formatter, relationshipObject); - }; - action.ShouldThrow() - .WithMessage("At least one of `links`, `data`, or `meta` must be present in a relationship object."); - } - - [TestMethod] - public async Task Serialize_relationship_with_self_link_only() - { - var mockSelfLink = new Mock(MockBehavior.Strict); - - var mockLinkFormatter = new Mock(MockBehavior.Strict); - mockLinkFormatter - .Setup(s => s.Serialize(mockSelfLink.Object, It.IsAny())) - .Returns((ILink metadata, JsonWriter writer) => - { - writer.WriteValue("some self link"); - return Task.FromResult(0); - }).Verifiable(); - - var formatter = new RelationshipObjectFormatter(mockLinkFormatter.Object, null, null); - IRelationshipObject resourceObject = new RelationshipObject(mockSelfLink.Object, null); - - await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_self_link_only.json"); - mockLinkFormatter.Verify(s => s.Serialize(mockSelfLink.Object, It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task Serialize_relationship_with_related_link_only() - { - var mockRelatedLink = new Mock(MockBehavior.Strict); - - var mockLinkFormatter = new Mock(MockBehavior.Strict); - mockLinkFormatter - .Setup(s => s.Serialize(mockRelatedLink.Object, It.IsAny())) - .Returns((ILink metadata, JsonWriter writer) => - { - writer.WriteValue("some related link"); - return Task.FromResult(0); - }).Verifiable(); - - var formatter = new RelationshipObjectFormatter(mockLinkFormatter.Object, null, null); - IRelationshipObject resourceObject = new RelationshipObject(null, mockRelatedLink.Object); - - await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_related_link_only.json"); - mockLinkFormatter.Verify(s => s.Serialize(mockRelatedLink.Object, It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task Serialize_relationship_with_self_link_and_related_link() - { - var mockSelfLink = new Mock(MockBehavior.Strict); - var mockRelatedLink = new Mock(MockBehavior.Strict); - - var mockLinkFormatter = new Mock(MockBehavior.Strict); - mockLinkFormatter - .Setup(s => s.Serialize(mockSelfLink.Object, It.IsAny())) - .Returns((ILink metadata, JsonWriter writer) => - { - writer.WriteValue("some self link"); - return Task.FromResult(0); - }).Verifiable(); - mockLinkFormatter - .Setup(s => s.Serialize(mockRelatedLink.Object, It.IsAny())) - .Returns((ILink metadata, JsonWriter writer) => - { - writer.WriteValue("some related link"); - return Task.FromResult(0); - }).Verifiable(); - - var formatter = new RelationshipObjectFormatter(mockLinkFormatter.Object, null, null); - IRelationshipObject resourceObject = new RelationshipObject(mockSelfLink.Object, mockRelatedLink.Object); - - await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_self_link_and_related_link.json"); - mockLinkFormatter.Verify(s => s.Serialize(mockSelfLink.Object, It.IsAny()), Times.Once); - mockLinkFormatter.Verify(s => s.Serialize(mockRelatedLink.Object, It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task Serialize_relationship_with_linkage_only() - { - var mockLinkage = new Mock(MockBehavior.Strict); - var mockLinkageFormatter = new Mock(MockBehavior.Strict); - mockLinkageFormatter - .Setup(s => s.Serialize(mockLinkage.Object, It.IsAny())) - .Returns((IResourceLinkage metadata, JsonWriter writer) => - { - writer.WriteValue("linkage goes here"); - return Task.FromResult(0); - }).Verifiable(); - - var formatter = new RelationshipObjectFormatter(null, mockLinkageFormatter.Object, null); - IRelationshipObject resourceObject = new RelationshipObject(mockLinkage.Object); - - await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_linkage_only.json"); - mockLinkageFormatter.Verify(s => s.Serialize(mockLinkage.Object, It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task Serialize_relationship_with_meta_only() - { - var mockMetadata = new Mock(MockBehavior.Strict); - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - mockMetadataFormatter - .Setup(s => s.Serialize(mockMetadata.Object, It.IsAny())) - .Returns((IMetadata metadata, JsonWriter writer) => - { - writer.WriteValue("IMetadata placeholder 1"); - return Task.FromResult(0); - }).Verifiable(); - - var formatter = new RelationshipObjectFormatter(null, null, mockMetadataFormatter.Object); - IRelationshipObject resourceObject = new RelationshipObject(null, null, mockMetadata.Object); - - await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_meta_only.json"); - mockMetadataFormatter.Verify(s => s.Serialize(mockMetadata.Object, It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task Serialize_relationship_with_all_possible_members() - { - var mockSelfLink = new Mock(MockBehavior.Strict); - var mockRelatedLink = new Mock(MockBehavior.Strict); - - var mockLinkFormatter = new Mock(MockBehavior.Strict); - mockLinkFormatter - .Setup(s => s.Serialize(mockSelfLink.Object, It.IsAny())) - .Returns((ILink metadata, JsonWriter writer) => - { - writer.WriteValue("some self link"); - return Task.FromResult(0); - }).Verifiable(); - mockLinkFormatter - .Setup(s => s.Serialize(mockRelatedLink.Object, It.IsAny())) - .Returns((ILink metadata, JsonWriter writer) => - { - writer.WriteValue("some related link"); - return Task.FromResult(0); - }).Verifiable(); - - var mockLinkage = new Mock(MockBehavior.Strict); - var mockLinkageFormatter = new Mock(MockBehavior.Strict); - mockLinkageFormatter - .Setup(s => s.Serialize(mockLinkage.Object, It.IsAny())) - .Returns((IResourceLinkage metadata, JsonWriter writer) => - { - writer.WriteValue("linkage goes here"); - return Task.FromResult(0); - }).Verifiable(); - - var mockMetadata = new Mock(MockBehavior.Strict); - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - mockMetadataFormatter - .Setup(s => s.Serialize(mockMetadata.Object, It.IsAny())) - .Returns((IMetadata metadata, JsonWriter writer) => - { - writer.WriteValue("metadata goes here"); - return Task.FromResult(0); - }).Verifiable(); - - var formatter = new RelationshipObjectFormatter(mockLinkFormatter.Object, mockLinkageFormatter.Object, mockMetadataFormatter.Object); - IRelationshipObject resourceObject = new RelationshipObject(mockLinkage.Object, mockSelfLink.Object, mockRelatedLink.Object, mockMetadata.Object); - - await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/RelationshipObjectFormatter/Serialize_relationship_with_all_possible_members.json"); - mockLinkFormatter.Verify(s => s.Serialize(mockSelfLink.Object, It.IsAny()), Times.Once); - mockLinkFormatter.Verify(s => s.Serialize(mockRelatedLink.Object, It.IsAny()), Times.Once); - mockLinkageFormatter.Verify(s => s.Serialize(mockLinkage.Object, It.IsAny()), Times.Once); - mockMetadataFormatter.Verify(s => s.Serialize(mockMetadata.Object, It.IsAny()), Times.Once); - } - - [TestMethod] - public void Deserialize_relationship_object() - { - // Arrange - var mockLinkage = new Mock(MockBehavior.Strict); - var mockMetadata = new Mock(MockBehavior.Strict); - - var mockLinkageFormatter = new Mock(MockBehavior.Strict); - mockLinkageFormatter.Setup(s => s.Deserialize(It.IsAny(), "/data")) - .Returns((JsonReader reader, string currentPath) => - { - reader.TokenType.Should().Be(JsonToken.String); - reader.Value.Should().Be("linkage goes here"); - return Task.FromResult(mockLinkage.Object); - }); - - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - mockMetadataFormatter.Setup(s => s.Deserialize(It.IsAny(), "/meta")) - .Returns((JsonReader reader, string currentPath) => - { - reader.TokenType.Should().Be(JsonToken.String); - reader.Value.Should().Be("metadata goes here"); - return Task.FromResult(mockMetadata.Object); - }); - - // Act - var formatter = new RelationshipObjectFormatter(null, mockLinkageFormatter.Object, mockMetadataFormatter.Object); - var relationshipObject = - GetDeserializedOutput(formatter, - "Json/Fixtures/RelationshipObjectFormatter/Deserialize_relationship_object.json").Result; - - // Assert - relationshipObject.Linkage.Should().BeSameAs(mockLinkage.Object); - relationshipObject.Metadata.Should().BeSameAs(mockMetadata.Object); - } - } -} diff --git a/JSONAPI.Tests/Json/ResourceCollectionDocumentFormatterTests.cs b/JSONAPI.Tests/Json/ResourceCollectionDocumentFormatterTests.cs deleted file mode 100644 index 212d4957..00000000 --- a/JSONAPI.Tests/Json/ResourceCollectionDocumentFormatterTests.cs +++ /dev/null @@ -1,252 +0,0 @@ -using System.Threading.Tasks; -using FluentAssertions; -using JSONAPI.Documents; -using JSONAPI.Json; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using Newtonsoft.Json; - -namespace JSONAPI.Tests.Json -{ - [TestClass] - public class ResourceCollectionDocumentFormatterTests : JsonApiFormatterTestsBase - { - [TestMethod] - public async Task Serialize_ResourceCollectionDocument_for_primary_data_only() - { - var primaryData1 = new Mock(MockBehavior.Strict); - var primaryData2 = new Mock(MockBehavior.Strict); - var mockResourceObjectFormatter = new Mock(MockBehavior.Strict); - mockResourceObjectFormatter.Setup(m => m.Serialize(primaryData1.Object, It.IsAny())) - .Returns((IResourceObject resourceObject, JsonWriter writer) => - { - writer.WriteValue("Primary data 1"); - return Task.FromResult(0); - }); - mockResourceObjectFormatter.Setup(m => m.Serialize(primaryData2.Object, It.IsAny())) - .Returns((IResourceObject resourceObject, JsonWriter writer) => - { - writer.WriteValue("Primary data 2"); - return Task.FromResult(0); - }); - - var primaryData = new[] { primaryData1.Object, primaryData2.Object }; - IResourceCollectionDocument document = new ResourceCollectionDocument(primaryData, null, null); - - var formatter = new ResourceCollectionDocumentFormatter(mockResourceObjectFormatter.Object, null); - await AssertSerializeOutput(formatter, document, "Json/Fixtures/ResourceCollectionDocumentFormatter/Serialize_ResourceCollectionDocument_for_primary_data_only.json"); - } - - [TestMethod] - public async Task Serialize_ResourceCollectionDocument_for_primary_data_only_and_metadata() - { - var primaryData1 = new Mock(MockBehavior.Strict); - var primaryData2 = new Mock(MockBehavior.Strict); - var mockResourceObjectFormatter = new Mock(MockBehavior.Strict); - mockResourceObjectFormatter.Setup(m => m.Serialize(primaryData1.Object, It.IsAny())) - .Returns((IResourceObject resourceObject, JsonWriter writer) => - { - writer.WriteValue("Primary data 1"); - return Task.FromResult(0); - }); - mockResourceObjectFormatter.Setup(m => m.Serialize(primaryData2.Object, It.IsAny())) - .Returns((IResourceObject resourceObject, JsonWriter writer) => - { - writer.WriteValue("Primary data 2"); - return Task.FromResult(0); - }); - - var mockMetadata = new Mock(MockBehavior.Strict); - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - mockMetadataFormatter.Setup(m => m.Serialize(mockMetadata.Object, It.IsAny())) - .Returns((IMetadata resourceObject, JsonWriter writer) => - { - writer.WriteValue("Placeholder metadata object"); - return Task.FromResult(0); - }); - - var primaryData = new[] { primaryData1.Object, primaryData2.Object }; - IResourceCollectionDocument document = new ResourceCollectionDocument(primaryData, null, mockMetadata.Object); - - var formatter = new ResourceCollectionDocumentFormatter(mockResourceObjectFormatter.Object, mockMetadataFormatter.Object); - await AssertSerializeOutput(formatter, document, "Json/Fixtures/ResourceCollectionDocumentFormatter/Serialize_ResourceCollectionDocument_for_primary_data_only_and_metadata.json"); - } - - [TestMethod] - public async Task Serialize_ResourceCollectionDocument_for_all_possible_members() - { - var primaryData1 = new Mock(MockBehavior.Strict); - var primaryData2 = new Mock(MockBehavior.Strict); - var relatedResource1 = new Mock(MockBehavior.Strict); - var relatedResource2 = new Mock(MockBehavior.Strict); - var relatedResource3 = new Mock(MockBehavior.Strict); - - var mockResourceObjectFormatter = new Mock(MockBehavior.Strict); - mockResourceObjectFormatter.Setup(m => m.Serialize(primaryData1.Object, It.IsAny())) - .Returns((IResourceObject resourceObject, JsonWriter writer) => - { - writer.WriteValue("Primary data 1"); - return Task.FromResult(0); - }); - mockResourceObjectFormatter.Setup(m => m.Serialize(primaryData2.Object, It.IsAny())) - .Returns((IResourceObject resourceObject, JsonWriter writer) => - { - writer.WriteValue("Primary data 2"); - return Task.FromResult(0); - }); - mockResourceObjectFormatter.Setup(m => m.Serialize(relatedResource1.Object, It.IsAny())) - .Returns((IResourceObject resourceObject, JsonWriter writer) => - { - writer.WriteValue("Related data object 1"); - return Task.FromResult(0); - }); - mockResourceObjectFormatter.Setup(m => m.Serialize(relatedResource2.Object, It.IsAny())) - .Returns((IResourceObject resourceObject, JsonWriter writer) => - { - writer.WriteValue("Related data object 2"); - return Task.FromResult(0); - }); - mockResourceObjectFormatter.Setup(m => m.Serialize(relatedResource3.Object, It.IsAny())) - .Returns((IResourceObject resourceObject, JsonWriter writer) => - { - writer.WriteValue("Related data object 3"); - return Task.FromResult(0); - }); - - var mockMetadata = new Mock(MockBehavior.Strict); - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - mockMetadataFormatter.Setup(m => m.Serialize(mockMetadata.Object, It.IsAny())) - .Returns((IMetadata resourceObject, JsonWriter writer) => - { - writer.WriteValue("Placeholder metadata object"); - return Task.FromResult(0); - }); - - var primaryData = new[] { primaryData1.Object, primaryData2.Object }; - var relatedResources = new[] { relatedResource1.Object, relatedResource2.Object, relatedResource3.Object }; - IResourceCollectionDocument document = new ResourceCollectionDocument(primaryData, relatedResources, mockMetadata.Object); - - var formatter = new ResourceCollectionDocumentFormatter(mockResourceObjectFormatter.Object, mockMetadataFormatter.Object); - await AssertSerializeOutput(formatter, document, "Json/Fixtures/ResourceCollectionDocumentFormatter/Serialize_ResourceCollectionDocument_for_all_possible_members.json"); - } - - [TestMethod] - public void Deserialize_empty_document() - { - // Arrange - var mockResourceObjectFormatter = new Mock(MockBehavior.Strict); - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - - // Act - var formatter = new ResourceCollectionDocumentFormatter(mockResourceObjectFormatter.Object, mockMetadataFormatter.Object); - var document = - GetDeserializedOutput(formatter, - "Json/Fixtures/ResourceCollectionDocumentFormatter/Deserialize_empty_document.json").Result; - - // Assert - document.PrimaryData.Should().BeEquivalentTo(); - document.RelatedData.Should().BeEquivalentTo(); - document.Metadata.Should().BeNull(); - } - - [TestMethod] - public void Deserialize_document_with_primary_data() - { - // Arrange - var mockResource1 = new Mock(MockBehavior.Strict); - var mockResource2 = new Mock(MockBehavior.Strict); - - var mockResourceObjectFormatter = new Mock(MockBehavior.Strict); - mockResourceObjectFormatter.Setup(s => s.Deserialize(It.IsAny(), "/data/0")) - .Returns((JsonReader reader, string currentPath) => - { - reader.TokenType.Should().Be(JsonToken.String); - reader.Value.Should().Be("PD1"); - return Task.FromResult(mockResource1.Object); - }); - mockResourceObjectFormatter.Setup(s => s.Deserialize(It.IsAny(), "/data/1")) - .Returns((JsonReader reader, string currentPath) => - { - reader.TokenType.Should().Be(JsonToken.String); - reader.Value.Should().Be("PD2"); - return Task.FromResult(mockResource2.Object); - }); - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - - // Act - var formatter = new ResourceCollectionDocumentFormatter(mockResourceObjectFormatter.Object, mockMetadataFormatter.Object); - var document = - GetDeserializedOutput(formatter, - "Json/Fixtures/ResourceCollectionDocumentFormatter/Deserialize_document_with_primary_data.json").Result; - - // Assert - document.PrimaryData.Should().BeEquivalentTo(mockResource1.Object, mockResource2.Object); - document.RelatedData.Should().BeEquivalentTo(); - document.Metadata.Should().BeNull(); - } - - [TestMethod] - public void Deserialize_document_with_primary_data_and_unknown_top_level_key() - { - // Arrange - var mockResource1 = new Mock(MockBehavior.Strict); - var mockResource2 = new Mock(MockBehavior.Strict); - - var mockResourceObjectFormatter = new Mock(MockBehavior.Strict); - mockResourceObjectFormatter.Setup(s => s.Deserialize(It.IsAny(), "/data/0")) - .Returns((JsonReader reader, string currentPath) => - { - reader.TokenType.Should().Be(JsonToken.String); - reader.Value.Should().Be("PD1"); - return Task.FromResult(mockResource1.Object); - }); - mockResourceObjectFormatter.Setup(s => s.Deserialize(It.IsAny(), "/data/1")) - .Returns((JsonReader reader, string currentPath) => - { - reader.TokenType.Should().Be(JsonToken.String); - reader.Value.Should().Be("PD2"); - return Task.FromResult(mockResource2.Object); - }); - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - - // Act - var formatter = new ResourceCollectionDocumentFormatter(mockResourceObjectFormatter.Object, mockMetadataFormatter.Object); - var document = - GetDeserializedOutput(formatter, - "Json/Fixtures/ResourceCollectionDocumentFormatter/Deserialize_document_with_primary_data_and_unknown_top_level_key.json").Result; - - // Assert - document.PrimaryData.Should().BeEquivalentTo(mockResource1.Object, mockResource2.Object); - document.RelatedData.Should().BeEquivalentTo(); - document.Metadata.Should().BeNull(); - } - - [TestMethod] - public void Deserialize_document_with_metadata() - { - // Arrange - var mockMetadata = new Mock(MockBehavior.Strict); - - var mockResourceObjectFormatter = new Mock(MockBehavior.Strict); - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - mockMetadataFormatter.Setup(s => s.Deserialize(It.IsAny(), "/meta")) - .Returns((JsonReader reader, string currentPath) => - { - reader.TokenType.Should().Be(JsonToken.String); - reader.Value.Should().Be("metadata goes here"); - return Task.FromResult(mockMetadata.Object); - }); - - // Act - var formatter = new ResourceCollectionDocumentFormatter(mockResourceObjectFormatter.Object, mockMetadataFormatter.Object); - var document = - GetDeserializedOutput(formatter, - "Json/Fixtures/ResourceCollectionDocumentFormatter/Deserialize_document_with_metadata.json").Result; - - // Assert - document.PrimaryData.Should().BeEquivalentTo(); - document.RelatedData.Should().BeEquivalentTo(); - document.Metadata.Should().BeSameAs(mockMetadata.Object); - } - } -} diff --git a/JSONAPI.Tests/Json/ResourceLinkageFormatterTests.cs b/JSONAPI.Tests/Json/ResourceLinkageFormatterTests.cs deleted file mode 100644 index 35226c4f..00000000 --- a/JSONAPI.Tests/Json/ResourceLinkageFormatterTests.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System; -using System.Threading.Tasks; -using FluentAssertions; -using JSONAPI.Documents; -using JSONAPI.Json; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; - -namespace JSONAPI.Tests.Json -{ - [TestClass] - public class ResourceLinkageFormatterTests : JsonApiFormatterTestsBase - { - [TestMethod] - public async Task Serialize_present_toMany_linkage() - { - var linkageObject = new Mock(MockBehavior.Strict); - linkageObject.Setup(l => l.IsToMany).Returns(true); - linkageObject.Setup(l => l.Identifiers) - .Returns(new IResourceIdentifier[] { new ResourceIdentifier("countries", "11000"), new ResourceIdentifier("cities", "4100") }); - - var formatter = new ResourceLinkageFormatter(); - await AssertSerializeOutput(formatter, linkageObject.Object, "Json/Fixtures/ResourceLinkageFormatter/Serialize_present_toMany_linkage.json"); - } - - [TestMethod] - public async Task Serialize_empty_toMany_linkage() - { - var linkageObject = new Mock(MockBehavior.Strict); - linkageObject.Setup(l => l.IsToMany).Returns(true); - linkageObject.Setup(l => l.Identifiers).Returns(new IResourceIdentifier[] { }); - - var formatter = new ResourceLinkageFormatter(); - await AssertSerializeOutput(formatter, linkageObject.Object, "Json/Fixtures/ResourceLinkageFormatter/Serialize_empty_toMany_linkage.json"); - } - - [TestMethod] - public async Task Serialize_present_toOne_linkage() - { - var linkageObject = new Mock(MockBehavior.Strict); - linkageObject.Setup(l => l.IsToMany).Returns(false); - linkageObject.Setup(l => l.Identifiers).Returns(new IResourceIdentifier[] { new ResourceIdentifier("countries", "11000") }); - - var formatter = new ResourceLinkageFormatter(); - await AssertSerializeOutput(formatter, linkageObject.Object, "Json/Fixtures/ResourceLinkageFormatter/Serialize_present_toOne_linkage.json"); - } - - [TestMethod] - public async Task Serialize_null_toOne_linkage() - { - var linkageObject = new Mock(MockBehavior.Strict); - linkageObject.Setup(l => l.IsToMany).Returns(false); - linkageObject.Setup(l => l.Identifiers).Returns(new IResourceIdentifier[] { }); - - var formatter = new ResourceLinkageFormatter(); - await AssertSerializeOutput(formatter, linkageObject.Object, "Json/Fixtures/ResourceLinkageFormatter/Serialize_null_toOne_linkage.json"); - } - - [TestMethod] - public void Deserialize_to_one_linkage() - { - // Arrange - - // Act - var formatter = new ResourceLinkageFormatter(); - var linkage = - GetDeserializedOutput(formatter, - "Json/Fixtures/ResourceLinkageFormatter/Deserialize_to_one_linkage.json").Result; - - // Assert - linkage.IsToMany.Should().BeFalse(); - linkage.Identifiers.Length.Should().Be(1); - linkage.Identifiers[0].Type.Should().Be("people"); - linkage.Identifiers[0].Id.Should().Be("abc123"); - } - - [TestMethod] - public void Deserialize_null_to_one_linkage() - { - // Arrange - - // Act - var formatter = new ResourceLinkageFormatter(); - var linkage = - GetDeserializedOutput(formatter, - "Json/Fixtures/ResourceLinkageFormatter/Deserialize_null_to_one_linkage.json").Result; - - // Assert - linkage.IsToMany.Should().BeFalse(); - linkage.Identifiers.Length.Should().Be(0); - } - - [TestMethod] - public void Deserialize_to_many_linkage() - { - // Arrange - - // Act - var formatter = new ResourceLinkageFormatter(); - var linkage = - GetDeserializedOutput(formatter, - "Json/Fixtures/ResourceLinkageFormatter/Deserialize_to_many_linkage.json").Result; - - // Assert - linkage.IsToMany.Should().BeTrue(); - linkage.Identifiers[0].Type.Should().Be("posts"); - linkage.Identifiers[0].Id.Should().Be("12"); - linkage.Identifiers[1].Type.Should().Be("comments"); - linkage.Identifiers[1].Id.Should().Be("9510"); - } - - [TestMethod] - public void Deserialize_fails_on_string() - { - // Arrange - - // Act - var formatter = new ResourceLinkageFormatter(); - - Func action = () => GetDeserializedOutput(formatter, - "Json/Fixtures/ResourceLinkageFormatter/Deserialize_fails_on_string.json"); - - // Assert - action.ShouldThrow().WithMessage("Expected an array, object, or null for linkage, but got String"); - } - - [TestMethod] - public void Deserialize_fails_on_integer() - { - // Arrange - - // Act - var formatter = new ResourceLinkageFormatter(); - - Func action = () => GetDeserializedOutput(formatter, - "Json/Fixtures/ResourceLinkageFormatter/Deserialize_fails_on_integer.json"); - - // Assert - action.ShouldThrow().WithMessage("Expected an array, object, or null for linkage, but got Integer"); - } - } -} diff --git a/JSONAPI.Tests/Json/ResourceObjectFormatterTests.cs b/JSONAPI.Tests/Json/ResourceObjectFormatterTests.cs deleted file mode 100644 index 945061c2..00000000 --- a/JSONAPI.Tests/Json/ResourceObjectFormatterTests.cs +++ /dev/null @@ -1,282 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using FluentAssertions; -using JSONAPI.Documents; -using JSONAPI.Json; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Tests.Json -{ - [TestClass] - public class ResourceObjectFormatterTests : JsonApiFormatterTestsBase - { - [TestMethod] - public async Task Serialize_ResourceObject_for_null_resource() - { - var formatter = new ResourceObjectFormatter(null, null, null); - await AssertSerializeOutput(formatter, (IResourceObject)null, "Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_null_resource.json"); - } - - [TestMethod] - public async Task Serialize_ResourceObject_for_resource_without_attributes() - { - IResourceObject resourceObject = new ResourceObject("countries", "1100"); - - var formatter = new ResourceObjectFormatter(null, null, null); - await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_without_attributes.json"); - } - - [TestMethod] - public async Task Serialize_ResourceObject_for_resource_with_attributes() - { - var attributes = new Dictionary - { - { "name", "Triangle" }, - { "sides", 3 }, - { "foo", null } - }; - IResourceObject resourceObject = new ResourceObject("shapes", "1400", attributes); - - var formatter = new ResourceObjectFormatter(null, null, null); - await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_attributes.json"); - } - - [TestMethod] - public async Task Serialize_ResourceObject_for_resource_with_relationships() - { - var mockCapital = new Mock(MockBehavior.Strict); - var mockNeighbors = new Mock(MockBehavior.Strict); - - var mockRelationshipObjectFormatter = new Mock(MockBehavior.Strict); - mockRelationshipObjectFormatter.Setup(m => m.Serialize(mockCapital.Object, It.IsAny())) - .Returns((IRelationshipObject relationshipObject, JsonWriter writer) => - { - writer.WriteValue("IRelationship Placeholder - capital"); - return Task.FromResult(0); - }).Verifiable(); - mockRelationshipObjectFormatter.Setup(m => m.Serialize(mockNeighbors.Object, It.IsAny())) - .Returns((IRelationshipObject relationshipObject, JsonWriter writer) => - { - writer.WriteValue("IRelationship Placeholder - neighbors"); - return Task.FromResult(0); - }).Verifiable(); - - var relationships = new Dictionary - { - { "capital", mockCapital.Object }, - { "neighbors", mockNeighbors.Object } - }; - IResourceObject resourceObject = new ResourceObject("states", "1400", relationships: relationships); - - var formatter = new ResourceObjectFormatter(mockRelationshipObjectFormatter.Object, null, null); - await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_relationships.json"); - mockRelationshipObjectFormatter.Verify(s => s.Serialize(mockCapital.Object, It.IsAny()), Times.Once); - mockRelationshipObjectFormatter.Verify(s => s.Serialize(mockNeighbors.Object, It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task Serialize_ResourceObject_for_resource_with_only_null_relationships() - { - var relationships = new Dictionary - { - { "capital", null } - }; - IResourceObject resourceObject = new ResourceObject("states", "1400", relationships: relationships); - - var formatter = new ResourceObjectFormatter(null, null, null); - await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_only_null_relationships.json"); - } - - [TestMethod] - public async Task Serialize_ResourceObject_for_resource_with_links() - { - var mockLinkFormatter = new Mock(MockBehavior.Strict); - mockLinkFormatter.Setup(m => m.Serialize(It.IsAny(), It.IsAny())) - .Returns((ILink link, JsonWriter writer) => - { - writer.WriteValue("ILink placeholder 1"); - return Task.FromResult(0); - }).Verifiable(); - - var mockSelfLink = new Mock(MockBehavior.Strict); - - IResourceObject resourceObject = new ResourceObject("states", "1400", selfLink: mockSelfLink.Object); - - var formatter = new ResourceObjectFormatter(null, mockLinkFormatter.Object, null); - await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_links.json"); - mockLinkFormatter.Verify(s => s.Serialize(mockSelfLink.Object, It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task Serialize_ResourceObject_for_resource_with_metadata() - { - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - mockMetadataFormatter.Setup(m => m.Serialize(It.IsAny(), It.IsAny())) - .Returns((IMetadata metadata, JsonWriter writer) => - { - writer.WriteValue("IMetadata placeholder 1"); - return Task.FromResult(0); - }).Verifiable(); - - var mockMetadata = new Mock(MockBehavior.Strict); - IResourceObject resourceObject = new ResourceObject("states", "1400", metadata: mockMetadata.Object); - - var formatter = new ResourceObjectFormatter(null, null, mockMetadataFormatter.Object); - await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_metadata.json"); - mockMetadataFormatter.Verify(s => s.Serialize(mockMetadata.Object, It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task Serialize_ResourceObject_for_resource_with_all_possible_members() - { - var mockCapital = new Mock(MockBehavior.Strict); - var mockNeighbors = new Mock(MockBehavior.Strict); - - var mockRelationshipObjectFormatter = new Mock(MockBehavior.Strict); - mockRelationshipObjectFormatter.Setup(m => m.Serialize(mockCapital.Object, It.IsAny())) - .Returns((IRelationshipObject relationshipObject, JsonWriter writer) => - { - writer.WriteValue("IRelationship Placeholder - capital"); - return Task.FromResult(0); - }).Verifiable(); - mockRelationshipObjectFormatter.Setup(m => m.Serialize(mockNeighbors.Object, It.IsAny())) - .Returns((IRelationshipObject relationshipObject, JsonWriter writer) => - { - writer.WriteValue("IRelationship Placeholder - neighbors"); - return Task.FromResult(0); - }).Verifiable(); - - var mockLinkFormatter = new Mock(MockBehavior.Strict); - mockLinkFormatter.Setup(m => m.Serialize(It.IsAny(), It.IsAny())) - .Returns((ILink link, JsonWriter writer) => - { - writer.WriteValue("ILink placeholder 1"); - return Task.FromResult(0); - }).Verifiable(); - - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - mockMetadataFormatter.Setup(m => m.Serialize(It.IsAny(), It.IsAny())) - .Returns((IMetadata metadata, JsonWriter writer) => - { - writer.WriteValue("IMetadata placeholder 1"); - return Task.FromResult(0); - }).Verifiable(); - - - var attributes = new Dictionary - { - { "name", "New York" }, - { "population", 19746227 }, - { "foo", null } - }; - - var relationships = new Dictionary - { - { "capital", mockCapital.Object }, - { "neighbors", mockNeighbors.Object } - }; - - var mockSelfLink = new Mock(MockBehavior.Strict); - var mockMetadata = new Mock(MockBehavior.Strict); - - IResourceObject resourceObject = new ResourceObject("states", "1400", attributes, relationships, mockSelfLink.Object, mockMetadata.Object); - - var formatter = new ResourceObjectFormatter(mockRelationshipObjectFormatter.Object, mockLinkFormatter.Object, mockMetadataFormatter.Object); - await AssertSerializeOutput(formatter, resourceObject, "Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_all_possible_members.json"); - mockRelationshipObjectFormatter.Verify(s => s.Serialize(mockCapital.Object, It.IsAny()), Times.Once); - mockRelationshipObjectFormatter.Verify(s => s.Serialize(mockNeighbors.Object, It.IsAny()), Times.Once); - mockLinkFormatter.Verify(s => s.Serialize(mockSelfLink.Object, It.IsAny()), Times.Once); - mockMetadataFormatter.Verify(s => s.Serialize(mockMetadata.Object, It.IsAny()), Times.Once); - } - - class Sample - { - public string Id { get; set; } - - public UInt64 UInt64Field { get; set; } - - public UInt64? NullableUInt64Field { get; set; } - } - - [TestMethod] - public async Task Serialize_ResourceObject_for_resource_with_unsigned_long_integer_greater_than_int64_maxvalue() - { - var attributes = new Dictionary - { - { "uInt64Field", 9223372036854775808 }, - { "nullableUInt64Field", 9223372036854775808 } - }; - - var resourceObject = new Mock(); - resourceObject.Setup(o => o.Id).Returns("2010"); - resourceObject.Setup(o => o.Type).Returns("samples"); - resourceObject.Setup(o => o.Attributes).Returns(attributes); - resourceObject.Setup(o => o.Relationships).Returns(new Dictionary()); - - var formatter = new ResourceObjectFormatter(null, null, null); - await AssertSerializeOutput(formatter, resourceObject.Object, "Json/Fixtures/ResourceObjectFormatter/Serialize_ResourceObject_for_resource_with_unsigned_long_integer_greater_than_int64_maxvalue.json"); - } - - [TestMethod] - public void Deserialize_resource_object() - { - // Arrange - var mockAuthorRelationship = new Mock(MockBehavior.Strict); - var mockCommentsRelationship = new Mock(MockBehavior.Strict); - var mockMetadata = new Mock(MockBehavior.Strict); - - var mockRelationshipFormatter = new Mock(MockBehavior.Strict); - mockRelationshipFormatter.Setup(s => s.Deserialize(It.IsAny(), "/relationships/author")) - .Returns((JsonReader reader, string currentPath) => - { - reader.TokenType.Should().Be(JsonToken.String); - reader.Value.Should().Be("AUTHOR_RELATIONSHIP"); - return Task.FromResult(mockAuthorRelationship.Object); - }); - mockRelationshipFormatter.Setup(s => s.Deserialize(It.IsAny(), "/relationships/comments")) - .Returns((JsonReader reader, string currentPath) => - { - reader.TokenType.Should().Be(JsonToken.String); - reader.Value.Should().Be("COMMENTS_RELATIONSHIP"); - return Task.FromResult(mockCommentsRelationship.Object); - }); - - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - mockMetadataFormatter.Setup(s => s.Deserialize(It.IsAny(), "/meta")) - .Returns((JsonReader reader, string currentPath) => - { - reader.TokenType.Should().Be(JsonToken.String); - reader.Value.Should().Be("metadata goes here"); - return Task.FromResult(mockMetadata.Object); - }); - - // Act - var formatter = new ResourceObjectFormatter(mockRelationshipFormatter.Object, null, mockMetadataFormatter.Object); - var resourceObject = - GetDeserializedOutput(formatter, - "Json/Fixtures/ResourceObjectFormatter/Deserialize_resource_object.json").Result; - - // Assert - resourceObject.Type.Should().Be("posts"); - resourceObject.Id.Should().Be("123456"); - - resourceObject.Attributes.Keys.Count.Should().Be(3); - resourceObject.Attributes["title"].Value().Should().Be("Another awesome post"); - resourceObject.Attributes["likes"].Value().Should().Be(43); - resourceObject.Attributes["some-complex-attribute"].Should().BeOfType(); - ((JObject) resourceObject.Attributes["some-complex-attribute"]).Properties().Count().Should().Be(1); - ((int) ((JObject) resourceObject.Attributes["some-complex-attribute"])["qux"]).Should().Be(5); - - resourceObject.Relationships.Keys.Count.Should().Be(2); - resourceObject.Relationships["author"].Should().BeSameAs(mockAuthorRelationship.Object); - resourceObject.Relationships["comments"].Should().BeSameAs(mockCommentsRelationship.Object); - - resourceObject.Metadata.Should().BeSameAs(mockMetadata.Object); - } - } -} diff --git a/JSONAPI.Tests/Json/SingleResourceDocumentFormatterTests.cs b/JSONAPI.Tests/Json/SingleResourceDocumentFormatterTests.cs deleted file mode 100644 index 69ac40e2..00000000 --- a/JSONAPI.Tests/Json/SingleResourceDocumentFormatterTests.cs +++ /dev/null @@ -1,164 +0,0 @@ -using System.Threading.Tasks; -using FluentAssertions; -using JSONAPI.Documents; -using JSONAPI.Json; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using Newtonsoft.Json; - -namespace JSONAPI.Tests.Json -{ - [TestClass] - public class SingleResourceDocumentFormatterTests : JsonApiFormatterTestsBase - { - [TestMethod] - public async Task Serialize_SingleResourceDocument_for_primary_data_only() - { - var mockResourceObjectFormatter = new Mock(MockBehavior.Strict); - mockResourceObjectFormatter.Setup(m => m.Serialize(It.IsAny(), It.IsAny())) - .Returns((IResourceObject resourceObject, JsonWriter writer) => - { - writer.WriteValue("Placeholder resource object"); - return Task.FromResult(0); - }).Verifiable(); - - var mockResource = new Mock(MockBehavior.Strict); - ISingleResourceDocument document = new SingleResourceDocument(mockResource.Object, null, null); - - var formatter = new SingleResourceDocumentFormatter(mockResourceObjectFormatter.Object, null); - await AssertSerializeOutput(formatter, document, "Json/Fixtures/SingleResourceDocumentFormatter/Serialize_SingleResourceDocument_for_primary_data_only.json"); - mockResourceObjectFormatter.Verify(s => s.Serialize(mockResource.Object, It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task Serialize_SingleResourceDocument_for_primary_data_and_metadata() - { - var mockResourceObjectFormatter = new Mock(MockBehavior.Strict); - mockResourceObjectFormatter.Setup(m => m.Serialize(It.IsAny(), It.IsAny())) - .Returns((IResourceObject resourceObject, JsonWriter writer) => - { - writer.WriteValue("Placeholder resource object"); - return Task.FromResult(0); - }).Verifiable(); - - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - mockMetadataFormatter.Setup(m => m.Serialize(It.IsAny(), It.IsAny())) - .Returns((IMetadata resourceObject, JsonWriter writer) => - { - writer.WriteValue("Placeholder metadata object"); - return Task.FromResult(0); - }).Verifiable(); - - var mockResource = new Mock(MockBehavior.Strict); - var mockMetadata = new Mock(MockBehavior.Strict); - ISingleResourceDocument document = new SingleResourceDocument(mockResource.Object, null, mockMetadata.Object); - - var formatter = new SingleResourceDocumentFormatter(mockResourceObjectFormatter.Object, mockMetadataFormatter.Object); - await AssertSerializeOutput(formatter, document, "Json/Fixtures/SingleResourceDocumentFormatter/Serialize_SingleResourceDocument_for_primary_data_and_metadata.json"); - mockResourceObjectFormatter.Verify(s => s.Serialize(mockResource.Object, It.IsAny()), Times.Once); - mockMetadataFormatter.Verify(s => s.Serialize(mockMetadata.Object, It.IsAny()), Times.Once); - } - - [TestMethod] - public async Task Serialize_SingleResourceDocument_for_all_possible_members() - { - var mockPrimaryData = new Mock(MockBehavior.Strict); - var relatedResource1 = new Mock(MockBehavior.Strict); - var relatedResource2 = new Mock(MockBehavior.Strict); - var relatedResource3 = new Mock(MockBehavior.Strict); - - var mockResourceObjectFormatter = new Mock(MockBehavior.Strict); - mockResourceObjectFormatter.Setup(m => m.Serialize(mockPrimaryData.Object, It.IsAny())) - .Returns((IResourceObject resourceObject, JsonWriter writer) => - { - writer.WriteValue("Primary data object"); - return Task.FromResult(0); - }).Verifiable(); - mockResourceObjectFormatter.Setup(m => m.Serialize(relatedResource1.Object, It.IsAny())) - .Returns((IResourceObject resourceObject, JsonWriter writer) => - { - writer.WriteValue("Related data object 1"); - return Task.FromResult(0); - }).Verifiable(); - mockResourceObjectFormatter.Setup(m => m.Serialize(relatedResource2.Object, It.IsAny())) - .Returns((IResourceObject resourceObject, JsonWriter writer) => - { - writer.WriteValue("Related data object 2"); - return Task.FromResult(0); - }).Verifiable(); - mockResourceObjectFormatter.Setup(m => m.Serialize(relatedResource3.Object, It.IsAny())) - .Returns((IResourceObject resourceObject, JsonWriter writer) => - { - writer.WriteValue("Related data object 3"); - return Task.FromResult(0); - }).Verifiable(); - - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - mockMetadataFormatter.Setup(m => m.Serialize(It.IsAny(), It.IsAny())) - .Returns((IMetadata resourceObject, JsonWriter writer) => - { - writer.WriteValue("Placeholder metadata object"); - return Task.FromResult(0); - }).Verifiable(); - - var mockMetadata = new Mock(MockBehavior.Strict); - var relatedResources = new[] { relatedResource1.Object, relatedResource2.Object, relatedResource3.Object }; - ISingleResourceDocument document = new SingleResourceDocument(mockPrimaryData.Object, relatedResources, mockMetadata.Object); - - var formatter = new SingleResourceDocumentFormatter(mockResourceObjectFormatter.Object, mockMetadataFormatter.Object); - await AssertSerializeOutput(formatter, document, "Json/Fixtures/SingleResourceDocumentFormatter/Serialize_SingleResourceDocument_for_all_possible_members.json"); - mockResourceObjectFormatter.Verify(s => s.Serialize(mockPrimaryData.Object, It.IsAny()), Times.Once); - mockResourceObjectFormatter.Verify(s => s.Serialize(relatedResource1.Object, It.IsAny()), Times.Once); - mockResourceObjectFormatter.Verify(s => s.Serialize(relatedResource2.Object, It.IsAny()), Times.Once); - mockResourceObjectFormatter.Verify(s => s.Serialize(relatedResource3.Object, It.IsAny()), Times.Once); - mockMetadataFormatter.Verify(s => s.Serialize(mockMetadata.Object, It.IsAny()), Times.Once); - } - - [TestMethod] - public void Deserialize_null_document() - { - // Arrange - var mockResourceObjectFormatter = new Mock(MockBehavior.Strict); - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - - // Act - var formatter = new SingleResourceDocumentFormatter(mockResourceObjectFormatter.Object, mockMetadataFormatter.Object); - var document = - GetDeserializedOutput(formatter, - "Json/Fixtures/SingleResourceDocumentFormatter/Deserialize_null_document.json").Result; - - // Assert - document.PrimaryData.Should().BeNull(); - document.RelatedData.Should().BeEquivalentTo(); - document.Metadata.Should().BeNull(); - } - - [TestMethod] - public void Deserialize_document_with_resource() - { - // Arrange - var mockResourceObject = new Mock(MockBehavior.Strict); - - var mockResourceObjectFormatter = new Mock(MockBehavior.Strict); - mockResourceObjectFormatter.Setup(s => s.Deserialize(It.IsAny(), "/data")) - .Returns((JsonReader reader, string currentPath) => - { - reader.TokenType.Should().Be(JsonToken.String); - reader.Value.Should().Be("primary data goes here"); - return Task.FromResult(mockResourceObject.Object); - }); - var mockMetadataFormatter = new Mock(MockBehavior.Strict); - - // Act - var formatter = new SingleResourceDocumentFormatter(mockResourceObjectFormatter.Object, mockMetadataFormatter.Object); - var document = - GetDeserializedOutput(formatter, - "Json/Fixtures/SingleResourceDocumentFormatter/Deserialize_document_with_resource.json").Result; - - // Assert - document.PrimaryData.Should().BeSameAs(mockResourceObject.Object); - document.RelatedData.Should().BeEquivalentTo(); - document.Metadata.Should().BeNull(); - } - } -} diff --git a/JSONAPI.Tests/Models/AttributeGrabBag.cs b/JSONAPI.Tests/Models/AttributeGrabBag.cs deleted file mode 100644 index dca40e34..00000000 --- a/JSONAPI.Tests/Models/AttributeGrabBag.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Collections.Generic; -using JSONAPI.Attributes; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; - -namespace JSONAPI.Tests.Models -{ - public enum SampleEnum - { - Value1 = 1, - Value2 = 2 - } - - public class SampleComplexType - { - [JsonProperty("intProp")] - public Int32 IntProp { get; set; } - public string StringProp { get; set; } - } - - public class AttributeGrabBag - { - public string Id { get; set; } - public Boolean BooleanField { get; set; } - public Boolean? NullableBooleanField { get; set; } - public SByte SbyteField { get; set; } - public SByte? NullableSbyteField { get; set; } - public Byte ByteField { get; set; } - public Byte? NullableByteField { get; set; } - public Int16 Int16Field { get; set; } - public Int16? NullableInt16Field { get; set; } - public UInt16 Uint16Field { get; set; } - public UInt16? NullableUint16Field { get; set; } - public Int32 Int32Field { get; set; } - public Int32? NullableInt32Field { get; set; } - public UInt32 Uint32Field { get; set; } - public UInt32? NullableUint32Field { get; set; } - public Int64 Int64Field { get; set; } - public Int64? NullableInt64Field { get; set; } - public UInt64 Uint64Field { get; set; } - public UInt64? NullableUint64Field { get; set; } - public Double DoubleField { get; set; } - public Double? NullableDoubleField { get; set; } - public Single SingleField { get; set; } - public Single? NullableSingleField { get; set; } - public Decimal DecimalField { get; set; } - public Decimal? NullableDecimalField { get; set; } - public DateTime DateTimeField { get; set; } - public DateTime? NullableDateTimeField { get; set; } - public DateTimeOffset DateTimeOffsetField { get; set; } - public DateTimeOffset? NullableDateTimeOffsetField { get; set; } - public Guid GuidField { get; set; } - public Guid? NullableGuidField { get; set; } - public string StringField { get; set; } - public SampleEnum EnumField { get; set; } - public SampleEnum? NullableEnumField { get; set; } - - [SerializeAsComplex] - public string ComplexAttributeField { get; set; } - - [SerializeAsComplex] - public SampleComplexType ToOneComplexTypeField { get; set; } - - [SerializeAsComplex] - public virtual ICollection ToManyComplexTypeField { get; set; } - } -} diff --git a/JSONAPI.Tests/Models/Author.cs b/JSONAPI.Tests/Models/Author.cs deleted file mode 100644 index 69f30a06..00000000 --- a/JSONAPI.Tests/Models/Author.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; - -namespace JSONAPI.Tests.Models -{ - class Author - { - public int Id { get; set; } - public string Name { get; set; } - public IList Posts { get; set; } - } -} diff --git a/JSONAPI.Tests/Models/Comment.cs b/JSONAPI.Tests/Models/Comment.cs deleted file mode 100644 index 704b7674..00000000 --- a/JSONAPI.Tests/Models/Comment.cs +++ /dev/null @@ -1,12 +0,0 @@ -using JSONAPI.Attributes; - -namespace JSONAPI.Tests.Models -{ - class Comment - { - public int Id { get; set; } - public string Body { get; set; } - public Post Post { get; set; } - [SerializeAsComplex]public string CustomData { get; set; } - } -} diff --git a/JSONAPI.Tests/Models/Post.cs b/JSONAPI.Tests/Models/Post.cs deleted file mode 100644 index f43347a7..00000000 --- a/JSONAPI.Tests/Models/Post.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using JSONAPI.Attributes; -using Newtonsoft.Json; - -namespace JSONAPI.Tests.Models -{ - class Post - { - public int Id { get; set; } - public string Title { get; set; } - - [JsonIgnore] - public string AuthorId { get; set; } - - [RelationshipLinkTemplate("/posts/{1}/relationships/comments")] - [RelatedResourceLinkTemplate("/posts/{1}/comments")] - public IList Comments { get; set; } - public Author Author { get; set; } - } -} diff --git a/JSONAPI.Tests/Models/Tag.cs b/JSONAPI.Tests/Models/Tag.cs deleted file mode 100644 index ba13a5e9..00000000 --- a/JSONAPI.Tests/Models/Tag.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace JSONAPI.Tests.Models -{ - class Tag - { - public byte Id { get; set; } - public string Text { get; set; } - } -} diff --git a/JSONAPI.Tests/Models/UserGroup.cs b/JSONAPI.Tests/Models/UserGroup.cs deleted file mode 100644 index ceed0d22..00000000 --- a/JSONAPI.Tests/Models/UserGroup.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace JSONAPI.Tests.Models -{ - class UserGroup - { - public int Id { get; set; } - public string Name { get; set; } - } -} diff --git a/JSONAPI.Tests/Properties/AssemblyInfo.cs b/JSONAPI.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 12a723f0..00000000 --- a/JSONAPI.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("JSONAPI.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("ERMC")] -[assembly: AssemblyProduct("JSONAPI.Tests")] -[assembly: AssemblyCopyright("Copyright © ERMC 2013")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("b0fb3634-e3d3-4c1c-894e-ea8b1f47e8e0")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/JSONAPI.Tests/TestHelpers.cs b/JSONAPI.Tests/TestHelpers.cs deleted file mode 100644 index eb4e4d78..00000000 --- a/JSONAPI.Tests/TestHelpers.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Reflection; -using FluentAssertions; -using JSONAPI.Json; -using Moq; - -namespace JSONAPI.Tests -{ - internal static class TestHelpers - { - public static string ReadEmbeddedFile(string path) - { - var resourcePath = "JSONAPI.Tests." + path.Replace("\\", ".").Replace("/", "."); - using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourcePath)) - { - if (stream == null) throw new Exception("Could not find a file at the path: " + path); - return new StreamReader(stream).ReadToEnd(); - } - } - - public static void StreamContentsMatchFixtureContents(MemoryStream stream, string fixtureFileName) - { - var output = System.Text.Encoding.ASCII.GetString(stream.ToArray()); - var expectedJson = ReadEmbeddedFile(fixtureFileName); - var minifiedExpectedJson = JsonHelpers.MinifyJson(expectedJson); - output.Should().Be(minifiedExpectedJson); - } - - public static void SetupIQueryable(this Mock mock, IQueryable queryable) - where T : class, IQueryable - { - mock.Setup(r => r.GetEnumerator()).Returns(queryable.GetEnumerator()); - mock.Setup(r => r.Provider).Returns(queryable.Provider); - mock.Setup(r => r.ElementType).Returns(queryable.ElementType); - mock.Setup(r => r.Expression).Returns(queryable.Expression); - } - } -} diff --git a/JSONAPI.Tests/app.config b/JSONAPI.Tests/app.config deleted file mode 100644 index cb613ec1..00000000 --- a/JSONAPI.Tests/app.config +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.Tests/packages.config b/JSONAPI.Tests/packages.config deleted file mode 100644 index ac30f5f4..00000000 --- a/JSONAPI.Tests/packages.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.TodoMVC.API/Controllers/MainController.cs b/JSONAPI.TodoMVC.API/Controllers/MainController.cs deleted file mode 100644 index f1bc55de..00000000 --- a/JSONAPI.TodoMVC.API/Controllers/MainController.cs +++ /dev/null @@ -1,12 +0,0 @@ -using JSONAPI.Http; - -namespace JSONAPI.TodoMVC.API.Controllers -{ - public class MainController : JsonApiController - { - public MainController(IDocumentMaterializerLocator documentMaterializerLocator) - : base(documentMaterializerLocator) - { - } - } -} \ No newline at end of file diff --git a/JSONAPI.TodoMVC.API/JSONAPI.TodoMVC.API.csproj b/JSONAPI.TodoMVC.API/JSONAPI.TodoMVC.API.csproj deleted file mode 100644 index 13ac0840..00000000 --- a/JSONAPI.TodoMVC.API/JSONAPI.TodoMVC.API.csproj +++ /dev/null @@ -1,191 +0,0 @@ - - - - - Debug - AnyCPU - - - 2.0 - {ECFA3EC5-47B8-4060-925E-9205146D6562} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - JSONAPI.TodoMVC.API - JSONAPI.TodoMVC.API - v4.5 - true - - - - - ..\ - true - - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\ - TRACE - prompt - 4 - - - - ..\packages\Autofac.3.5.2\lib\net40\Autofac.dll - - - False - ..\packages\Autofac.WebApi2.3.4.0\lib\net45\Autofac.Integration.WebApi.dll - - - False - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll - - - False - ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll - - - - ..\packages\Microsoft.Owin.3.0.0\lib\net45\Microsoft.Owin.dll - - - ..\packages\Microsoft.Owin.Host.SystemWeb.3.0.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll - - - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - - - ..\packages\Owin.1.0\lib\net40\Owin.dll - - - - False - ..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll - - - - - - - - - - - - False - ..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll - - - False - ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.2\lib\net45\System.Web.Http.Owin.dll - - - - - - - - - - - - - - - - - 201502061744049_Initial.cs - - - - - - - - - - - Web.config - - - Web.config - - - - - - - - {64abe648-efcb-46ee-9e1a-e163f52bf372} - JSONAPI.Autofac.EntityFramework - - - {af7861f3-550b-4f70-a33e-1e5f48d39333} - JSONAPI.Autofac - - - {E906356C-93F6-41F6-9A0D-73B8A99AA53C} - JSONAPI.EntityFramework - - - {52B19FD6-EFAA-45B5-9C3E-A652E27608D1} - JSONAPI - - - - - 201502061744049_Initial.cs - - - - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - - - - - True - True - 58216 - / - http://localhost:58216/ - False - False - - - False - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/JSONAPI.TodoMVC.API/Migrations/201502061744049_Initial.Designer.cs b/JSONAPI.TodoMVC.API/Migrations/201502061744049_Initial.Designer.cs deleted file mode 100644 index c80ba74c..00000000 --- a/JSONAPI.TodoMVC.API/Migrations/201502061744049_Initial.Designer.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -namespace JSONAPI.TodoMVC.API.Migrations -{ - using System.CodeDom.Compiler; - using System.Data.Entity.Migrations; - using System.Data.Entity.Migrations.Infrastructure; - using System.Resources; - - [GeneratedCode("EntityFramework.Migrations", "6.1.2-31219")] - public sealed partial class Initial : IMigrationMetadata - { - private readonly ResourceManager Resources = new ResourceManager(typeof(Initial)); - - string IMigrationMetadata.Id - { - get { return "201502061744049_Initial"; } - } - - string IMigrationMetadata.Source - { - get { return null; } - } - - string IMigrationMetadata.Target - { - get { return Resources.GetString("Target"); } - } - } -} diff --git a/JSONAPI.TodoMVC.API/Migrations/201502061744049_Initial.cs b/JSONAPI.TodoMVC.API/Migrations/201502061744049_Initial.cs deleted file mode 100644 index 5f196ca2..00000000 --- a/JSONAPI.TodoMVC.API/Migrations/201502061744049_Initial.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace JSONAPI.TodoMVC.API.Migrations -{ - using System.Data.Entity.Migrations; - - public partial class Initial : DbMigration - { - public override void Up() - { - CreateTable( - "dbo.Todo", - c => new - { - Id = c.String(nullable: false, maxLength: 128), - Text = c.String(nullable: false), - IsCompleted = c.Boolean(nullable: false), - }) - .PrimaryKey(t => t.Id); - - } - - public override void Down() - { - DropTable("dbo.Todo"); - } - } -} diff --git a/JSONAPI.TodoMVC.API/Migrations/201502061744049_Initial.resx b/JSONAPI.TodoMVC.API/Migrations/201502061744049_Initial.resx deleted file mode 100644 index 904f2962..00000000 --- a/JSONAPI.TodoMVC.API/Migrations/201502061744049_Initial.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - H4sIAAAAAAAEAM1X23LbNhB970z/gYOndsYRbOcl9VDJOLTdURtZnlDxO0SuZExxYQFQI31bHvpJ/YUueBepi5M4mY5eSGD3YPfw7C707+d/wncbKYI1GMu1GpOL0TkJQCU65Wo1JrlbvnpD3r39+afwNpWb4LG2e+3t0FPZMXlyLrui1CZPIJkdSZ4YbfXSjRItKUs1vTw//41eXFBACIJYQRB+zJXjEooXfI20SiBzORNTnYKw1TruxAVqcM8k2IwlMCZ/xLP764fJaK5TPX2MRv659CLBteAMI4pBLEnAlNKOOYz36pOF2BmtVnGGC0zMtxmg3ZIJC1UeV635c1M6v/Qp0daxhkpy67T8QsCL1xVHtO/+VUyThkNk8RbZdlufdcHkmHjySNA/6CoSxhsdI7lYOgv2GJw18kAV+d9ZEOXC5QbGCnJnmDgLHvKF4MmfsJ3rv0CNVS5EN1AMFfd2FnDpwegMjNt+hGUV/iQlAd31o33Hxq3jUyaHUkB1k2DKNh9ArdwT6v7yDQnu+AbSeqXSxifFsRjQyZkcX+8xYLYQ0OzTo2fOYeOOnIqP3+PUiY20zAQ4aFJ+r7UApk5AhbQVylA+WKSOcQWmo6HpOvHLRZoDNWHVVYKyVSa7YZewMbgOIBZxG0NZyaNSrPsCbUJqGwYtO0bdWeiB1hJOWZbh9+i0mmoliMs+E72Kv7zwZIlBE7un/ppom5OcNmwFvV08GiO948a6G+bYgvnPFKVyYNb7AAfIrQ/rctyvsJby2to/lx4nWkEfqyXyDnOToFyRJjTxVM1n4FY0eyaY2VO3kRa5VIdq/5h3WYFd/3Ll+Qg71bQTSHdjiBfSHg990umA9V5H63/CYwXQN2lObwqhJ/iwEt/pgTtQY2lCAiRqzVOvxHhrHciRNxjFf4tIcMy3NZgyxZdgXdn0Cc66y96s/v/MTWptKp4xPH/41FJrZpInZoZz6xuGUg36i2SbX19i0Cy4e9EhM2yFp2fIwRFSCndM0gW+zMsIv2m4DGsopN2rbXgDlq9aCH/RVZB4cbagtc1ELXVNMCbUjag26fE/BcdS5OXaOL5kicPtBKwtrhmPTORocisXkE7ULHdZ7q6tBbkQ226+IT1+fjFBd2MOZ5l/sy+RAobJMQWYqfc5F2kT990e4RyA8BL5HXC9KHq8ZiHcatsg3Wv1TKCKvhvIQKXYwOaA4kYwO1MxW8PXxIZXoA+wYsm2boWHQU5/iF3awxvOVoZJW2G0/v7vGvX/197+B4M5dvPhDQAA - - - dbo - - \ No newline at end of file diff --git a/JSONAPI.TodoMVC.API/Migrations/Configuration.cs b/JSONAPI.TodoMVC.API/Migrations/Configuration.cs deleted file mode 100644 index 962d285b..00000000 --- a/JSONAPI.TodoMVC.API/Migrations/Configuration.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Data.Entity.Migrations; -using JSONAPI.TodoMVC.API.Models; - -namespace JSONAPI.TodoMVC.API.Migrations -{ - internal sealed class Configuration : DbMigrationsConfiguration - { - public Configuration() - { - AutomaticMigrationsEnabled = false; - } - - protected override void Seed(TodoMvcContext context) - { - context.Todos.AddOrUpdate( - new Todo - { - Id = "1", - Text = "Do the dishes", - IsCompleted = false - }, - new Todo - { - Id = "2", - Text = "Do the laundry", - IsCompleted = true - }, - new Todo - { - Id = "3", - Text = "Walk the dog", - IsCompleted = false - } - ); - } - } -} diff --git a/JSONAPI.TodoMVC.API/Models/Todo.cs b/JSONAPI.TodoMVC.API/Models/Todo.cs deleted file mode 100644 index 21429f8b..00000000 --- a/JSONAPI.TodoMVC.API/Models/Todo.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace JSONAPI.TodoMVC.API.Models -{ - public class Todo - { - public string Id { get; set; } - - [Required] - public string Text { get; set; } - - public bool IsCompleted { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.TodoMVC.API/Models/TodoMvcContext.cs b/JSONAPI.TodoMVC.API/Models/TodoMvcContext.cs deleted file mode 100644 index 814e2c0d..00000000 --- a/JSONAPI.TodoMVC.API/Models/TodoMvcContext.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Data.Common; -using System.Data.Entity; -using System.Data.Entity.ModelConfiguration.Conventions; - -namespace JSONAPI.TodoMVC.API.Models -{ - public class TodoMvcContext : DbContext - { - public TodoMvcContext() - { - - } - - public TodoMvcContext(DbConnection connection, bool contextOwnsConnection) - : base(connection, contextOwnsConnection) - { - - } - - protected override void OnModelCreating(DbModelBuilder modelBuilder) - { - modelBuilder.Conventions.Remove(); - - base.OnModelCreating(modelBuilder); - } - - public DbSet Todos { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI.TodoMVC.API/Properties/AssemblyInfo.cs b/JSONAPI.TodoMVC.API/Properties/AssemblyInfo.cs deleted file mode 100644 index 7a2c0673..00000000 --- a/JSONAPI.TodoMVC.API/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("JSONAPI.TodoMVC.API")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("JSONAPI.TodoMVC.API")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("e2ddf49c-d412-4653-9cd9-b0bb3aed3776")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/JSONAPI.TodoMVC.API/Startup.cs b/JSONAPI.TodoMVC.API/Startup.cs deleted file mode 100644 index b5b6f0b0..00000000 --- a/JSONAPI.TodoMVC.API/Startup.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Data.Entity; -using System.Reflection; -using System.Web.Http; -using Autofac; -using Autofac.Integration.WebApi; -using JSONAPI.Autofac; -using JSONAPI.Autofac.EntityFramework; -using JSONAPI.Configuration; -using JSONAPI.Core; -using JSONAPI.EntityFramework.Configuration; -using JSONAPI.TodoMVC.API.Models; -using Owin; - -namespace JSONAPI.TodoMVC.API -{ - public class Startup - { - public void Configuration(IAppBuilder app) - { - var httpConfig = GetWebApiConfiguration(); - app.UseWebApi(httpConfig); - } - - private static HttpConfiguration GetWebApiConfiguration() - { - var httpConfig = new HttpConfiguration(); - - var containerBuilder = new ContainerBuilder(); - containerBuilder.RegisterApiControllers(Assembly.GetExecutingAssembly()); - containerBuilder.RegisterType().As().InstancePerRequest(); - var container = containerBuilder.Build(); - - var configuration = new JsonApiConfiguration(); - configuration.RegisterEntityFrameworkResourceType(c => c.OverrideDefaultResourceTypeName("todos")); - configuration.SetupHttpConfigurationUsingAutofac(httpConfig, container); - - return httpConfig; - } - } -} \ No newline at end of file diff --git a/JSONAPI.TodoMVC.API/Web.Debug.config b/JSONAPI.TodoMVC.API/Web.Debug.config deleted file mode 100644 index 2e302f9f..00000000 --- a/JSONAPI.TodoMVC.API/Web.Debug.config +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.TodoMVC.API/Web.Release.config b/JSONAPI.TodoMVC.API/Web.Release.config deleted file mode 100644 index c3584446..00000000 --- a/JSONAPI.TodoMVC.API/Web.Release.config +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.TodoMVC.API/Web.config b/JSONAPI.TodoMVC.API/Web.config deleted file mode 100644 index f52ca3cb..00000000 --- a/JSONAPI.TodoMVC.API/Web.config +++ /dev/null @@ -1,97 +0,0 @@ - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.TodoMVC.API/packages.config b/JSONAPI.TodoMVC.API/packages.config deleted file mode 100644 index 922aad91..00000000 --- a/JSONAPI.TodoMVC.API/packages.config +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI.sln b/JSONAPI.sln deleted file mode 100644 index 07c3e3b5..00000000 --- a/JSONAPI.sln +++ /dev/null @@ -1,91 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONAPI", "JSONAPI\JSONAPI.csproj", "{52B19FD6-EFAA-45B5-9C3E-A652E27608D1}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{550F1F3B-83B1-43F1-A343-DF15E3DEEB12}" - ProjectSection(SolutionItems) = preProject - .gitignore = .gitignore - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONAPI.Tests", "JSONAPI.Tests\JSONAPI.Tests.csproj", "{8299ECFA-EA68-4C1D-9488-0D213D15D644}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONAPI.EntityFramework", "JSONAPI.EntityFramework\JSONAPI.EntityFramework.csproj", "{E906356C-93F6-41F6-9A0D-73B8A99AA53C}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONAPI.EntityFramework.Tests", "JSONAPI.EntityFramework.Tests\JSONAPI.EntityFramework.Tests.csproj", "{00655E05-F1BB-425D-92F3-659EFB581439}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{021B87D3-E627-47EE-98C7-AB3922C1EABF}" - ProjectSection(SolutionItems) = preProject - .nuget\NuGet.Config = .nuget\NuGet.Config - .nuget\NuGet.exe = .nuget\NuGet.exe - .nuget\NuGet.targets = .nuget\NuGet.targets - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONAPI.TodoMVC.API", "JSONAPI.TodoMVC.API\JSONAPI.TodoMVC.API.csproj", "{ECFA3EC5-47B8-4060-925E-9205146D6562}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp", "JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp\JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.csproj", "{76DEE472-723B-4BE6-8B97-428AC326E30F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONAPI.Autofac", "JSONAPI.Autofac\JSONAPI.Autofac.csproj", "{AF7861F3-550B-4F70-A33E-1E5F48D39333}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONAPI.Autofac.EntityFramework", "JSONAPI.Autofac.EntityFramework\JSONAPI.Autofac.EntityFramework.csproj", "{64ABE648-EFCB-46EE-9E1A-E163F52BF372}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests", "JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests\JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests.csproj", "{58AEF8B8-8D51-4175-AC96-BC622703E8BB}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSONAPI.Autofac.Tests", "JSONAPI.Autofac.Tests\JSONAPI.Autofac.Tests.csproj", "{AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {52B19FD6-EFAA-45B5-9C3E-A652E27608D1}.Release|Any CPU.Build.0 = Release|Any CPU - {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8299ECFA-EA68-4C1D-9488-0D213D15D644}.Release|Any CPU.Build.0 = Release|Any CPU - {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E906356C-93F6-41F6-9A0D-73B8A99AA53C}.Release|Any CPU.Build.0 = Release|Any CPU - {00655E05-F1BB-425D-92F3-659EFB581439}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {00655E05-F1BB-425D-92F3-659EFB581439}.Debug|Any CPU.Build.0 = Debug|Any CPU - {00655E05-F1BB-425D-92F3-659EFB581439}.Release|Any CPU.ActiveCfg = Release|Any CPU - {00655E05-F1BB-425D-92F3-659EFB581439}.Release|Any CPU.Build.0 = Release|Any CPU - {ECFA3EC5-47B8-4060-925E-9205146D6562}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ECFA3EC5-47B8-4060-925E-9205146D6562}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ECFA3EC5-47B8-4060-925E-9205146D6562}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ECFA3EC5-47B8-4060-925E-9205146D6562}.Release|Any CPU.Build.0 = Release|Any CPU - {76DEE472-723B-4BE6-8B97-428AC326E30F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {76DEE472-723B-4BE6-8B97-428AC326E30F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {76DEE472-723B-4BE6-8B97-428AC326E30F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {76DEE472-723B-4BE6-8B97-428AC326E30F}.Release|Any CPU.Build.0 = Release|Any CPU - {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AF7861F3-550B-4F70-A33E-1E5F48D39333}.Release|Any CPU.Build.0 = Release|Any CPU - {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Debug|Any CPU.Build.0 = Debug|Any CPU - {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Release|Any CPU.ActiveCfg = Release|Any CPU - {64ABE648-EFCB-46EE-9E1A-E163F52BF372}.Release|Any CPU.Build.0 = Release|Any CPU - {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {58AEF8B8-8D51-4175-AC96-BC622703E8BB}.Release|Any CPU.Build.0 = Release|Any CPU - {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AEA3C57B-8360-42FF-95E8-0F3A6BA5BCB1}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(TestCaseManagementSettings) = postSolution - CategoryFile = JSONAPI.vsmdi - EndGlobalSection -EndGlobal diff --git a/JSONAPI/ActionFilters/FallbackDocumentBuilderAttribute.cs b/JSONAPI/ActionFilters/FallbackDocumentBuilderAttribute.cs deleted file mode 100644 index 405cf3c1..00000000 --- a/JSONAPI/ActionFilters/FallbackDocumentBuilderAttribute.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using System.Web.Http; -using System.Web.Http.Filters; -using JSONAPI.Documents; -using JSONAPI.Documents.Builders; - -namespace JSONAPI.ActionFilters -{ - /// - /// Converts ObjectContent to JSON API document form if it isn't already - /// - public class FallbackDocumentBuilderAttribute : ActionFilterAttribute - { - private readonly IFallbackDocumentBuilder _fallbackDocumentBuilder; - private readonly IErrorDocumentBuilder _errorDocumentBuilder; - - /// - /// Creates a FallbackDocumentBuilderAttribute - /// - /// - /// - public FallbackDocumentBuilderAttribute(IFallbackDocumentBuilder fallbackDocumentBuilder, IErrorDocumentBuilder errorDocumentBuilder) - { - _fallbackDocumentBuilder = fallbackDocumentBuilder; - _errorDocumentBuilder = errorDocumentBuilder; - } - - public override async Task OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, - CancellationToken cancellationToken) - { - var response = actionExecutedContext.Response; - if (response != null && actionExecutedContext.Exception == null) - { - var content = actionExecutedContext.Response.Content; - var objectContent = content as ObjectContent; - if (content != null && objectContent == null) - return; - - if (objectContent != null) - { - if (objectContent.Value == null) - { - if (response.StatusCode == HttpStatusCode.OK) - response.StatusCode = HttpStatusCode.NoContent; - return; - } - - // These document types should be passed through; they are already ready to be serialized. - if (objectContent.Value is ISingleResourceDocument || - objectContent.Value is IResourceCollectionDocument) - return; - - var errorDocument = objectContent.Value as IErrorDocument; - if (errorDocument != null) - { - actionExecutedContext.Response.StatusCode = - errorDocument.Errors.First().Status; - return; - } - - object documentValue; - var httpError = objectContent.Value as HttpError; - if (httpError != null) - { - documentValue = _errorDocumentBuilder.BuildFromHttpError(httpError, actionExecutedContext.Response.StatusCode); - } - else - { - documentValue = - await _fallbackDocumentBuilder.BuildDocument(objectContent.Value, actionExecutedContext.Request, cancellationToken); - } - - errorDocument = documentValue as IErrorDocument; - if (documentValue is IErrorDocument) - { - actionExecutedContext.Response.StatusCode = errorDocument.Errors.First().Status; - } - - actionExecutedContext.Response.Content = new ObjectContent(documentValue.GetType(), documentValue, objectContent.Formatter); - } - } - - await Task.Yield(); - } - } -} diff --git a/JSONAPI/ActionFilters/JsonApiExceptionFilterAttribute.cs b/JSONAPI/ActionFilters/JsonApiExceptionFilterAttribute.cs deleted file mode 100644 index be96b26e..00000000 --- a/JSONAPI/ActionFilters/JsonApiExceptionFilterAttribute.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Web.Http.Filters; -using JSONAPI.Documents.Builders; -using JSONAPI.Json; - -namespace JSONAPI.ActionFilters -{ - /// - /// Filter for catching exceptions and converting them to IErrorDocument - /// - public class JsonApiExceptionFilterAttribute : ExceptionFilterAttribute - { - private readonly IErrorDocumentBuilder _errorDocumentBuilder; - private readonly JsonApiFormatter _jsonApiFormatter; - - /// - /// - /// - /// - /// - public JsonApiExceptionFilterAttribute(IErrorDocumentBuilder errorDocumentBuilder, JsonApiFormatter jsonApiFormatter) - { - _errorDocumentBuilder = errorDocumentBuilder; - _jsonApiFormatter = jsonApiFormatter; - } - - public override void OnException(HttpActionExecutedContext actionExecutedContext) - { - var document = _errorDocumentBuilder.BuildFromException(actionExecutedContext.Exception); - actionExecutedContext.Response = new HttpResponseMessage(HttpStatusCode.InternalServerError) - { - Content = new ObjectContent(document.GetType(), document, _jsonApiFormatter) - }; - if (document.Errors != null && document.Errors.Length > 0) - { - var status = document.Errors.First().Status; - actionExecutedContext.Response.StatusCode = status != default(HttpStatusCode) ? status : HttpStatusCode.InternalServerError; - } - } - } -} diff --git a/JSONAPI/Attributes/LinkSettingsAttribute.cs b/JSONAPI/Attributes/LinkSettingsAttribute.cs deleted file mode 100644 index 4c2b96cf..00000000 --- a/JSONAPI/Attributes/LinkSettingsAttribute.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace JSONAPI.Attributes -{ - /// - /// This attribute should be added to a property to override DefaultLinkConventions's default - /// behavior for serializing links. - /// - [AttributeUsage(AttributeTargets.Property)] - public class LinkSettingsAttribute : Attribute - { - internal bool SerializeRelationshipLink; - - internal bool SerializeRelatedResourceLink; - - /// - /// Creates a new LinkSettingsAttribute. - /// - public LinkSettingsAttribute(bool serializeRelationshipLink = true, bool serializeRelatedResourceLink = true) - { - SerializeRelationshipLink = serializeRelationshipLink; - SerializeRelatedResourceLink = serializeRelatedResourceLink; - } - } -} diff --git a/JSONAPI/Attributes/RelatedResourceLinkTemplate.cs b/JSONAPI/Attributes/RelatedResourceLinkTemplate.cs deleted file mode 100644 index ce6d2742..00000000 --- a/JSONAPI/Attributes/RelatedResourceLinkTemplate.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; - -namespace JSONAPI.Attributes -{ - /// - /// This attribute should be added to a property to override DefaultLinkConventions's default - /// behavior for generating a relationship link template. The string "{1}" will be replaced - /// by the ID of the resource that owns the relationship. - /// - [AttributeUsage(AttributeTargets.Property)] - public class RelatedResourceLinkTemplate : Attribute - { - internal string TemplateString; - - /// - /// Creates a new RelatedResourceLinkTemplate. - /// - /// The template - public RelatedResourceLinkTemplate(string linkTemplate) - { - TemplateString = linkTemplate; - } - } -} diff --git a/JSONAPI/Attributes/RelationshipLinkTemplate.cs b/JSONAPI/Attributes/RelationshipLinkTemplate.cs deleted file mode 100644 index 94e74a3c..00000000 --- a/JSONAPI/Attributes/RelationshipLinkTemplate.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; - -namespace JSONAPI.Attributes -{ - /// - /// This attribute should be added to a property to override DefaultLinkConventions's default - /// behavior for generating a related resource link template. The string "{1}" will be replaced - /// by the ID of the resource that owns the relationship. - /// - [AttributeUsage(AttributeTargets.Property)] - public class RelationshipLinkTemplate : Attribute - { - internal string TemplateString; - - /// - /// Creates a new RelationshipLinkTemplate. - /// - /// The template - public RelationshipLinkTemplate(string linkTemplate) - { - TemplateString = linkTemplate; - } - } -} \ No newline at end of file diff --git a/JSONAPI/Attributes/SerializeAsComplexAttribute.cs b/JSONAPI/Attributes/SerializeAsComplexAttribute.cs deleted file mode 100644 index eb83a132..00000000 --- a/JSONAPI/Attributes/SerializeAsComplexAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace JSONAPI.Attributes -{ - /// - /// Indicates that the property should be serialized as a complex attribute, instead of a string - /// - [AttributeUsage(AttributeTargets.Property)] - public class SerializeAsComplexAttribute : Attribute - { - } -} diff --git a/JSONAPI/Attributes/UseAsIdAttribute.cs b/JSONAPI/Attributes/UseAsIdAttribute.cs deleted file mode 100644 index 5a0079c3..00000000 --- a/JSONAPI/Attributes/UseAsIdAttribute.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace JSONAPI.Attributes -{ - [System.AttributeUsage(System.AttributeTargets.Property)] - public class UseAsIdAttribute : System.Attribute - { - public UseAsIdAttribute() { } - } -} \ No newline at end of file diff --git a/JSONAPI/Configuration/IResourceTypeConfiguration.cs b/JSONAPI/Configuration/IResourceTypeConfiguration.cs deleted file mode 100644 index 9ee2a8ee..00000000 --- a/JSONAPI/Configuration/IResourceTypeConfiguration.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using JSONAPI.Core; - -namespace JSONAPI.Configuration -{ - /// - /// Results of configuring a resource type - /// - public interface IResourceTypeConfiguration - { - /// - /// The JSON name for this resource type - /// - string ResourceTypeName { get; } - - /// - /// The CLR type corresponding to this resource type - /// - Type ClrType { get; } - - /// - /// The type of document materializer to use for resources of this type - /// - Type DocumentMaterializerType { get; } - - /// - /// A factory to determine the related resource materializer for a given relationship - /// - Func RelatedResourceMaterializerTypeFactory { get; } - - /// - /// Configurations for this type's resources - /// - IDictionary RelationshipConfigurations { get; } - - /// - /// A factory to use to build expressions to filter a collection of resources of this type by ID. - /// - Func FilterByIdExpressionFactory { get; } - - /// - /// A factory to use to build expressions to sort a collection of resources of this type by ID. - /// - Func SortByIdExpressionFactory { get; } - - /// - /// Builds a resource type registration corresponding to this type - /// - /// - IResourceTypeRegistration BuildResourceTypeRegistration(); - } -} \ No newline at end of file diff --git a/JSONAPI/Configuration/IResourceTypeConfigurator.cs b/JSONAPI/Configuration/IResourceTypeConfigurator.cs deleted file mode 100644 index a861bbfe..00000000 --- a/JSONAPI/Configuration/IResourceTypeConfigurator.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Linq.Expressions; -using JSONAPI.Core; -using JSONAPI.Http; - -namespace JSONAPI.Configuration -{ - /// - /// Configuration mechanism for resource types - /// - public interface IResourceTypeConfigurator - { - /// - /// Configures the relationship corresponding to the specified property - /// - void ConfigureRelationship(Expression> property, - Action configurationAction); - - /// - /// Specifies the materializer to use for this resource type - /// - /// - void UseDocumentMaterializer() where TMaterializer : IDocumentMaterializer; - - /// - /// Allows specifying a default materializer for related resources. - /// - /// - void UseDefaultRelatedResourceMaterializer(Func materializerTypeFactory); - - /// - /// Overrides the resource type name from naming conventions - /// - /// - void OverrideDefaultResourceTypeName(string resourceTypeName); - - /// - /// Specifies a function to use build expressions that allow filtering resources of this type by ID - /// - void OverrideDefaultFilterById(Func filterByIdExpressionFactory); - - /// - /// Specifies a function to use build expressions that allow sorting resources of this type by ID - /// - void OverrideDefaultSortById(Func sortByIdExpressionFactory); - - } -} \ No newline at end of file diff --git a/JSONAPI/Configuration/IResourceTypeRelationshipConfiguration.cs b/JSONAPI/Configuration/IResourceTypeRelationshipConfiguration.cs deleted file mode 100644 index ea420fba..00000000 --- a/JSONAPI/Configuration/IResourceTypeRelationshipConfiguration.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using JSONAPI.Http; - -namespace JSONAPI.Configuration -{ - /// - /// Results of configuring a relationship - /// - public interface IResourceTypeRelationshipConfiguration - { - /// - /// The type to use for materializing this relationship - /// - Type MaterializerType { get; } - } -} \ No newline at end of file diff --git a/JSONAPI/Configuration/IResourceTypeRelationshipConfigurator.cs b/JSONAPI/Configuration/IResourceTypeRelationshipConfigurator.cs deleted file mode 100644 index 1d072bfe..00000000 --- a/JSONAPI/Configuration/IResourceTypeRelationshipConfigurator.cs +++ /dev/null @@ -1,15 +0,0 @@ -using JSONAPI.Http; - -namespace JSONAPI.Configuration -{ - /// - /// Configuration mechanism for relationships - /// - public interface IResourceTypeRelationshipConfigurator - { - /// - /// Specify the materializer type to use for this particular relationship - /// - void UseMaterializer() where TMaterializerType : IRelatedResourceDocumentMaterializer; - } -} \ No newline at end of file diff --git a/JSONAPI/Configuration/JsonApiConfiguration.cs b/JSONAPI/Configuration/JsonApiConfiguration.cs deleted file mode 100644 index 27752c1a..00000000 --- a/JSONAPI/Configuration/JsonApiConfiguration.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using System.Collections.Generic; -using JSONAPI.Core; -using JSONAPI.Documents; -using JSONAPI.Http; - -namespace JSONAPI.Configuration -{ - /// - /// Base class for JSON API configuration services - /// - public class JsonApiConfiguration : IJsonApiConfiguration - { - private readonly IResourceTypeRegistrar _resourceTypeRegistrar; - public ILinkConventions LinkConventions { get; private set; } - public IEnumerable ResourceTypeConfigurations { get { return _resourceTypeConfigurations; } } - public IBaseUrlService CustomBaseUrlService { get; set; } - - private readonly IList _resourceTypeConfigurations; - - /// - /// Creates a new JsonApiConfiguration - /// - public JsonApiConfiguration() - : this(new PluralizationService()) - { - } - - /// - /// Creates a new JsonApiConfiguration - /// - public JsonApiConfiguration(IPluralizationService pluralizationService) - : this(new DefaultNamingConventions(pluralizationService)) - { - } - - /// - /// Creates a new JsonApiConfiguration - /// - public JsonApiConfiguration(INamingConventions namingConventions) - : this(new ResourceTypeRegistrar(namingConventions)) - { - } - - /// - /// Creates a new JsonApiConfiguration - /// - public JsonApiConfiguration(IResourceTypeRegistrar resourceTypeRegistrar) - { - _resourceTypeRegistrar = resourceTypeRegistrar; - if (resourceTypeRegistrar == null) throw new ArgumentNullException("resourceTypeRegistrar"); - - _resourceTypeConfigurations = new List(); - LinkConventions = new DefaultLinkConventions(); - } - - /// - /// Registers a resource type with the configuration - /// - public void RegisterResourceType(Action> configurationAction = null) - { - var configuration = new ResourceTypeConfiguration(_resourceTypeRegistrar); - if (configurationAction != null) - configurationAction(configuration); - _resourceTypeConfigurations.Add(configuration); - } - - /// - /// Registers an entity type/resource type pair for use with MappedDocumentMaterializer /> - /// - public void RegisterMappedType(Action> configurationAction = null) - where TMaterializer : MappedDocumentMaterializer - where TResourceType : class - { - RegisterResourceType(c => - { - c.UseDocumentMaterializer(); - if (configurationAction != null) - configurationAction(c); - }); - } - - /// - /// Allows overriding how links will be formatted. - /// - /// - public void OverrideLinkConventions(ILinkConventions linkConventions) - { - LinkConventions = linkConventions; - } - } - - /// - /// Configuration interface for JSON API - /// - public interface IJsonApiConfiguration - { - /// - /// Conventions for serializing links with resource objects - /// - ILinkConventions LinkConventions { get; } - - /// - /// A set of resource type configurations. These configurations will be converted into IResourceTypeRegistrations - /// by the ResourceTypeRegistrar - /// - IEnumerable ResourceTypeConfigurations { get; } - - /// - /// A custom configured - /// - IBaseUrlService CustomBaseUrlService { get; } - } -} diff --git a/JSONAPI/Configuration/JsonApiHttpConfiguration.cs b/JSONAPI/Configuration/JsonApiHttpConfiguration.cs deleted file mode 100644 index 4451eda8..00000000 --- a/JSONAPI/Configuration/JsonApiHttpConfiguration.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Web.Http; -using JSONAPI.ActionFilters; -using JSONAPI.Json; - -namespace JSONAPI.Configuration -{ - /// - /// Configures an HttpConfiguration object for use with JSONAPI.NET - /// - public class JsonApiHttpConfiguration - { - private readonly JsonApiFormatter _formatter; - private readonly FallbackDocumentBuilderAttribute _fallbackDocumentBuilderAttribute; - private readonly JsonApiExceptionFilterAttribute _jsonApiExceptionFilterAttribute; - - /// - /// Creates a new configuration - /// - public JsonApiHttpConfiguration(JsonApiFormatter formatter, - FallbackDocumentBuilderAttribute fallbackDocumentBuilderAttribute, - JsonApiExceptionFilterAttribute jsonApiExceptionFilterAttribute) - { - if (formatter == null) throw new ArgumentNullException("formatter"); - if (fallbackDocumentBuilderAttribute == null) throw new ArgumentNullException("fallbackDocumentBuilderAttribute"); - if (jsonApiExceptionFilterAttribute == null) throw new ArgumentNullException("jsonApiExceptionFilterAttribute"); - - _formatter = formatter; - _fallbackDocumentBuilderAttribute = fallbackDocumentBuilderAttribute; - _jsonApiExceptionFilterAttribute = jsonApiExceptionFilterAttribute; - } - - /// - /// Applies the running configuration to an HttpConfiguration instance - /// - /// The HttpConfiguration to apply this JsonApiHttpConfiguration to - /// configuration holding BaseUrlService wich could provide a context path. - public void Apply(HttpConfiguration httpConfig, IJsonApiConfiguration jsonApiConfiguration) - { - httpConfig.Formatters.Clear(); - httpConfig.Formatters.Add(_formatter); - - httpConfig.Filters.Add(_fallbackDocumentBuilderAttribute); - httpConfig.Filters.Add(_jsonApiExceptionFilterAttribute); - - var contextPath = jsonApiConfiguration.CustomBaseUrlService?.GetContextPath(); - if (contextPath != null && !contextPath.Equals(string.Empty)) - { - contextPath += "/"; - } - - // Web API routes - httpConfig.Routes.MapHttpRoute("ResourceCollection", contextPath + "{resourceType}", new { controller = "Main" }); - httpConfig.Routes.MapHttpRoute("Resource", contextPath + "{resourceType}/{id}", new { controller = "Main" }); - httpConfig.Routes.MapHttpRoute("RelatedResource", contextPath + "{resourceType}/{id}/{relationshipName}", new { controller = "Main" }); - } - } -} diff --git a/JSONAPI/Configuration/ResourceTypeConfiguration.cs b/JSONAPI/Configuration/ResourceTypeConfiguration.cs deleted file mode 100644 index 5bc0cc14..00000000 --- a/JSONAPI/Configuration/ResourceTypeConfiguration.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Reflection; -using JSONAPI.Core; -using JSONAPI.Http; - -namespace JSONAPI.Configuration -{ - /// - /// Configuration mechanism for resource types. - /// - /// - public sealed class ResourceTypeConfiguration : IResourceTypeConfigurator, IResourceTypeConfiguration - { - private readonly IResourceTypeRegistrar _resourceTypeRegistrar; - - internal ResourceTypeConfiguration(IResourceTypeRegistrar resourceTypeRegistrar) - { - _resourceTypeRegistrar = resourceTypeRegistrar; - RelationshipConfigurations = new ConcurrentDictionary(); - ClrType = typeof (TResourceType); - } - - public string ResourceTypeName { get; private set; } - public Type ClrType { get; private set; } - public Type DocumentMaterializerType { get; private set; } - public Func RelatedResourceMaterializerTypeFactory { get; private set; } - public IDictionary RelationshipConfigurations { get; private set; } - public Func FilterByIdExpressionFactory { get; private set; } - public Func SortByIdExpressionFactory { get; private set; } - - public void ConfigureRelationship(Expression> property, - Action configurationAction) - { - if (property == null) throw new ArgumentNullException("property"); - if (configurationAction == null) throw new ArgumentNullException("configurationAction"); - - var member = (MemberExpression) property.Body; - var propertyInfo = (PropertyInfo) member.Member; - - var config = new ResourceTypeRelationshipConfiguration(); - configurationAction(config); - - RelationshipConfigurations[propertyInfo.Name] = config; - } - - public void UseDocumentMaterializer() - where TMaterializer : IDocumentMaterializer - { - DocumentMaterializerType = typeof (TMaterializer); - } - - public void UseDefaultRelatedResourceMaterializer(Func materializerTypeFactory) - { - RelatedResourceMaterializerTypeFactory = materializerTypeFactory; - } - - public void OverrideDefaultResourceTypeName(string resourceTypeName) - { - ResourceTypeName = resourceTypeName; - } - - public void OverrideDefaultFilterById(Func filterByIdExpressionFactory) - { - FilterByIdExpressionFactory = filterByIdExpressionFactory; - } - - public void OverrideDefaultSortById(Func sortByIdExpressionFactory) - { - SortByIdExpressionFactory = sortByIdExpressionFactory; - } - - public IResourceTypeRegistration BuildResourceTypeRegistration() - { - return _resourceTypeRegistrar.BuildRegistration(ClrType, ResourceTypeName, FilterByIdExpressionFactory, - SortByIdExpressionFactory); - } - } -} \ No newline at end of file diff --git a/JSONAPI/Configuration/ResourceTypeRelationshipConfiguration.cs b/JSONAPI/Configuration/ResourceTypeRelationshipConfiguration.cs deleted file mode 100644 index 3998a6a2..00000000 --- a/JSONAPI/Configuration/ResourceTypeRelationshipConfiguration.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using JSONAPI.Http; - -namespace JSONAPI.Configuration -{ - /// - /// Allows configuring a relationship - /// - public sealed class ResourceTypeRelationshipConfiguration : IResourceTypeRelationshipConfiguration, IResourceTypeRelationshipConfigurator - { - internal ResourceTypeRelationshipConfiguration() - { - } - - public Type MaterializerType { get; private set; } - - public void UseMaterializer() - where TMaterializerType : IRelatedResourceDocumentMaterializer - { - MaterializerType = typeof (TMaterializerType); - } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/ComplexAttributeValueConverter.cs b/JSONAPI/Core/ComplexAttributeValueConverter.cs deleted file mode 100644 index e26726d0..00000000 --- a/JSONAPI/Core/ComplexAttributeValueConverter.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Core -{ - /// - /// Implementation of suitable for - /// use with complex attributes that deserialize to strings. - /// - public class ComplexAttributeValueConverter : IAttributeValueConverter - { - private readonly PropertyInfo _property; - - /// - /// Creates a new ComplexAttributeValueConverter - /// - /// - public ComplexAttributeValueConverter(PropertyInfo property) - { - _property = property; - } - - public JToken GetValue(object resource) - { - var value = _property.GetValue(resource); - if (value == null) return null; - return JToken.Parse(value.ToString()); - } - - public void SetValue(object resource, JToken value) - { - var serializedValue = value.ToString(); // TODO: this won't work if this converter is used for non-string properties - _property.SetValue(resource, serializedValue); - } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/DateTimeAttributeValueConverter.cs b/JSONAPI/Core/DateTimeAttributeValueConverter.cs deleted file mode 100644 index 94550d07..00000000 --- a/JSONAPI/Core/DateTimeAttributeValueConverter.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Reflection; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Core -{ - /// - /// Implementation of suitable for - /// use converting between DateTime CLR properties and ISO8601 string values. - /// - public class DateTimeAttributeValueConverter : IAttributeValueConverter - { - private readonly PropertyInfo _property; - private readonly bool _isNullable; - - /// - /// Creates a new DateTimeAttributeValueConverter - /// - /// - /// - public DateTimeAttributeValueConverter(PropertyInfo property, bool isNullable) - { - _property = property; - _isNullable = isNullable; - } - - public JToken GetValue(object resource) - { - var value = _property.GetValue(resource); - if (value != null) return ((DateTime) value).ToString("s"); - if (_isNullable) return null; - return "0001-01-01"; - } - - public void SetValue(object resource, JToken value) - { - if (value == null || value.Type == JTokenType.Null) - { - _property.SetValue(resource, _isNullable ? (DateTime?)null : new DateTime()); - } - else - { - var dateTimeValue = value.Value(); - if (dateTimeValue.Kind == DateTimeKind.Local) dateTimeValue = dateTimeValue.ToUniversalTime(); - _property.SetValue(resource, dateTimeValue); - } - } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/DateTimeOffsetAttributeValueConverter.cs b/JSONAPI/Core/DateTimeOffsetAttributeValueConverter.cs deleted file mode 100644 index 82eac86f..00000000 --- a/JSONAPI/Core/DateTimeOffsetAttributeValueConverter.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Reflection; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Core -{ - /// - /// Implementation of suitable for - /// use converting between DateTimeOffset CLR properties and ISO8601 string values. - /// - public class DateTimeOffsetAttributeValueConverter : IAttributeValueConverter - { - private readonly PropertyInfo _property; - private readonly bool _isNullable; - - /// - /// Creates a new DateTimeOffsetAttributeValueConverter - /// - /// - /// - public DateTimeOffsetAttributeValueConverter(PropertyInfo property, bool isNullable) - { - _property = property; - _isNullable = isNullable; - } - - public JToken GetValue(object resource) - { - var value = _property.GetValue(resource); - if (value != null) return ((DateTimeOffset)value).ToString("o"); - if (_isNullable) return null; - return "0001-01-01T00:00:00Z"; - } - - public void SetValue(object resource, JToken value) - { - if (value == null || value.Type == JTokenType.Null) - { - _property.SetValue(resource, _isNullable ? (DateTimeOffset?)null : new DateTimeOffset()); - } - else - { - var stringValue = value.Value(); - var dateTimeOffsetValue = DateTimeOffset.Parse(stringValue); - _property.SetValue(resource, dateTimeOffsetValue); - } - } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/DecimalAttributeValueConverter.cs b/JSONAPI/Core/DecimalAttributeValueConverter.cs deleted file mode 100644 index c15c7477..00000000 --- a/JSONAPI/Core/DecimalAttributeValueConverter.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Globalization; -using System.Reflection; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Core -{ - /// - /// Implementation of suitable for - /// use converting between decimal CLR properties and string attributes. - /// - public class DecimalAttributeValueConverter : IAttributeValueConverter - { - private readonly PropertyInfo _property; - - /// - /// Creates a new DecimalAttributeValueConverter - /// - /// - public DecimalAttributeValueConverter(PropertyInfo property) - { - _property = property; - } - - public JToken GetValue(object resource) - { - var value = _property.GetValue(resource); - if (value == null) return null; - try - { - return ((Decimal)value).ToString(CultureInfo.InvariantCulture); - } - catch (InvalidCastException e) - { - throw new JsonSerializationException("Could not serialize decimal value.", e); - } - } - - public void SetValue(object resource, JToken value) - { - if (value == null || value.Type == JTokenType.Null) - _property.SetValue(resource, null); - else - { - var stringTokenValue = value.Value(); - Decimal d; - if (!Decimal.TryParse(stringTokenValue, NumberStyles.Any, CultureInfo.InvariantCulture, out d)) - throw new JsonSerializationException("Could not parse decimal value."); - _property.SetValue(resource, d); - } - } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/DefaultEphemeralRelatedResourceCreator.cs b/JSONAPI/Core/DefaultEphemeralRelatedResourceCreator.cs deleted file mode 100644 index 7eb6f419..00000000 --- a/JSONAPI/Core/DefaultEphemeralRelatedResourceCreator.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -namespace JSONAPI.Core -{ - /// - /// Default implementation of , using Activator - /// - public class DefaultEphemeralRelatedResourceCreator : IEphemeralRelatedResourceCreator - { - /// - public object CreateEphemeralResource(IResourceTypeRegistration resourceTypeRegistration, string id) - { - var obj = Activator.CreateInstance(resourceTypeRegistration.Type); - resourceTypeRegistration.SetIdForResource(obj, id); - return obj; - } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/DefaultNamingConventions.cs b/JSONAPI/Core/DefaultNamingConventions.cs deleted file mode 100644 index b2b4f3f4..00000000 --- a/JSONAPI/Core/DefaultNamingConventions.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Linq; -using System.Reflection; -using JSONAPI.Extensions; -using Newtonsoft.Json; - -namespace JSONAPI.Core -{ - /// - /// Default implementation of INamingConventions - /// - public class DefaultNamingConventions : INamingConventions - { - private readonly IPluralizationService _pluralizationService; - - /// - /// Creates a new DefaultNamingConventions - /// - /// - public DefaultNamingConventions(IPluralizationService pluralizationService) - { - _pluralizationService = pluralizationService; - } - - /// - /// This method first checks if the property has a [JsonProperty] attribute. If so, - /// it uses the attribute's PropertyName. Otherwise, it falls back to taking the - /// property's name, and dasherizing it. - /// - /// - /// - public virtual string GetFieldNameForProperty(PropertyInfo property) - { - var jsonPropertyAttribute = (JsonPropertyAttribute)property.GetCustomAttributes(typeof(JsonPropertyAttribute)).FirstOrDefault(); - return jsonPropertyAttribute != null ? jsonPropertyAttribute.PropertyName : property.Name.Dasherize(); - } - - /// - /// This method first checks if the type has a [JsonObject] attribute. If so, - /// it uses the attribute's Title. Otherwise it falls back to pluralizing the - /// type's name using the given and then - /// dasherizing that value. - /// - /// - /// - public virtual string GetResourceTypeNameForType(Type type) - { - var jsonObjectAttribute = type.GetCustomAttributes().OfType().FirstOrDefault(); - - string title = null; - if (jsonObjectAttribute != null) - { - title = jsonObjectAttribute.Title; - } - - if (string.IsNullOrEmpty(title)) - { - title = GetNameForType(type); - } - - return _pluralizationService.Pluralize(title).Dasherize(); - } - - /// - /// Gets the name for a CLR type. - /// - protected virtual string GetNameForType(Type type) - { - return type.Name; - } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/EnumAttributeValueConverter.cs b/JSONAPI/Core/EnumAttributeValueConverter.cs deleted file mode 100644 index fd893adc..00000000 --- a/JSONAPI/Core/EnumAttributeValueConverter.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Reflection; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Core -{ - /// - /// Implementation of suitable for - /// use converting between enum CLR properties and integer attributes. - /// - public class EnumAttributeValueConverter : IAttributeValueConverter - { - private readonly PropertyInfo _property; - private readonly Type _enumType; - private readonly bool _isNullable; - - /// - /// Creates a new EnumAttributeValueConverter - /// - /// - /// - /// - public EnumAttributeValueConverter(PropertyInfo property, Type enumType, bool isNullable) - { - _property = property; - _enumType = enumType; - _isNullable = isNullable; - } - - public JToken GetValue(object resource) - { - var value = _property.GetValue(resource); - if (value != null) return Convert.ToInt64(value); - if (_isNullable) return null; - return 0; - } - - public void SetValue(object resource, JToken value) - { - if (value == null || value.Type == JTokenType.Null) - { - if (_isNullable) - _property.SetValue(resource, null); - else - { - var enumValue = Enum.Parse(_enumType, "0"); - _property.SetValue(resource, enumValue); - } - } - else - { - var enumValue = Enum.Parse(_enumType, value.ToString()); - _property.SetValue(resource, enumValue); - } - } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/EphemeralRelatedResourceReader.cs b/JSONAPI/Core/EphemeralRelatedResourceReader.cs deleted file mode 100644 index 7f40ef7f..00000000 --- a/JSONAPI/Core/EphemeralRelatedResourceReader.cs +++ /dev/null @@ -1,146 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using JSONAPI.Documents; -using JSONAPI.Json; - -namespace JSONAPI.Core -{ - /// - /// Populates property values on an ephemeral resource - /// - /// - [Obsolete] - public class EphemeralRelatedResourceReader : IEphemeralRelatedResourceReader - { - private readonly IEphemeralRelatedResourceReader _ephemeralRelatedResourceReader; - - /// - /// Creates a new EphemeralRelatedResourceReader - /// - /// - public EphemeralRelatedResourceReader(IEphemeralRelatedResourceReader ephemeralRelatedResourceReader) - { - _ephemeralRelatedResourceReader = ephemeralRelatedResourceReader; - } - - public void SetProperty(T ephemeralResource, string jsonKey, IRelationshipObject relationshipObject) - { - _ephemeralRelatedResourceReader.SetProperty(ephemeralResource, jsonKey, relationshipObject); - } - } - - /// - /// Populates property values on an ephemeral resource - /// - /// - public class EphemeralRelatedResourceReader : IEphemeralRelatedResourceReader - { - private readonly IResourceTypeRegistry _resourceTypeRegistry; - private readonly IEphemeralRelatedResourceCreator _ephemeralRelatedResourceCreator; - private readonly MethodInfo _openSetToManyRelationshipValueMethod; - - /// - /// Creates a new EphemeralRelatedResourceReader - /// - /// - /// - public EphemeralRelatedResourceReader(IResourceTypeRegistry resourceTypeRegistry, IEphemeralRelatedResourceCreator ephemeralRelatedResourceCreator) - { - _resourceTypeRegistry = resourceTypeRegistry; - _ephemeralRelatedResourceCreator = ephemeralRelatedResourceCreator; - _openSetToManyRelationshipValueMethod = GetType() - .GetMethod("SetToManyRelationshipValue", BindingFlags.NonPublic | BindingFlags.Instance); - } - - public void SetProperty(T ephemeralResource, string jsonKey, IRelationshipObject relationshipObject) - { - var resourceTypeRegistration = new Lazy(() => _resourceTypeRegistry.GetRegistrationForType(typeof(T))); - var relationship = resourceTypeRegistration.Value.GetFieldByName(jsonKey) as ResourceTypeRelationship; - if (relationship == null) return; - - if (relationship.IsToMany) - SetPropertyForToManyRelationship(ephemeralResource, relationship, relationshipObject.Linkage); - else - SetPropertyForToOneRelationship(ephemeralResource, relationship, relationshipObject.Linkage); - } - - protected virtual void SetPropertyForToOneRelationship(T ephemeralResource, ResourceTypeRelationship relationship, IResourceLinkage linkage) - { - if (linkage == null) - throw new DeserializationException("Missing linkage for to-one relationship", - "Expected an object for to-one linkage, but no linkage was specified.", $"/data/relationships/{relationship.JsonKey}"); - - if (linkage.IsToMany) - throw new DeserializationException("Invalid linkage for to-one relationship", - "Expected an object or null for to-one linkage", - $"/data/relationships/{relationship.JsonKey}/data"); - - var identifier = linkage.Identifiers.FirstOrDefault(); - if (identifier == null) - { - relationship.Property.SetValue(ephemeralResource, null); - } - else - { - var relatedObjectRegistration = _resourceTypeRegistry.GetRegistrationForResourceTypeName(identifier.Type); - var relatedObject = _ephemeralRelatedResourceCreator.CreateEphemeralResource(relatedObjectRegistration, identifier.Id); - - relationship.Property.SetValue(ephemeralResource, relatedObject); - } - } - - protected virtual void SetPropertyForToManyRelationship(T ephemeralResource, ResourceTypeRelationship relationship, - IResourceLinkage linkage) - { - if (linkage == null) - throw new DeserializationException("Missing linkage for to-many relationship", - "Expected an array for to-many linkage, but no linkage was specified.", $"/data/relationships/{relationship.JsonKey}"); - - if (!linkage.IsToMany) - throw new DeserializationException("Invalid linkage for to-many relationship", - "Expected an array for to-many linkage.", - $"/data/relationships/{relationship.JsonKey}/data"); - - var newCollection = (from resourceIdentifier in linkage.Identifiers - let relatedObjectRegistration = _resourceTypeRegistry.GetRegistrationForResourceTypeName(resourceIdentifier.Type) - select _ephemeralRelatedResourceCreator.CreateEphemeralResource(relatedObjectRegistration, resourceIdentifier.Id)).ToList(); - - var method = _openSetToManyRelationshipValueMethod.MakeGenericMethod(relationship.RelatedType); - method.Invoke(this, new object[] { ephemeralResource, newCollection, relationship }); - } - - /// - /// Sets the value of a to-many relationship - /// - protected void SetToManyRelationshipValue(object material, IEnumerable relatedObjects, ResourceTypeRelationship relationship) - { - var currentValue = relationship.Property.GetValue(material); - var typedArray = relatedObjects.Select(o => (TRelated)o).ToArray(); - if (relationship.Property.PropertyType.IsAssignableFrom(typeof(List))) - { - if (currentValue == null) - { - relationship.Property.SetValue(material, typedArray.ToList()); - } - else - { - var listCurrentValue = (ICollection)currentValue; - var itemsToAdd = typedArray.Except(listCurrentValue); - var itemsToRemove = listCurrentValue.Except(typedArray).ToList(); - - foreach (var related in itemsToAdd) - listCurrentValue.Add(related); - - foreach (var related in itemsToRemove) - listCurrentValue.Remove(related); - } - } - else - { - relationship.Property.SetValue(material, typedArray); - } - } - } -} diff --git a/JSONAPI/Core/GuidAttributeValueConverter.cs b/JSONAPI/Core/GuidAttributeValueConverter.cs deleted file mode 100644 index b6d6f2d5..00000000 --- a/JSONAPI/Core/GuidAttributeValueConverter.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Reflection; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Core -{ - /// - /// Implementation of suitable for - /// use converting between Guid CLR properties and string attributes. - /// - public class GuidAttributeValueConverter : IAttributeValueConverter - { - private readonly PropertyInfo _property; - private readonly bool _isNullable; - - /// - /// Creates a new GuidAttributeValueConverter - /// - /// - /// - public GuidAttributeValueConverter(PropertyInfo property, bool isNullable) - { - _property = property; - _isNullable = isNullable; - } - - public JToken GetValue(object resource) - { - var value = _property.GetValue(resource); - if (value == null) - { - if (_isNullable) return null; - value = new Guid(); - } - return value.ToString(); - } - - public void SetValue(object resource, JToken value) - { - if (value == null) - { - _property.SetValue(resource, _isNullable ? (Guid?)null : new Guid()); - } - else - { - var stringTokenValue = value.Value(); - var guidValue = new Guid(stringTokenValue); - _property.SetValue(resource, guidValue); - } - } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/IAttributeValueConverter.cs b/JSONAPI/Core/IAttributeValueConverter.cs deleted file mode 100644 index 79c47648..00000000 --- a/JSONAPI/Core/IAttributeValueConverter.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Core -{ - /// - /// Provides services for interacting with JSON API attributes - /// - public interface IAttributeValueConverter - { - /// - /// Gets the json-formatted value of this attribute for the given resource - /// - /// - /// - JToken GetValue(object resource); - - /// - /// Sets the value of this attribute for the resource - /// - /// - /// - void SetValue(object resource, JToken value); - } -} \ No newline at end of file diff --git a/JSONAPI/Core/IEphemeralRelatedResourceCreator.cs b/JSONAPI/Core/IEphemeralRelatedResourceCreator.cs deleted file mode 100644 index 5fdc47c5..00000000 --- a/JSONAPI/Core/IEphemeralRelatedResourceCreator.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace JSONAPI.Core -{ - /// - /// Service for creating an instance of a registered resource type - /// - public interface IEphemeralRelatedResourceCreator - { - /// - /// Creates an instance of the specified resource type, with the given ID - /// - /// The type to create the instance for - /// The ID for the resource - /// A new instance of the specified resource type - object CreateEphemeralResource(IResourceTypeRegistration resourceTypeRegistration, string id); - } -} \ No newline at end of file diff --git a/JSONAPI/Core/IEphemeralRelatedResourceReader.cs b/JSONAPI/Core/IEphemeralRelatedResourceReader.cs deleted file mode 100644 index 95a8fade..00000000 --- a/JSONAPI/Core/IEphemeralRelatedResourceReader.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using JSONAPI.Documents; - -namespace JSONAPI.Core -{ - /// - /// Populates property values on an ephemeral resource from a relationship object - /// - /// - [Obsolete] - public interface IEphemeralRelatedResourceReader - { - /// - /// Sets the property on the ephemeral resource that corresponds to the given property - /// - /// - /// - /// - void SetProperty(T ephemeralResource, string jsonKey, IRelationshipObject relationshipObject); - } - - /// - /// Populates property values on an ephemeral resource from a relationship object - /// - public interface IEphemeralRelatedResourceReader - { - /// - /// Sets the property on the ephemeral resource that corresponds to the given property - /// - /// - /// - /// - void SetProperty(T ephemeralResource, string jsonKey, IRelationshipObject relationshipObject); - } -} \ No newline at end of file diff --git a/JSONAPI/Core/INamingConventions.cs b/JSONAPI/Core/INamingConventions.cs deleted file mode 100644 index 3866d9d3..00000000 --- a/JSONAPI/Core/INamingConventions.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Reflection; - -namespace JSONAPI.Core -{ - /// - /// Allows configuring how to calculate JSON API keys based on CLR types and properties - /// - public interface INamingConventions - { - /// - /// Calculates the field name for a given property - /// - /// - /// - string GetFieldNameForProperty(PropertyInfo property); - - /// - /// Calculates the resource type name for a CLR type - /// - /// - /// - string GetResourceTypeNameForType(Type type); - } -} \ No newline at end of file diff --git a/JSONAPI/Core/IPluralizationService.cs b/JSONAPI/Core/IPluralizationService.cs deleted file mode 100644 index e31d0e7e..00000000 --- a/JSONAPI/Core/IPluralizationService.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Collections.Generic; - - -namespace JSONAPI.Core -{ - /// - /// A mirror of System.Data.Entity.Infrastructure.Pluralization.IPluralizationService, - /// but redefined here to allow usage without a dependency on Entity Framework. - /// - public interface IPluralizationService - { - /// - /// Return the plural form of a word. This function should be idempotent! (Allowing for the caveat that - /// explicit mappings may be required to make this be true.) - /// - /// The word to pluralize - /// The plural form of the word - string Pluralize(string word); - - /// - /// Return the plural form of a word. This function should be idempotent! (Allowing for the caveat that - /// explicit mappings may be required to make this be true.) - /// - /// The word to singularize - /// The singular form of the word - string Singularize(string word); - } - - /// - /// A horribly naive, default implementation of . - /// If you use this, at least specify mappings extensively! - /// - public class PluralizationService : IPluralizationService - { - private Dictionary s2p; - private Dictionary p2s; - - public PluralizationService() - { - s2p = new Dictionary(); - p2s = new Dictionary(); - } - - public PluralizationService(Dictionary explicitMappings) - { - s2p = new Dictionary(); - p2s = new Dictionary(); - foreach(KeyValuePair pair in explicitMappings) - { - s2p.Add(pair.Key, pair.Value); - p2s.Add(pair.Value, pair.Key); - } - } - - public void AddMapping(string singular, string plural) - { - if (!s2p.ContainsKey(singular) && !p2s.ContainsKey(plural)) - { - s2p.Add(singular, plural); - p2s.Add(plural, singular); - } - else - { - throw new ArgumentException("At least one side of the mapping already exists."); - } - } - - public void RemoveMapping(string singular, string plural) - { - if (s2p.ContainsKey(singular) && p2s.ContainsKey(plural) && s2p[singular] == plural && p2s[plural] == singular) - { - s2p.Remove(singular); - p2s.Remove(plural); - } - else - { - throw new ArgumentException("Specified mapping does not already exist."); - } - } - - public string Pluralize(string word) - { - if (s2p.ContainsKey(word)) return s2p[word]; - if (p2s.ContainsKey(word)) return word; // idempotence! - return word + "s"; - } - public string Singularize(string word) - { - if (p2s.ContainsKey(word)) return p2s[word]; - if (s2p.ContainsKey(word)) return word; // idempotentce! - return word.TrimEnd('s'); - } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/IResourceTypeRegistrar.cs b/JSONAPI/Core/IResourceTypeRegistrar.cs deleted file mode 100644 index c92d3d7c..00000000 --- a/JSONAPI/Core/IResourceTypeRegistrar.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Linq.Expressions; - -namespace JSONAPI.Core -{ - /// - /// Creates resource type registrations based on CLR types - /// - public interface IResourceTypeRegistrar - { - /// - /// Creates a registration for the given CLR type - /// - IResourceTypeRegistration BuildRegistration(Type type, - string resourceTypeName = null, - Func filterByIdFactory = null, - Func sortByIdFactory = null); - } -} \ No newline at end of file diff --git a/JSONAPI/Core/IResourceTypeRegistration.cs b/JSONAPI/Core/IResourceTypeRegistration.cs deleted file mode 100644 index 1c59cbb5..00000000 --- a/JSONAPI/Core/IResourceTypeRegistration.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Linq.Expressions; -using System.Net.Http; -using System.Reflection; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.Documents; -using JSONAPI.Http; - -namespace JSONAPI.Core -{ - /// - /// Represents a registered resource type - /// - public interface IResourceTypeRegistration - { - /// - /// The resource type's runtime type - /// - Type Type { get; } - - /// - /// The property to use to get the ID - /// - PropertyInfo IdProperty { get; } - - /// - /// The JSON API name of the resource type - /// - string ResourceTypeName { get; } - - /// - /// Gets the attribute fields for the resource type - /// - /// - ResourceTypeAttribute[] Attributes { get; } - - /// - /// Gets the relationship fields for the resource type - /// - /// - ResourceTypeRelationship[] Relationships { get; } - - /// - /// Gets the ID for a resource belonging to this resource type - /// - /// - /// - string GetIdForResource(object resource); - - /// - /// Sets the ID for a resource belonging to this resource type - /// - /// - /// - void SetIdForResource(object resource, string id); - - /// - /// Returns an expression that can be used to allow getting an instance of this resource - /// by ID - /// - /// - BinaryExpression GetFilterByIdExpression(ParameterExpression parameter, string id); - - /// - /// Returns an expression that can be used to allow sorting this resource by ID. - /// - /// - Expression GetSortByIdExpression(ParameterExpression parameter); - - /// - /// Gets a field by its JSON API-normalized name - /// - /// - /// - ResourceTypeField GetFieldByName(string name); - } -} \ No newline at end of file diff --git a/JSONAPI/Core/IResourceTypeRegistry.cs b/JSONAPI/Core/IResourceTypeRegistry.cs deleted file mode 100644 index c55177cb..00000000 --- a/JSONAPI/Core/IResourceTypeRegistry.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; - -namespace JSONAPI.Core -{ - /// - /// Manages registrations of this API's resource types. - /// - public interface IResourceTypeRegistry - { - /// - /// Determines whether a given type has been registered. - /// - /// The type - /// Whether the type is registered - bool TypeIsRegistered(Type type); - - /// - /// Gets the registration for the given type. - /// - /// The type to get the registration for - /// The registration for the given type. - /// Thrown when the type was not registered - IResourceTypeRegistration GetRegistrationForType(Type type); - - /// - /// Gets the registration for the given type. - /// - /// The name of the type to get the registration for - /// The registration for the given type name. - /// Thrown when the type name was not registered - IResourceTypeRegistration GetRegistrationForResourceTypeName(string resourceTypeName); - - /// - /// Adds a registration to the registry. - /// - /// The registration to add - void AddRegistration(IResourceTypeRegistration registration); - } -} diff --git a/JSONAPI/Core/ObjectComplexAttributeValueConverter.cs b/JSONAPI/Core/ObjectComplexAttributeValueConverter.cs deleted file mode 100644 index c6c73af0..00000000 --- a/JSONAPI/Core/ObjectComplexAttributeValueConverter.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Reflection; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Core -{ - /// - /// Implementation of suitable for - /// use with complex attributes that deserialize to custom types. - /// - public class ObjectComplexAttributeValueConverter : IAttributeValueConverter - { - private readonly PropertyInfo _property; - private readonly bool _isToMany; - - /// - /// Creates a new ComplexAttributeValueConverter - /// - /// - /// - public ObjectComplexAttributeValueConverter(PropertyInfo property, bool isToMany) - { - _property = property; - _isToMany = isToMany; - } - - public JToken GetValue(object resource) - { - var value = _property.GetValue(resource); - if (value == null) return null; - return _isToMany ? (JToken)JArray.FromObject(value) : JObject.FromObject(value); - } - - public void SetValue(object resource, JToken value) - { - var deserialized = value?.ToObject(_property.PropertyType); - _property.SetValue(resource, deserialized); - } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/PathVisitor.cs b/JSONAPI/Core/PathVisitor.cs deleted file mode 100644 index 74566089..00000000 --- a/JSONAPI/Core/PathVisitor.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Reflection; - -namespace JSONAPI.Core -{ - /// - /// Utility for converting an property expression into a dot-separated path string - /// - public class PathVisitor : ExpressionVisitor - { - private readonly IResourceTypeRegistry _resourceTypeRegistry; - - /// - /// Creates a new PathVisitor - /// - /// - public PathVisitor(IResourceTypeRegistry resourceTypeRegistry) - { - _resourceTypeRegistry = resourceTypeRegistry; - } - - private readonly Stack _segments = new Stack(); - public string Path { get { return string.Join(".", _segments.ToArray()); } } - - protected override Expression VisitMethodCall(MethodCallExpression node) - { - if (node.Method.Name == "Select") - { - Visit(node.Arguments[1]); - Visit(node.Arguments[0]); - } - return node; - } - - protected override Expression VisitMember(MemberExpression node) - { - var property = node.Member as PropertyInfo; - if (property == null) return node; - - var registration = _resourceTypeRegistry.GetRegistrationForType(property.DeclaringType); - if (registration == null || registration.Relationships == null) return node; - - var relationship = registration.Relationships.FirstOrDefault(r => r.Property == property); - if (relationship == null) return node; - - _segments.Push(relationship.JsonKey); - - return base.VisitMember(node); - } - } -} diff --git a/JSONAPI/Core/PrimitiveTypeAttributeValueConverter.cs b/JSONAPI/Core/PrimitiveTypeAttributeValueConverter.cs deleted file mode 100644 index b245ee9e..00000000 --- a/JSONAPI/Core/PrimitiveTypeAttributeValueConverter.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Reflection; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Core -{ - /// - /// Implementation of suitable for - /// primitive types. - /// - public class PrimitiveTypeAttributeValueConverter : IAttributeValueConverter - { - private readonly PropertyInfo _property; - - /// - /// Creates a new PrimitiveTypeAttributeValueConverter - /// - /// - public PrimitiveTypeAttributeValueConverter(PropertyInfo property) - { - _property = property; - } - - public JToken GetValue(object resource) - { - var value = _property.GetValue(resource); - if (value == null) return null; - return JToken.FromObject(value); - } - - public void SetValue(object resource, JToken value) - { - if (value == null) - { - _property.SetValue(resource, null); - } - else - { - var unpackedValue = value.Value(); - _property.SetValue(resource, unpackedValue); - } - } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/ResourceTypeAttribute.cs b/JSONAPI/Core/ResourceTypeAttribute.cs deleted file mode 100644 index 01865b35..00000000 --- a/JSONAPI/Core/ResourceTypeAttribute.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Reflection; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Core -{ - /// - /// A ResourceTypeField representing an attribute on a resource object - /// - public class ResourceTypeAttribute : ResourceTypeField - { - private readonly IAttributeValueConverter _attributeValueConverter; - - internal ResourceTypeAttribute(IAttributeValueConverter attributeValueConverter, PropertyInfo property, string jsonKey) - : base(property, jsonKey) - { - _attributeValueConverter = attributeValueConverter; - } - - /// - /// Gets the json-formatted value of this attribute for the given resource - /// - /// - /// - public JToken GetValue(object resource) - { - return _attributeValueConverter.GetValue(resource); - } - - /// - /// Sets the value of this attribute for the resource - /// - /// - /// - public void SetValue(object resource, JToken value) - { - _attributeValueConverter.SetValue(resource, value); - } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/ResourceTypeField.cs b/JSONAPI/Core/ResourceTypeField.cs deleted file mode 100644 index b54797ec..00000000 --- a/JSONAPI/Core/ResourceTypeField.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Reflection; - -namespace JSONAPI.Core -{ - /// - /// Stores a resource type's field and its usage. - /// - public abstract class ResourceTypeField - { - internal ResourceTypeField(PropertyInfo property, string jsonKey) - { - JsonKey = jsonKey; - Property = property; - } - - /// - /// The PropertyInfo backing this ModelProperty - /// - public PropertyInfo Property { get; private set; } - - /// - /// The key that will be used to represent this property in JSON API documents - /// - public string JsonKey { get; private set; } - } -} diff --git a/JSONAPI/Core/ResourceTypeRegistrar.cs b/JSONAPI/Core/ResourceTypeRegistrar.cs deleted file mode 100644 index bedd6e21..00000000 --- a/JSONAPI/Core/ResourceTypeRegistrar.cs +++ /dev/null @@ -1,207 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Reflection; -using JSONAPI.Attributes; -using JSONAPI.Extensions; -using Newtonsoft.Json; - -namespace JSONAPI.Core -{ - /// - /// Default implementation of - /// - public class ResourceTypeRegistrar : IResourceTypeRegistrar - { - private readonly INamingConventions _namingConventions; - - /// - /// Creates a new - /// - /// Conventions for naming types and fields - public ResourceTypeRegistrar(INamingConventions namingConventions) - { - if (namingConventions == null) throw new ArgumentNullException("namingConventions"); - _namingConventions = namingConventions; - } - - public IResourceTypeRegistration BuildRegistration(Type type, string resourceTypeName = null, - Func filterByIdFactory = null, - Func sortByIdFactory = null) - { - if (resourceTypeName == null) - resourceTypeName = _namingConventions.GetResourceTypeNameForType(type); - - var fieldMap = new Dictionary(); - - var idProperty = CalculateIdProperty(type); - if (idProperty == null) - throw new InvalidOperationException(String.Format( - "Unable to determine Id property for type `{0}`.", type.Name)); - - var props = type.GetProperties().OrderBy(p => p.Name); - foreach (var prop in props) - { - if (prop == idProperty) continue; - - var ignore = prop.CustomAttributes.Any(c => c.AttributeType == typeof (JsonIgnoreAttribute)); - if (ignore) continue; - - var property = CreateResourceTypeField(prop); - var jsonKey = property.JsonKey; - - if (jsonKey == "id") - throw new InvalidOperationException( - String.Format( - "Failed to register type `{0}` because it contains a non-id property that would serialize as \"id\".", - type.Name)); - - if (jsonKey == "type") - throw new InvalidOperationException( - String.Format( - "Failed to register type `{0}` because it contains a property that would serialize as \"type\".", - type.Name)); - - if (fieldMap.ContainsKey(jsonKey)) - throw new InvalidOperationException( - String.Format( - "Failed to register type `{0}` because contains multiple properties that would serialize as `{1}`.", - type.Name, jsonKey)); - - fieldMap[jsonKey] = property; - } - - if (filterByIdFactory == null) - { - filterByIdFactory = (param, id) => - { - var propertyExpr = Expression.Property(param, idProperty); - object obj = id; - if (obj == null) - { - var t = propertyExpr.Type; - if (t.IsValueType) - obj = Activator.CreateInstance(t); - } - var idExpr = Expression.Constant(Convert.ChangeType(obj, propertyExpr.Type)); - return Expression.Equal(propertyExpr, idExpr); - }; - } - - if (sortByIdFactory == null) - { - sortByIdFactory = param => Expression.Property(param, idProperty); - } - - return new ResourceTypeRegistration(type, idProperty, resourceTypeName, fieldMap, filterByIdFactory, - sortByIdFactory); - } - - /// - /// Gets a value converter for the given property - /// - /// - /// - protected virtual IAttributeValueConverter GetValueConverterForProperty(PropertyInfo prop) - { - var serializeAsComplexAttribute = prop.GetCustomAttribute(); - if (serializeAsComplexAttribute != null) - { - if (prop.PropertyType == typeof (string)) - return new ComplexAttributeValueConverter(prop); - - var isToMany = - prop.PropertyType.IsArray || - (prop.PropertyType.GetInterfaces().Contains(typeof(System.Collections.IEnumerable)) && prop.PropertyType.IsGenericType); - return new ObjectComplexAttributeValueConverter(prop, isToMany); - } - - if (prop.PropertyType == typeof(DateTime)) - return new DateTimeAttributeValueConverter(prop, false); - - if (prop.PropertyType == typeof(DateTime?)) - return new DateTimeAttributeValueConverter(prop, true); - - if (prop.PropertyType == typeof(DateTimeOffset)) - return new DateTimeOffsetAttributeValueConverter(prop, false); - - if (prop.PropertyType == typeof(DateTimeOffset?)) - return new DateTimeOffsetAttributeValueConverter(prop, true); - - if (prop.PropertyType == typeof(Decimal) || prop.PropertyType == typeof(Decimal?)) - return new DecimalAttributeValueConverter(prop); - - if (prop.PropertyType == typeof(Guid)) - return new GuidAttributeValueConverter(prop, false); - - if (prop.PropertyType == typeof(Guid?)) - return new GuidAttributeValueConverter(prop, true); - - if (prop.PropertyType.IsEnum) - return new EnumAttributeValueConverter(prop, prop.PropertyType, true); - - Type enumType; - if (prop.PropertyType.IsGenericType && - prop.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>) && - (enumType = prop.PropertyType.GetGenericArguments()[0]).IsEnum) - { - return new EnumAttributeValueConverter(prop, enumType, true); - } - - var closedType = typeof(PrimitiveTypeAttributeValueConverter<>).MakeGenericType(prop.PropertyType); - return (IAttributeValueConverter)Activator.CreateInstance(closedType, prop); - } - - /// - /// Creates a cacheable model field representation from a PropertyInfo - /// - /// The property - /// A model field represenation - protected virtual ResourceTypeField CreateResourceTypeField(PropertyInfo prop) - { - var jsonKey = _namingConventions.GetFieldNameForProperty(prop); - - var type = prop.PropertyType; - - if (prop.PropertyType.CanWriteAsJsonApiAttribute() || prop.GetCustomAttributes().Any()) - { - var converter = GetValueConverterForProperty(prop); - return new ResourceTypeAttribute(converter, prop, jsonKey); - } - - var selfLinkTemplateAttribute = prop.GetCustomAttributes().OfType().FirstOrDefault(); - var selfLinkTemplate = selfLinkTemplateAttribute?.TemplateString; - var relatedResourceLinkTemplateAttribute = prop.GetCustomAttributes().OfType().FirstOrDefault(); - var relatedResourceLinkTemplate = relatedResourceLinkTemplateAttribute?.TemplateString; - - var isToMany = - type.IsArray || - (type.GetInterfaces().Contains(typeof(System.Collections.IEnumerable)) && type.IsGenericType); - - var linkSettingsAttribute = prop.GetCustomAttributes().OfType().FirstOrDefault(); - var serializeRelationshipLink = linkSettingsAttribute == null || linkSettingsAttribute.SerializeRelationshipLink; - var serializeRelatedResourceLink = linkSettingsAttribute == null || linkSettingsAttribute.SerializeRelatedResourceLink; - - if (!isToMany) return new ToOneResourceTypeRelationship(prop, jsonKey, type, selfLinkTemplate, relatedResourceLinkTemplate, - serializeRelationshipLink, serializeRelatedResourceLink); - var relatedType = type.IsGenericType ? type.GetGenericArguments()[0] : type.GetElementType(); - return new ToManyResourceTypeRelationship(prop, jsonKey, relatedType, selfLinkTemplate, relatedResourceLinkTemplate, - serializeRelationshipLink, serializeRelatedResourceLink); - } - - /// - /// Calculates the ID property for a given resource type. - /// - /// The type to use to calculate the ID for - /// The ID property to use for this type - protected virtual PropertyInfo CalculateIdProperty(Type type) - { - return - type - .GetProperties() - .FirstOrDefault(p => p.CustomAttributes.Any(attr => attr.AttributeType == typeof(UseAsIdAttribute))) - ?? type.GetProperty("Id") ?? type.GetProperty("ID"); - } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/ResourceTypeRegistration.cs b/JSONAPI/Core/ResourceTypeRegistration.cs deleted file mode 100644 index ad35ef2f..00000000 --- a/JSONAPI/Core/ResourceTypeRegistration.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Linq.Expressions; -using System.Reflection; - -namespace JSONAPI.Core -{ - /// - /// Represents a type's registration with a registry - /// - public class ResourceTypeRegistration : IResourceTypeRegistration - { - private readonly IReadOnlyDictionary _fields; - private readonly Func _filterByIdExpressionFactory; - private readonly Func _sortByIdExpressionFactory; - - internal ResourceTypeRegistration(Type type, PropertyInfo idProperty, string resourceTypeName, - IDictionary fields, - Func filterByIdExpressionFactory, - Func sortByIdExpressionFactory) - { - if (type == null) throw new ArgumentNullException(nameof(type)); - if (idProperty == null) throw new ArgumentNullException(nameof(idProperty)); - if (resourceTypeName == null) throw new ArgumentNullException(nameof(resourceTypeName)); - IdProperty = idProperty; - Type = type; - ResourceTypeName = resourceTypeName; - _filterByIdExpressionFactory = filterByIdExpressionFactory; - _sortByIdExpressionFactory = sortByIdExpressionFactory; - Attributes = fields.Values.OfType().ToArray(); - Relationships = fields.Values.OfType().ToArray(); - _fields = new ReadOnlyDictionary(fields); - } - - public Type Type { get; private set; } - - public PropertyInfo IdProperty { get; private set; } - - public string ResourceTypeName { get; private set; } - - public ResourceTypeAttribute[] Attributes { get; private set; } - - public ResourceTypeRelationship[] Relationships { get; private set; } - - public string GetIdForResource(object resource) - { - if (resource == null) throw new ArgumentNullException(nameof(resource)); - var resourceId = IdProperty.GetValue(resource); - if (resourceId == null) throw new ArgumentException($"The ID for the provided `{ResourceTypeName}` resource is null."); - return resourceId.ToString(); - } - - public void SetIdForResource(object resource, string id) - { - if (resource == null) throw new ArgumentNullException(nameof(resource)); - IdProperty.SetValue(resource, id); // TODO: handle classes with non-string ID types - } - - public BinaryExpression GetFilterByIdExpression(ParameterExpression parameter, string id) - { - return _filterByIdExpressionFactory(parameter, id); - } - - public Expression GetSortByIdExpression(ParameterExpression parameter) - { - return _sortByIdExpressionFactory(parameter); - } - - public ResourceTypeField GetFieldByName(string name) - { - return _fields.ContainsKey(name) ? _fields[name] : null; - } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/ResourceTypeRegistry.cs b/JSONAPI/Core/ResourceTypeRegistry.cs deleted file mode 100644 index 57c3cbd0..00000000 --- a/JSONAPI/Core/ResourceTypeRegistry.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JSONAPI.Core -{ - /// - /// Default implementation of IModelRegistry - /// - public class ResourceTypeRegistry : IResourceTypeRegistry - { - private readonly IDictionary _registrationsByName; - private readonly IDictionary _registrationsByType; - - /// - /// Creates a new ResourceTypeRegistry - /// - public ResourceTypeRegistry() - { - _registrationsByName = new Dictionary(); - _registrationsByType = new Dictionary(); - } - - public bool TypeIsRegistered(Type type) - { - var registration = FindRegistrationForType(type); - return registration != null; - } - - public IResourceTypeRegistration GetRegistrationForType(Type type) - { - var reg = FindRegistrationForType(type); - if (reg == null) - throw new TypeRegistrationNotFoundException(type); - - return reg; - } - - public IResourceTypeRegistration GetRegistrationForResourceTypeName(string resourceTypeName) - { - lock (_registrationsByName) - { - IResourceTypeRegistration registration; - if (!_registrationsByName.TryGetValue(resourceTypeName, out registration)) - throw new TypeRegistrationNotFoundException(resourceTypeName); - - return registration; - } - } - - public void AddRegistration(IResourceTypeRegistration registration) - { - lock (_registrationsByType) - { - lock (_registrationsByName) - { - if (_registrationsByType.ContainsKey(registration.Type)) - throw new InvalidOperationException(String.Format("The type `{0}` has already been registered.", - registration.Type.FullName)); - - IResourceTypeRegistration existingRegistration; - if (_registrationsByName.TryGetValue(registration.ResourceTypeName, out existingRegistration)) - throw new InvalidOperationException( - String.Format("Could not register `{0} under resource type name `{1}` because `{1}` has already been registered by `{2}`.", - registration.Type.FullName, - registration.ResourceTypeName, - existingRegistration.Type.FullName)); - - _registrationsByType.Add(registration.Type, registration); - _registrationsByName.Add(registration.ResourceTypeName, registration); - } - } - } - - private IResourceTypeRegistration FindRegistrationForType(Type type) - { - lock (_registrationsByType) - { - var currentType = type; - while (currentType != null && currentType != typeof(Object)) - { - IResourceTypeRegistration registration; - if (_registrationsByType.TryGetValue(currentType, out registration)) - return registration; - - // This particular type wasn't registered, but maybe the base type was. - currentType = currentType.BaseType; - } - } - - return null; - } - } -} diff --git a/JSONAPI/Core/ResourceTypeRelationship.cs b/JSONAPI/Core/ResourceTypeRelationship.cs deleted file mode 100644 index 2955d94d..00000000 --- a/JSONAPI/Core/ResourceTypeRelationship.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Reflection; - -namespace JSONAPI.Core -{ - /// - /// A ResourceTypeField representing a relationship to another resource type - /// - public abstract class ResourceTypeRelationship : ResourceTypeField - { - internal ResourceTypeRelationship(PropertyInfo property, string jsonKey, Type relatedType, - string selfLinkTemplate, string relatedResourceLinkTemplate, bool isToMany, - bool serializeRelationshipLink = true, bool serializeRelatedResourceLink = true) - : base(property, jsonKey) - { - RelatedType = relatedType; - SelfLinkTemplate = selfLinkTemplate; - RelatedResourceLinkTemplate = relatedResourceLinkTemplate; - IsToMany = isToMany; - SerializeRelationshipLink = serializeRelationshipLink; - SerializeRelatedResourceLink = serializeRelatedResourceLink; - } - - /// - /// Whether this relationship represents a link to a collection of resources or a single one. - /// - public bool IsToMany { get; private set; } - - /// - /// The type of resource found on the other side of this relationship - /// - public Type RelatedType { get; private set; } - - /// - /// The template for building URLs to access the relationship itself. - /// If the string {1} appears in the template, it will be replaced by the ID of resource this - /// relationship belongs to. - /// - public string SelfLinkTemplate { get; private set; } - - /// - /// The template for building URLs to access the data making up the other side of this relationship. - /// If the string {1} appears in the template, it will be replaced by the ID of resource this - /// relationship belongs to. - /// - public string RelatedResourceLinkTemplate { get; private set; } - - /// - /// Whether to include a link to the relationship URL when serializing relationship objects for - /// this relationship - /// - public bool SerializeRelationshipLink { get; private set; } - - /// - /// Whether to include a link to the related resource URL when serializing relationship objects for - /// this relationship - /// - public bool SerializeRelatedResourceLink { get; private set; } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/ToManyResourceTypeRelationship.cs b/JSONAPI/Core/ToManyResourceTypeRelationship.cs deleted file mode 100644 index 0337ed85..00000000 --- a/JSONAPI/Core/ToManyResourceTypeRelationship.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Reflection; - -namespace JSONAPI.Core -{ - /// - /// A ModelProperty representing a relationship to a collection of resources - /// - public sealed class ToManyResourceTypeRelationship : ResourceTypeRelationship - { - internal ToManyResourceTypeRelationship(PropertyInfo property, string jsonKey, Type relatedType, - string selfLinkTemplate, string relatedResourceLinkTemplate, bool serializeRelationshipLink = true, bool serializeRelatedResourceLink = true) - : base(property, jsonKey, relatedType, selfLinkTemplate, relatedResourceLinkTemplate, true, serializeRelationshipLink, serializeRelatedResourceLink) - { - } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/ToOneResourceTypeRelationship.cs b/JSONAPI/Core/ToOneResourceTypeRelationship.cs deleted file mode 100644 index 25d148c8..00000000 --- a/JSONAPI/Core/ToOneResourceTypeRelationship.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Reflection; - -namespace JSONAPI.Core -{ - /// - /// A ModelProperty representing a relationship to a single resource - /// - public sealed class ToOneResourceTypeRelationship : ResourceTypeRelationship - { - internal ToOneResourceTypeRelationship(PropertyInfo property, string jsonKey, Type relatedType, - string selfLinkTemplate, string relatedResourceLinkTemplate, bool serializeRelationshipLink = true, bool serializeRelatedResourceLink = true) - : base(property, jsonKey, relatedType, selfLinkTemplate, relatedResourceLinkTemplate, false, serializeRelationshipLink, serializeRelatedResourceLink) - { - } - } -} \ No newline at end of file diff --git a/JSONAPI/Core/TypeRegistrationNotFoundException.cs b/JSONAPI/Core/TypeRegistrationNotFoundException.cs deleted file mode 100644 index 56c37c01..00000000 --- a/JSONAPI/Core/TypeRegistrationNotFoundException.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; - -namespace JSONAPI.Core -{ - /// - /// Exception thrown when a model is looked up for a type that has not been registred - /// - public class TypeRegistrationNotFoundException : Exception - { - /// - /// Creates a ModelRegistrationNotFoundException for a type lookup failure - /// - /// - public TypeRegistrationNotFoundException(Type type) - : base("No type registration was found for the type \"" + type.Name + "\".") - { - } - - /// - /// Creates a ModelRegistrationNotFoundException for a resource type name lookup failure - /// - /// - public TypeRegistrationNotFoundException(string resourceTypeName) - : base("No type registration was found for the type name \"" + resourceTypeName + "\".") - { - } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/Builders/DefaultQueryableResourceCollectionDocumentBuilder.cs b/JSONAPI/Documents/Builders/DefaultQueryableResourceCollectionDocumentBuilder.cs deleted file mode 100644 index d0488b1c..00000000 --- a/JSONAPI/Documents/Builders/DefaultQueryableResourceCollectionDocumentBuilder.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System.Linq; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.Http; -using JSONAPI.QueryableTransformers; - -namespace JSONAPI.Documents.Builders -{ - /// - /// Provides a default implementation of an IQueryableResourceCollectionDocumentBuilder - /// - public class DefaultQueryableResourceCollectionDocumentBuilder : IQueryableResourceCollectionDocumentBuilder - { - private readonly IResourceCollectionDocumentBuilder _resourceCollectionDocumentBuilder; - private readonly IQueryableEnumerationTransformer _enumerationTransformer; - private readonly IQueryableFilteringTransformer _filteringTransformer; - private readonly IQueryableSortingTransformer _sortingTransformer; - private readonly IQueryablePaginationTransformer _paginationTransformer; - private readonly IBaseUrlService _baseUrlService; - - /// - /// Creates a new DefaultQueryableResourceCollectionDocumentBuilder - /// - public DefaultQueryableResourceCollectionDocumentBuilder( - IResourceCollectionDocumentBuilder resourceCollectionDocumentBuilder, - IQueryableEnumerationTransformer enumerationTransformer, - IQueryableFilteringTransformer filteringTransformer, - IQueryableSortingTransformer sortingTransformer, - IQueryablePaginationTransformer paginationTransformer, - IBaseUrlService baseUrlService) - { - _resourceCollectionDocumentBuilder = resourceCollectionDocumentBuilder; - _enumerationTransformer = enumerationTransformer; - _filteringTransformer = filteringTransformer; - _sortingTransformer = sortingTransformer; - _paginationTransformer = paginationTransformer; - _baseUrlService = baseUrlService; - } - - public async Task BuildDocument(IQueryable query, HttpRequestMessage request, string[] sortExpressions, CancellationToken cancellationToken, - string[] includes = null) - { - var filteredQuery = _filteringTransformer.Filter(query, request); - var sortedQuery = _sortingTransformer.Sort(filteredQuery, sortExpressions); - - var paginationResults = _paginationTransformer.ApplyPagination(sortedQuery, request); - var paginatedQuery = paginationResults.PagedQuery; - - var linkBaseUrl = _baseUrlService.GetBaseUrl(request); - - var results = await _enumerationTransformer.Enumerate(paginatedQuery, cancellationToken); - var metadata = await GetDocumentMetadata(query, filteredQuery, sortedQuery, paginationResults, cancellationToken); - return _resourceCollectionDocumentBuilder.BuildDocument(results, linkBaseUrl, includes, metadata, null); - } - - /// - /// Returns the metadata that should be sent with this document. - /// - protected virtual Task GetDocumentMetadata(IQueryable originalQuery, IQueryable filteredQuery, IOrderedQueryable sortedQuery, - IPaginationTransformResult paginationResult, CancellationToken cancellationToken) - { - return Task.FromResult((IMetadata) null); - } - } -} diff --git a/JSONAPI/Documents/Builders/ErrorDocumentBuilder.cs b/JSONAPI/Documents/Builders/ErrorDocumentBuilder.cs deleted file mode 100644 index aead058c..00000000 --- a/JSONAPI/Documents/Builders/ErrorDocumentBuilder.cs +++ /dev/null @@ -1,153 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net; -using System.Web.Http; -using JSONAPI.Json; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Documents.Builders -{ - /// - /// Default implementation of IErrorDocumentBuilder - /// - public class ErrorDocumentBuilder : IErrorDocumentBuilder - { - private readonly IDictionary> _specificExceptionHandlers; - - /// - /// Creates a new ErrorDocumentBuilder - /// - public ErrorDocumentBuilder() - { - _specificExceptionHandlers = new Dictionary>(); - _specificExceptionHandlers[typeof(JsonApiException)] = GetErrorForJsonApiException; - _specificExceptionHandlers[typeof(DeserializationException)] = GetErrorForDeserializationException; - } - - public IErrorDocument BuildFromException(Exception exception) - { - var error = BuildErrorForException(exception); - - var topLevelMetadata = GetTopLevelMetadata(); - return new ErrorDocument(new [] { error }, topLevelMetadata); - } - - public IErrorDocument BuildFromHttpError(HttpError httpError, HttpStatusCode statusCode) - { - var error = new Error - { - Id = Guid.NewGuid().ToString(), - Title = "An HttpError was returned.", - Detail = httpError.Message, - Status = statusCode, - Metadata = GetHttpErrorMetadata(httpError) - }; - - - var topLevelMetadata = GetTopLevelMetadata(); - return new ErrorDocument(new[] { (IError)error }, topLevelMetadata); - } - - /// - /// Builds an error object for a given exception. - /// - /// - /// - protected virtual IError BuildErrorForException(Exception exception) - { - foreach (var specificExceptionHandler in _specificExceptionHandlers) - { - if (specificExceptionHandler.Key.IsInstanceOfType(exception)) - return specificExceptionHandler.Value(exception); - } - - var error = new Error - { - Id = Guid.NewGuid().ToString(), - Title = "Unhandled exception", - Detail = "An unhandled exception was thrown while processing the request.", - AboutLink = GetAboutLinkForException(exception), - Status = HttpStatusCode.InternalServerError, - Metadata = GetErrorMetadata(exception) - }; - return error; - } - - /// - /// Gets metadata to serialize inside the error object for a given exception. - /// - /// - /// - protected virtual IMetadata GetErrorMetadata(Exception exception) - { - return new ExceptionErrorMetadata(exception); - } - - /// - /// Gets a link to an about resource that yields further details about this particular occurrence of the problem. - /// - /// - /// - protected virtual ILink GetAboutLinkForException(Exception exception) - { - return null; - } - - /// - /// Allows configuring top-level metadata for an error response document. - /// - /// - protected virtual IMetadata GetTopLevelMetadata() - { - return null; - } - - /// - /// Gets metadata for an HttpError - /// - /// - /// - protected virtual IMetadata GetHttpErrorMetadata(HttpError httpError) - { - var metaObject = new JObject(); - - var currentObject = metaObject; - var currentError = httpError; - while (currentError != null) - { - currentObject["exceptionType"] = currentError.ExceptionType; - currentObject["exceptionMessage"] = currentError.ExceptionMessage; - currentObject["stackTrace"] = currentError.StackTrace; - - currentError = currentError.InnerException; - - if (currentError != null) - { - var innerObject = new JObject(); - currentObject["innerException"] = innerObject; - currentObject = innerObject; - } - } - - return new BasicMetadata(metaObject); - } - - private IError GetErrorForJsonApiException(Exception ex) - { - return ((JsonApiException) ex).Error; - } - - private IError GetErrorForDeserializationException(Exception ex) - { - var deserializationException = (DeserializationException) ex; - return new Error - { - Id = Guid.NewGuid().ToString(), - Title = deserializationException.Title, - Detail = ex.Message, - Pointer = deserializationException.Pointer, - Status = HttpStatusCode.BadRequest - }; - } - } -} diff --git a/JSONAPI/Documents/Builders/FallbackDocumentBuilder.cs b/JSONAPI/Documents/Builders/FallbackDocumentBuilder.cs deleted file mode 100644 index 8208f274..00000000 --- a/JSONAPI/Documents/Builders/FallbackDocumentBuilder.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Reflection; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.Http; - -namespace JSONAPI.Documents.Builders -{ - /// - /// Default implementation of IFallbackDocumentBuilder - /// - public class FallbackDocumentBuilder : IFallbackDocumentBuilder - { - private readonly ISingleResourceDocumentBuilder _singleResourceDocumentBuilder; - private readonly IQueryableResourceCollectionDocumentBuilder _queryableResourceCollectionDocumentBuilder; - private readonly IResourceCollectionDocumentBuilder _resourceCollectionDocumentBuilder; - private readonly ISortExpressionExtractor _sortExpressionExtractor; - private readonly IIncludeExpressionExtractor _includeExpressionExtractor; - private readonly IBaseUrlService _baseUrlService; - private readonly Lazy _openBuildDocumentFromQueryableMethod; - private readonly Lazy _openBuildDocumentFromEnumerableMethod; - - /// - /// Creates a new FallbackDocumentBuilder - /// - public FallbackDocumentBuilder(ISingleResourceDocumentBuilder singleResourceDocumentBuilder, - IQueryableResourceCollectionDocumentBuilder queryableResourceCollectionDocumentBuilder, - IResourceCollectionDocumentBuilder resourceCollectionDocumentBuilder, - ISortExpressionExtractor sortExpressionExtractor, - IIncludeExpressionExtractor includeExpressionExtractor, - IBaseUrlService baseUrlService) - { - _singleResourceDocumentBuilder = singleResourceDocumentBuilder; - _queryableResourceCollectionDocumentBuilder = queryableResourceCollectionDocumentBuilder; - _resourceCollectionDocumentBuilder = resourceCollectionDocumentBuilder; - _sortExpressionExtractor = sortExpressionExtractor; - _includeExpressionExtractor = includeExpressionExtractor; - _baseUrlService = baseUrlService; - - _openBuildDocumentFromQueryableMethod = - new Lazy( - () => _queryableResourceCollectionDocumentBuilder.GetType() - .GetMethod("BuildDocument", BindingFlags.Instance | BindingFlags.Public)); - - _openBuildDocumentFromEnumerableMethod = - new Lazy( - () => _resourceCollectionDocumentBuilder.GetType() - .GetMethod("BuildDocument", BindingFlags.Instance | BindingFlags.Public)); - } - - public async Task BuildDocument(object obj, HttpRequestMessage requestMessage, - CancellationToken cancellationToken) - { - var type = obj.GetType(); - - // TODO: test includes - var includeExpressions = _includeExpressionExtractor.ExtractIncludeExpressions(requestMessage); - - var queryableInterfaces = type.GetInterfaces(); - var queryableInterface = - queryableInterfaces.FirstOrDefault( - i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof (IQueryable<>)); - if (queryableInterface != null) - { - var queryableElementType = queryableInterface.GenericTypeArguments[0]; - var buildDocumentMethod = - _openBuildDocumentFromQueryableMethod.Value.MakeGenericMethod(queryableElementType); - - var sortExpressions = _sortExpressionExtractor.ExtractSortExpressions(requestMessage); - - dynamic materializedQueryTask = buildDocumentMethod.Invoke(_queryableResourceCollectionDocumentBuilder, - new[] { obj, requestMessage, sortExpressions, cancellationToken, includeExpressions }); - - return await materializedQueryTask; - } - - var isCollection = false; - var enumerableElementType = GetEnumerableElementType(type); - if (enumerableElementType != null) - { - isCollection = true; - } - - var linkBaseUrl = _baseUrlService.GetBaseUrl(requestMessage); - - if (isCollection) - { - var buildDocumentMethod = - _openBuildDocumentFromEnumerableMethod.Value.MakeGenericMethod(enumerableElementType); - return - (dynamic)buildDocumentMethod.Invoke(_resourceCollectionDocumentBuilder, new[] { obj, linkBaseUrl, new string[] { }, null, null }); - } - - // Single resource object - return _singleResourceDocumentBuilder.BuildDocument(obj, linkBaseUrl, includeExpressions, null); - } - - private static Type GetEnumerableElementType(Type collectionType) - { - if (collectionType.IsArray) - return collectionType.GetElementType(); - - if (collectionType.IsGenericType && collectionType.GetGenericTypeDefinition() == typeof(IEnumerable<>)) - { - return collectionType.GetGenericArguments()[0]; - } - - var enumerableInterface = collectionType.GetInterface(typeof(IEnumerable<>).FullName); - if (enumerableInterface == null) return null; - - var genericArguments = collectionType.GetGenericArguments(); - if (!genericArguments.Any()) return null; - - return genericArguments[0]; - } - } -} diff --git a/JSONAPI/Documents/Builders/IErrorDocumentBuilder.cs b/JSONAPI/Documents/Builders/IErrorDocumentBuilder.cs deleted file mode 100644 index 900d6d05..00000000 --- a/JSONAPI/Documents/Builders/IErrorDocumentBuilder.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Net; -using System.Web.Http; - -namespace JSONAPI.Documents.Builders -{ - /// - /// Provides services for building an error document - /// - public interface IErrorDocumentBuilder - { - /// - /// Builds an error document based on an exception - /// - IErrorDocument BuildFromException(Exception exception); - - /// - /// Builds an error document based on an HttpError - /// - IErrorDocument BuildFromHttpError(HttpError httpError, HttpStatusCode statusCode); - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/Builders/IFallbackDocumentBuilder.cs b/JSONAPI/Documents/Builders/IFallbackDocumentBuilder.cs deleted file mode 100644 index 5004d2fd..00000000 --- a/JSONAPI/Documents/Builders/IFallbackDocumentBuilder.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; - -namespace JSONAPI.Documents.Builders -{ - /// - /// Service to create a document when the type is unknown at compile-time - /// - public interface IFallbackDocumentBuilder - { - /// - /// Builds a JSON API document based on the given object - /// - /// - /// - /// - /// - /// Thrown when an error occurs when building the document - Task BuildDocument(object obj, HttpRequestMessage requestMessage, CancellationToken cancellationToken); - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/Builders/IQueryableResourceCollectionDocumentBuilder.cs b/JSONAPI/Documents/Builders/IQueryableResourceCollectionDocumentBuilder.cs deleted file mode 100644 index 0c15cb50..00000000 --- a/JSONAPI/Documents/Builders/IQueryableResourceCollectionDocumentBuilder.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Linq; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; - -namespace JSONAPI.Documents.Builders -{ - /// - /// This interface is responsible for building IResourceCollectionDocument objects based on IQueryable ObjectContent - /// - public interface IQueryableResourceCollectionDocumentBuilder - { - /// - /// Builds a document object for the given query - /// - /// The query to materialize to build the response document - /// The request containing parameters to determine how to sort/filter/paginate the query - /// An array of paths to sort by - /// - /// The set of paths to include in the compound document - /// - /// - Task BuildDocument(IQueryable query, HttpRequestMessage request, string[] sortExpressions, CancellationToken cancellationToken, - string[] includePaths = null); - } -} diff --git a/JSONAPI/Documents/Builders/IResourceCollectionDocumentBuilder.cs b/JSONAPI/Documents/Builders/IResourceCollectionDocumentBuilder.cs deleted file mode 100644 index 78d06d14..00000000 --- a/JSONAPI/Documents/Builders/IResourceCollectionDocumentBuilder.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections.Generic; - -namespace JSONAPI.Documents.Builders -{ - /// - /// Builds a response document from primary data objects - /// - public interface IResourceCollectionDocumentBuilder - { - /// - /// Builds an IResourceCollectionDocument from the given queryable of model objects - /// - /// - /// The string to prepend to link URLs. - /// A list of dot-separated paths to include in the compound document. - /// If this collection is null or empty, no linkage will be included. - /// Metadata for the top-level - /// Metadata to associate with individual resource objects - /// - /// - IResourceCollectionDocument BuildDocument(IEnumerable primaryData, string linkBaseUrl, string[] includePathExpressions, IMetadata metadata, - IDictionary resourceMetadata = null); - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/Builders/ISingleResourceDocumentBuilder.cs b/JSONAPI/Documents/Builders/ISingleResourceDocumentBuilder.cs deleted file mode 100644 index 6fc032fa..00000000 --- a/JSONAPI/Documents/Builders/ISingleResourceDocumentBuilder.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Collections.Generic; - -namespace JSONAPI.Documents.Builders -{ - /// - /// Builds a response document from primary data objects - /// - public interface ISingleResourceDocumentBuilder - { - /// - /// Builds an ISingleResourceDocument from the given model object - /// - /// - /// The string to prepend to link URLs. - /// A list of dot-separated paths to include in the compound document. - /// If this collection is null or empty, no linkage will be included. - /// Metadata to serialize at the top level of the document - /// Metadata about individual resource objects - /// - ISingleResourceDocument BuildDocument(object primaryData, string linkBaseUrl, string[] includePathExpressions, IMetadata topLevelMetadata, - IDictionary resourceMetadata = null); - } -} diff --git a/JSONAPI/Documents/Builders/JsonApiException.cs b/JSONAPI/Documents/Builders/JsonApiException.cs deleted file mode 100644 index ee6d04f9..00000000 --- a/JSONAPI/Documents/Builders/JsonApiException.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using System.Net; - -namespace JSONAPI.Documents.Builders -{ - /// - /// Exception that should be thrown by document builders if an error occurs. The data in - /// this exception will drive the construction of the error object in the response document, - /// as well as the HTTP status code. - /// - public class JsonApiException : Exception - { - /// - /// The error - /// - public IError Error { get; set; } - - /// - /// Creates a new JsonApiException - /// - /// - public JsonApiException(IError error) : base(error?.Detail ?? "An error occurred in JSONAPI") - { - Error = error; - } - - /// - /// Creates a JsonApiException indicating a problem with a supplied query parameter - /// - public static JsonApiException CreateForParameterError(string title, string detail, string parameter) - { - var error = new Error - { - Id = Guid.NewGuid().ToString(), - Status = HttpStatusCode.BadRequest, - Title = title, - Detail = detail, - Parameter = parameter - }; - return new JsonApiException(error); - } - - /// - /// Creates a JsonApiException with a title and detail - /// - public static JsonApiException Create(string title, string detail, HttpStatusCode status) - { - var error = new Error - { - Id = Guid.NewGuid().ToString(), - Status = status, - Title = title, - Detail = detail - }; - return new JsonApiException(error); - } - - /// - /// Creates a JsonApiException to send a 400 Bad Request error. - /// - public static JsonApiException CreateForBadRequest(string detail = null) - { - var error = new Error - { - Id = Guid.NewGuid().ToString(), - Status = HttpStatusCode.BadRequest, - Title = "Bad request", - Detail = detail - }; - return new JsonApiException(error); - } - - /// - /// Creates a JsonApiException to send a 404 Not Found error. - /// - public static JsonApiException CreateForNotFound(string detail = null) - { - var error = new Error - { - Id = Guid.NewGuid().ToString(), - Status = HttpStatusCode.NotFound, - Title = "Resource not found", - Detail = detail - }; - return new JsonApiException(error); - } - - /// - /// Creates a JsonApiException to send a 403 Forbidden error. - /// - public static JsonApiException CreateForForbidden(string detail = null) - { - var error = new Error - { - Id = Guid.NewGuid().ToString(), - Status = HttpStatusCode.Forbidden, - Title = "Forbidden", - Detail = detail - }; - return new JsonApiException(error); - } - - /// - /// Creates a JsonApiException to send a 405 Method Not Allowed error. - /// - public static JsonApiException CreateForMethodNotAllowed(string detail = null) - { - var error = new Error - { - Id = Guid.NewGuid().ToString(), - Status = HttpStatusCode.MethodNotAllowed, - Title = "Method not allowed", - Detail = detail - }; - return new JsonApiException(error); - } - } -} diff --git a/JSONAPI/Documents/Builders/RegistryDrivenDocumentBuilder.cs b/JSONAPI/Documents/Builders/RegistryDrivenDocumentBuilder.cs deleted file mode 100644 index 69b6bbac..00000000 --- a/JSONAPI/Documents/Builders/RegistryDrivenDocumentBuilder.cs +++ /dev/null @@ -1,169 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using JSONAPI.Core; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Documents.Builders -{ - /// - /// Base class for the main document builders - /// - public abstract class RegistryDrivenDocumentBuilder - { - private readonly IResourceTypeRegistry _resourceTypeRegistry; - private readonly ILinkConventions _linkConventions; - - /// - /// Creates a new RegistryDrivenDocumentBuilder - /// - /// - /// - protected RegistryDrivenDocumentBuilder(IResourceTypeRegistry resourceTypeRegistry, ILinkConventions linkConventions) - { - _resourceTypeRegistry = resourceTypeRegistry; - _linkConventions = linkConventions; - } - - internal static bool PathExpressionMatchesCurrentPath(string currentPath, string pathToInclude) - { - if (string.IsNullOrEmpty(pathToInclude)) return false; - if (currentPath == pathToInclude) return true; - - var currentPathSegments = currentPath.Split('.'); - var pathToIncludeSegments = pathToInclude.Split('.'); - - // Same number of segments fails because we already checked for equality above - if (currentPathSegments.Length >= pathToIncludeSegments.Length) return false; - - return !currentPathSegments.Where((t, i) => t != pathToIncludeSegments[i]).Any(); - } - - /// - /// Creates a JSON API resource object from the given CLR object - /// - /// - /// - /// - /// - /// - /// - /// - protected ResourceObject CreateResourceObject(object modelObject, IDictionary> idDictionariesByType, - string currentPath, string[] includePathExpressions, string linkBaseUrl, IDictionary resourceObjectMetadata) - { - if (modelObject == null) return null; - - var modelObjectRuntimeType = modelObject.GetType(); - var resourceTypeRegistration = _resourceTypeRegistry.GetRegistrationForType(modelObjectRuntimeType); - - var attributes = new Dictionary(); - var relationships = new Dictionary(); - - foreach (var attribute in resourceTypeRegistration.Attributes) - { - var propertyValue = attribute.GetValue(modelObject); - attributes[attribute.JsonKey] = propertyValue; - } - - foreach (var modelRelationship in resourceTypeRegistration.Relationships) - { - IResourceLinkage linkage = null; - - var childPath = currentPath == null - ? modelRelationship.JsonKey - : (currentPath + "." + modelRelationship.JsonKey); - if (includePathExpressions != null && - includePathExpressions.Any(e => PathExpressionMatchesCurrentPath(childPath, e))) - { - if (modelRelationship.IsToMany) - { - var propertyValue = - (IEnumerable)modelRelationship.Property.GetValue(modelObject); - if (propertyValue != null) - { - var identifiers = new List(); - foreach (var relatedResource in propertyValue) - { - var identifier = GetResourceIdentifierForResource(relatedResource); - identifiers.Add(identifier); - - IDictionary idDictionary; - if (!idDictionariesByType.TryGetValue(identifier.Type, out idDictionary)) - { - idDictionary = new Dictionary(); - idDictionariesByType[identifier.Type] = idDictionary; - } - - ResourceObject relatedResourceObject; - if (!idDictionary.TryGetValue(identifier.Id, out relatedResourceObject)) - { - relatedResourceObject = CreateResourceObject(relatedResource, idDictionariesByType, - childPath, includePathExpressions, linkBaseUrl, resourceObjectMetadata); - idDictionary[identifier.Id] = relatedResourceObject; - } - } - linkage = new ToManyResourceLinkage(identifiers.ToArray()); - } - } - else - { - var relatedResource = modelRelationship.Property.GetValue(modelObject); - if (relatedResource != null) - { - var identifier = GetResourceIdentifierForResource(relatedResource); - - IDictionary idDictionary; - if (!idDictionariesByType.TryGetValue(identifier.Type, out idDictionary)) - { - idDictionary = new Dictionary(); - idDictionariesByType[identifier.Type] = idDictionary; - } - - ResourceObject relatedResourceObject; - if (!idDictionary.TryGetValue(identifier.Id, out relatedResourceObject)) - { - relatedResourceObject = CreateResourceObject(relatedResource, idDictionariesByType, - childPath, includePathExpressions, linkBaseUrl, resourceObjectMetadata); - idDictionary[identifier.Id] = relatedResourceObject; - } - - linkage = new ToOneResourceLinkage(identifier); - } - else - { - linkage = new ToOneResourceLinkage(null); - } - } - } - - var selfLink = _linkConventions.GetRelationshipLink(modelObject, _resourceTypeRegistry, modelRelationship, linkBaseUrl); - var relatedResourceLink = _linkConventions.GetRelatedResourceLink(modelObject, _resourceTypeRegistry, modelRelationship, linkBaseUrl); - - relationships[modelRelationship.JsonKey] = new RelationshipObject(linkage, selfLink, relatedResourceLink); - } - - var resourceId = resourceTypeRegistration.GetIdForResource(modelObject); - - IMetadata thisResourceObjectsMetadata; - if (resourceObjectMetadata != null) - resourceObjectMetadata.TryGetValue(modelObject, out thisResourceObjectsMetadata); - else - thisResourceObjectsMetadata = null; - return new ResourceObject(resourceTypeRegistration.ResourceTypeName, resourceId, attributes, relationships, metadata: thisResourceObjectsMetadata); - } - - /// - /// Creates a JSON API resource identifier that points to the given resource instance - /// - /// - /// - protected ResourceIdentifier GetResourceIdentifierForResource(object resource) - { - var relatedResourceType = resource.GetType(); - var relatedResourceRegistration = _resourceTypeRegistry.GetRegistrationForType(relatedResourceType); - var relatedResourceTypeName = relatedResourceRegistration.ResourceTypeName; - var relatedResourceId = relatedResourceRegistration.GetIdForResource(resource); - return new ResourceIdentifier(relatedResourceTypeName, relatedResourceId); - } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/Builders/RegistryDrivenResourceCollectionDocumentBuilder.cs b/JSONAPI/Documents/Builders/RegistryDrivenResourceCollectionDocumentBuilder.cs deleted file mode 100644 index 0508dd4a..00000000 --- a/JSONAPI/Documents/Builders/RegistryDrivenResourceCollectionDocumentBuilder.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using JSONAPI.Core; - -namespace JSONAPI.Documents.Builders -{ - /// - /// Builds a document for a collection of resources that are registered with a resource type registry - /// - public class RegistryDrivenResourceCollectionDocumentBuilder : RegistryDrivenDocumentBuilder, IResourceCollectionDocumentBuilder - { - /// - /// Creates a new RegistryDrivenSingleResourceDocumentBuilder - /// - /// The resource type registry to use to locate the registered type - /// Conventions to follow when building links - public RegistryDrivenResourceCollectionDocumentBuilder(IResourceTypeRegistry resourceTypeRegistry, ILinkConventions linkConventions) - : base(resourceTypeRegistry, linkConventions) - { - } - - public IResourceCollectionDocument BuildDocument(IEnumerable primaryData, string linkBaseUrl, string[] includePathExpressions, IMetadata metadata, - IDictionary resourceMetadata = null) - { - var idDictionariesByType = new Dictionary>(); - var primaryDataResources = - primaryData.Select(d => (IResourceObject)CreateResourceObject(d, idDictionariesByType, null, includePathExpressions, linkBaseUrl, resourceMetadata)) - .ToArray(); - - var primaryResourceIdentifiers = primaryDataResources.Select(r => new { r.Id, r.Type }).ToArray(); - - var relatedData = idDictionariesByType.Values.SelectMany(d => d.Values).Cast().ToArray(); - var relatedDataNotInPrimaryData = relatedData - .Where(r => !primaryResourceIdentifiers.Any(pri => pri.Id == r.Id && pri.Type == r.Type)) - .ToArray(); - - var document = new ResourceCollectionDocument(primaryDataResources, relatedDataNotInPrimaryData, metadata); - return document; - } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/Builders/RegistryDrivenSingleResourceDocumentBuilder.cs b/JSONAPI/Documents/Builders/RegistryDrivenSingleResourceDocumentBuilder.cs deleted file mode 100644 index 029897b3..00000000 --- a/JSONAPI/Documents/Builders/RegistryDrivenSingleResourceDocumentBuilder.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using JSONAPI.Core; - -namespace JSONAPI.Documents.Builders -{ - /// - /// Builds a document for a resource that is registered with a resource type registry - /// - public class RegistryDrivenSingleResourceDocumentBuilder : RegistryDrivenDocumentBuilder, ISingleResourceDocumentBuilder - { - /// - /// Creates a new RegistryDrivenSingleResourceDocumentBuilder - /// - /// The resource type registry to use to locate the registered type - /// Conventions to follow when building links - public RegistryDrivenSingleResourceDocumentBuilder(IResourceTypeRegistry resourceTypeRegistry, ILinkConventions linkConventions) - : base(resourceTypeRegistry, linkConventions) - { - } - - public ISingleResourceDocument BuildDocument(object primaryData, string linkBaseUrl, string[] includePathExpressions, IMetadata topLevelMetadata, - IDictionary resourceMetadata = null) - { - var idDictionariesByType = new Dictionary>(); - var primaryDataResource = CreateResourceObject(primaryData, idDictionariesByType, null, includePathExpressions, linkBaseUrl, resourceMetadata); - - var relatedData = idDictionariesByType.Values.SelectMany(d => d.Values).Cast().ToArray(); - var document = new SingleResourceDocument(primaryDataResource, relatedData, topLevelMetadata); - return document; - } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/DefaultLinkConventions.cs b/JSONAPI/Documents/DefaultLinkConventions.cs deleted file mode 100644 index 88d1c500..00000000 --- a/JSONAPI/Documents/DefaultLinkConventions.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System; -using JSONAPI.Core; - -namespace JSONAPI.Documents -{ - /// - /// Implementation of ILinkConventions that adheres to JSON API recommendations for URL formatting. - /// - public class DefaultLinkConventions : ILinkConventions - { - public ILink GetRelationshipLink(TResource relationshipOwner, IResourceTypeRegistry resourceTypeRegistry, ResourceTypeRelationship property, string baseUrl) - { - if (!property.SerializeRelationshipLink) return null; - - var url = BuildRelationshipUrl(relationshipOwner, resourceTypeRegistry, property, baseUrl); - var metadata = GetMetadataForRelationshipLink(relationshipOwner, property); - return new Link(url, metadata); - } - - public ILink GetRelatedResourceLink(TResource relationshipOwner, IResourceTypeRegistry resourceTypeRegistry, ResourceTypeRelationship property, string baseUrl) - { - if (!property.SerializeRelatedResourceLink) return null; - - var url = BuildRelatedResourceUrl(relationshipOwner, resourceTypeRegistry, property, baseUrl); - var metadata = GetMetadataForRelatedResourceLink(relationshipOwner, property); - return new Link(url, metadata); - } - - private string GetSanitizedBaseUrl(string baseUrl) - { - while (baseUrl[baseUrl.Length - 1] == '/') - baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); - return baseUrl; - } - - /// - /// Constructs a URL for the relationship belonging to the given resource - /// - /// - /// - /// - /// - /// - protected virtual string BuildRelationshipUrl(object relationshipOwner, IResourceTypeRegistry resourceTypeRegistry, - ResourceTypeRelationship property, string baseUrl) - { - var relationshipOwnerType = relationshipOwner.GetType(); - var sanitizedBaseUrl = GetSanitizedBaseUrl(baseUrl); - var registration = resourceTypeRegistry.GetRegistrationForType(relationshipOwnerType); - var id = registration.GetIdForResource(relationshipOwner); - if (property.SelfLinkTemplate != null) - { - var replacedString = property.SelfLinkTemplate.Replace("{1}", id); - return String.Format("{0}/{1}", sanitizedBaseUrl, replacedString); - } - - return String.Format("{0}/{1}/{2}/relationships/{3}", sanitizedBaseUrl, registration.ResourceTypeName, id, property.JsonKey); - } - - /// - /// Gets a metadata object to serialize alongside the link URL for relationship links. - /// - /// - protected virtual IMetadata GetMetadataForRelationshipLink(TResource relationshipOwner, ResourceTypeRelationship property) - { - return null; - } - - /// - /// Constructs a URL for the resource(s) on the other side of the given relationship, belonging to the given resource - /// - /// - /// - /// - /// - /// - protected virtual string BuildRelatedResourceUrl(object relationshipOwner, IResourceTypeRegistry resourceTypeRegistry, - ResourceTypeRelationship property, string baseUrl) - { - var relationshipOwnerType = relationshipOwner.GetType(); - var sanitizedBaseUrl = GetSanitizedBaseUrl(baseUrl); - var registration = resourceTypeRegistry.GetRegistrationForType(relationshipOwnerType); - var id = registration.GetIdForResource(relationshipOwner); - if (property.RelatedResourceLinkTemplate != null) - { - var replacedString = property.RelatedResourceLinkTemplate.Replace("{1}", id); - return String.Format("{0}/{1}", sanitizedBaseUrl, replacedString); - } - - return String.Format("{0}/{1}/{2}/{3}", sanitizedBaseUrl, registration.ResourceTypeName, id, property.JsonKey); - } - - /// - /// Gets a metadata object to serialize alongside the link URL for related resource links. - /// - /// - protected virtual IMetadata GetMetadataForRelatedResourceLink(TResource relationshipOwner, ResourceTypeRelationship property) - { - return null; - } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/Error.cs b/JSONAPI/Documents/Error.cs deleted file mode 100644 index 95659008..00000000 --- a/JSONAPI/Documents/Error.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Net; - -namespace JSONAPI.Documents -{ - /// - /// Default implementation of IError - /// - public class Error : IError - { - public string Id { get; set; } - public ILink AboutLink { get; set; } - public HttpStatusCode Status { get; set; } - public string Code { get; set; } - public string Title { get; set; } - public string Detail { get; set; } - public string Pointer { get; set; } - public string Parameter { get; set; } - public IMetadata Metadata { get; set; } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/ErrorDocument.cs b/JSONAPI/Documents/ErrorDocument.cs deleted file mode 100644 index 23dc4637..00000000 --- a/JSONAPI/Documents/ErrorDocument.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace JSONAPI.Documents -{ - /// - /// Default implementation of IErrorDocument - /// - public class ErrorDocument : IErrorDocument - { - public IError[] Errors { get; private set; } - public IMetadata Metadata { get; private set; } - - /// - /// Creates a new ErrorDocument - /// - /// - /// - public ErrorDocument(IError[] errors, IMetadata metadata) - { - Errors = errors; - Metadata = metadata; - } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/ExceptionErrorMetadata.cs b/JSONAPI/Documents/ExceptionErrorMetadata.cs deleted file mode 100644 index 9af55611..00000000 --- a/JSONAPI/Documents/ExceptionErrorMetadata.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Documents -{ - /// - /// Metadata object for serializing exceptions in a response - /// - public class ExceptionErrorMetadata : IMetadata - { - /// - /// Creates a new ExceptionErrorMetadata - /// - /// - public ExceptionErrorMetadata(Exception exception) - { - MetaObject = new JObject(); - - var currentObject = MetaObject; - var currentException = exception; - while (currentException != null) - { - currentObject["exceptionMessage"] = currentException.Message; - currentObject["stackTrace"] = currentException.StackTrace; - - currentException = currentException.InnerException; - - if (currentException != null) - { - var innerObject = new JObject(); - currentObject["innerException"] = innerObject; - currentObject = innerObject; - } - } - } - - public JObject MetaObject { get; private set; } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/IError.cs b/JSONAPI/Documents/IError.cs deleted file mode 100644 index ea7e37e1..00000000 --- a/JSONAPI/Documents/IError.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Net; - -namespace JSONAPI.Documents -{ - /// - /// Represents an error appearing in the `errors` array at the document top-level - /// - public interface IError - { - /// - /// a unique identifier for this particular occurrence of the problem. - /// - string Id { get; } - - /// - /// link to information about this error - /// - ILink AboutLink { get; } - - /// - /// the HTTP status code applicable to this problem, expressed as a string value. - /// - HttpStatusCode Status { get; } - - /// - /// an application-specific error code, expressed as a string value. - /// - string Code { get; } - - /// - /// a short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization. - /// - string Title { get; } - - /// - /// a human-readable explanation specific to this occurrence of the problem. - /// - string Detail { get; } - - /// - /// a JSON Pointer [RFC6901] to the associated entity in the request document - /// - string Pointer { get; } - - /// - /// a string indicating which query parameter caused the error. - /// - string Parameter { get; } - - /// - /// a meta object containing non-standard meta-information about the error. - /// - IMetadata Metadata { get; } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/IErrorDocument.cs b/JSONAPI/Documents/IErrorDocument.cs deleted file mode 100644 index 78892aa5..00000000 --- a/JSONAPI/Documents/IErrorDocument.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace JSONAPI.Documents -{ - /// - /// Interface for JSON API documents that represent a collection of errors - /// - public interface IErrorDocument : IJsonApiDocument - { - /// - /// The errors to send in this document - /// - IError[] Errors { get; } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/IJsonApiDocument.cs b/JSONAPI/Documents/IJsonApiDocument.cs deleted file mode 100644 index 120d2cd2..00000000 --- a/JSONAPI/Documents/IJsonApiDocument.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace JSONAPI.Documents -{ - /// - /// Base interface for document - /// - public interface IJsonApiDocument - { - /// - /// Metadata for the document as a whole - /// - IMetadata Metadata { get; } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/ILink.cs b/JSONAPI/Documents/ILink.cs deleted file mode 100644 index 32fab92e..00000000 --- a/JSONAPI/Documents/ILink.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace JSONAPI.Documents -{ - /// - /// A link that may be found in a "links object" - /// - /// - public interface ILink - { - /// - /// a string containing the link's URL. - /// - string Href { get; } - - /// - /// a meta object containing non-standard meta-information about the link. - /// - IMetadata Metadata { get; } - } - - /// - /// Default implementation of ILink - /// - public class Link : ILink - { - public string Href { get; private set; } - public IMetadata Metadata { get; private set; } - - /// - /// Constructs a link - /// - /// The URL of the link - /// metadata about the link - public Link(string href, IMetadata metadata) - { - Href = href; - Metadata = metadata; - } - } -} diff --git a/JSONAPI/Documents/ILinkConventions.cs b/JSONAPI/Documents/ILinkConventions.cs deleted file mode 100644 index ec369a26..00000000 --- a/JSONAPI/Documents/ILinkConventions.cs +++ /dev/null @@ -1,30 +0,0 @@ -using JSONAPI.Core; - -namespace JSONAPI.Documents -{ - /// - /// Service to provide formatting of links - /// - public interface ILinkConventions - { - /// - /// Builds a relationship link for the given model property - /// - /// The resource that this relationship belongs to. - /// The model manage to use to lookup information about the relationship owner's type - /// The property to get the link for - /// The portion of the URL that the link will be appended to - /// - ILink GetRelationshipLink(TResource relationshipOwner, IResourceTypeRegistry resourceTypeRegistry, ResourceTypeRelationship property, string baseUrl); - - /// - /// Builds a related resource link for the given model property - /// - /// The resource that this relationship belongs to. - /// The model manage to use to lookup information about the relationship owner's type - /// The property to get the link for - /// The portion of the URL that the link will be appended to - /// - ILink GetRelatedResourceLink(TResource relationshipOwner, IResourceTypeRegistry resourceTypeRegistry, ResourceTypeRelationship property, string baseUrl); - } -} diff --git a/JSONAPI/Documents/IMetadata.cs b/JSONAPI/Documents/IMetadata.cs deleted file mode 100644 index 99e75c7b..00000000 --- a/JSONAPI/Documents/IMetadata.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Documents -{ - /// - /// Represents metadata that can be embedded in several places - /// - public interface IMetadata - { - /// - /// A JSON object containing the metadata value - /// - JObject MetaObject { get; } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/IRelationshipObject.cs b/JSONAPI/Documents/IRelationshipObject.cs deleted file mode 100644 index b65259ec..00000000 --- a/JSONAPI/Documents/IRelationshipObject.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace JSONAPI.Documents -{ - /// - /// Represents a JSON API relationship object - /// - public interface IRelationshipObject - { - /// - /// A link for the relationship itself - /// - ILink SelfLink { get; } - - /// - /// A link for the related resource - /// - ILink RelatedResourceLink { get; } - - /// - /// Linkage to the resources defined by this relationship - /// - IResourceLinkage Linkage { get; } - - /// - /// Metadata for the relationship - /// - IMetadata Metadata { get; } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/IResourceCollectionDocument.cs b/JSONAPI/Documents/IResourceCollectionDocument.cs deleted file mode 100644 index bcc52cf9..00000000 --- a/JSONAPI/Documents/IResourceCollectionDocument.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace JSONAPI.Documents -{ - /// - /// Interface for JSON API documents that represent a collection of resources - /// - public interface IResourceCollectionDocument : IJsonApiDocument - { - /// - /// The document's primary data - /// - IResourceObject[] PrimaryData { get; } - - /// - /// Data related to the primary data - /// - IResourceObject[] RelatedData { get; } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/IResourceIdentifier.cs b/JSONAPI/Documents/IResourceIdentifier.cs deleted file mode 100644 index 9a7ae764..00000000 --- a/JSONAPI/Documents/IResourceIdentifier.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace JSONAPI.Documents -{ - /// - /// Type/ID pair that identifies a particular resource - /// - public interface IResourceIdentifier - { - /// - /// The type of resource - /// - string Type { get; } - - /// - /// The ID of the resource - /// - string Id { get; } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/IResourceLinkage.cs b/JSONAPI/Documents/IResourceLinkage.cs deleted file mode 100644 index b45aef06..00000000 --- a/JSONAPI/Documents/IResourceLinkage.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace JSONAPI.Documents -{ - /// - /// Describes a relationship's linkage - /// - public interface IResourceLinkage - { - /// - /// Whether the linkage is to-many (true) or to-one (false). - /// - bool IsToMany { get; } - - /// - /// The identifiers this linkage refers to. If IsToMany is false, this - /// property must return an array of length either 0 or 1. If true, - /// the array may be of any length. This property must not return null. - /// - IResourceIdentifier[] Identifiers { get; } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/IResourceObject.cs b/JSONAPI/Documents/IResourceObject.cs deleted file mode 100644 index 6d839e40..00000000 --- a/JSONAPI/Documents/IResourceObject.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Collections.Generic; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Documents -{ - /// - /// Represents a JSON API resource object - /// - public interface IResourceObject - { - /// - /// The type of the resource - /// - string Type { get; } - - /// - /// The ID of the resource - /// - string Id { get; } - - /// - /// Attributes of the resource - /// - IDictionary Attributes { get; } - - /// - /// Relationships between the resource and other JSON API resources - /// - IDictionary Relationships { get; } - - /// - /// A link to the resource - /// - ILink SelfLink { get; } - - /// - /// Metadata about this particular resource - /// - IMetadata Metadata { get; } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/ISingleResourceDocument.cs b/JSONAPI/Documents/ISingleResourceDocument.cs deleted file mode 100644 index 684521f0..00000000 --- a/JSONAPI/Documents/ISingleResourceDocument.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace JSONAPI.Documents -{ - /// - /// Interface for JSON API documents that represent a single resource - /// - public interface ISingleResourceDocument : IJsonApiDocument - { - /// - /// The document's primary data - /// - IResourceObject PrimaryData { get; } - - /// - /// Data related to the primary data - /// - IResourceObject[] RelatedData { get; } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/Metadata.cs b/JSONAPI/Documents/Metadata.cs deleted file mode 100644 index 004de8c7..00000000 --- a/JSONAPI/Documents/Metadata.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Documents -{ - /// - /// Default implementation of - /// - public class Metadata : IMetadata - { - public Metadata() - { - MetaObject = new JObject(); - } - public JObject MetaObject { get; } - } -} diff --git a/JSONAPI/Documents/RelationshipObject.cs b/JSONAPI/Documents/RelationshipObject.cs deleted file mode 100644 index 4c3d7e14..00000000 --- a/JSONAPI/Documents/RelationshipObject.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace JSONAPI.Documents -{ - /// - /// Default implementation for IRelationshipObject - /// - public class RelationshipObject : IRelationshipObject - { - public ILink SelfLink { get; private set; } - public ILink RelatedResourceLink { get; private set; } - public IResourceLinkage Linkage { get; private set; } - public IMetadata Metadata { get; private set; } - - /// - /// Builds a new RelationshipObject with links only - /// - public RelationshipObject(ILink selfLink, ILink relatedResourceLink, IMetadata metadata = null) - { - SelfLink = selfLink; - RelatedResourceLink = relatedResourceLink; - Metadata = metadata; - } - - /// - /// Builds a new RelationshipObject with linkage only - /// - public RelationshipObject(IResourceLinkage linkage, IMetadata metadata = null) - { - Linkage = linkage; - Metadata = metadata; - } - - /// - /// Builds a new RelationshipObject with links and linkage - /// - public RelationshipObject(IResourceLinkage linkage, ILink selfLink, ILink relatedResourceLink, IMetadata metadata = null) - { - Linkage = linkage; - SelfLink = selfLink; - RelatedResourceLink = relatedResourceLink; - Metadata = metadata; - } - } -} diff --git a/JSONAPI/Documents/ResourceCollectionDocument.cs b/JSONAPI/Documents/ResourceCollectionDocument.cs deleted file mode 100644 index daab255b..00000000 --- a/JSONAPI/Documents/ResourceCollectionDocument.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace JSONAPI.Documents -{ - /// - /// Default implementation of IResourceCollectionDocument - /// - public class ResourceCollectionDocument : IResourceCollectionDocument - { - public IResourceObject[] PrimaryData { get; private set; } - public IResourceObject[] RelatedData { get; private set; } - public IMetadata Metadata { get; private set; } - - /// - /// Constructs a resource collection document - /// - public ResourceCollectionDocument(IResourceObject[] primaryData, IResourceObject[] relatedData, IMetadata metadata) - { - PrimaryData = primaryData; - RelatedData = relatedData; - Metadata = metadata; - } - } -} diff --git a/JSONAPI/Documents/ResourceIdentifier.cs b/JSONAPI/Documents/ResourceIdentifier.cs deleted file mode 100644 index 5f894f1a..00000000 --- a/JSONAPI/Documents/ResourceIdentifier.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace JSONAPI.Documents -{ - /// - /// Default implementation of IResourceIdentifier - /// - public class ResourceIdentifier : IResourceIdentifier - { - public string Type { get; private set; } - public string Id { get; private set; } - - /// - /// Creates a new ResourceIdentifier - /// - /// - /// - public ResourceIdentifier(string type, string id) - { - Type = type; - Id = id; - } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/ResourceObject.cs b/JSONAPI/Documents/ResourceObject.cs deleted file mode 100644 index e1ecd612..00000000 --- a/JSONAPI/Documents/ResourceObject.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Documents -{ - /// - /// Default implementation of IResourceObject - /// - public class ResourceObject : IResourceObject - { - public string Type { get; private set; } - public string Id { get; private set; } - public IDictionary Attributes { get; private set; } - public IDictionary Relationships { get; private set; } - public ILink SelfLink { get; private set; } - public IMetadata Metadata { get; private set; } - - /// - /// Creates a ResourceObject - /// - public ResourceObject(string type, string id, IDictionary attributes = null, - IDictionary relationships = null, ILink selfLink = null, IMetadata metadata = null) - { - Type = type; - Id = id; - Attributes = attributes ?? new Dictionary(); - Relationships = relationships ?? new Dictionary(); - SelfLink = selfLink; - Metadata = metadata; - } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/SingleResourceDocument.cs b/JSONAPI/Documents/SingleResourceDocument.cs deleted file mode 100644 index 01def3e0..00000000 --- a/JSONAPI/Documents/SingleResourceDocument.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace JSONAPI.Documents -{ - /// - /// Default implementation of ISingleResourceDocument - /// - public class SingleResourceDocument : ISingleResourceDocument - { - public IResourceObject PrimaryData { get; private set; } - - public IResourceObject[] RelatedData { get; private set; } - - public IMetadata Metadata { get; private set; } - - /// - /// Constructs a single resource document - /// - public SingleResourceDocument(IResourceObject primaryData, IResourceObject[] relatedData, IMetadata metadata) - { - PrimaryData = primaryData; - RelatedData = relatedData; - Metadata = metadata; - } - } -} diff --git a/JSONAPI/Documents/ToManyResourceLinkage.cs b/JSONAPI/Documents/ToManyResourceLinkage.cs deleted file mode 100644 index a9c576b4..00000000 --- a/JSONAPI/Documents/ToManyResourceLinkage.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; - -namespace JSONAPI.Documents -{ - /// - /// Describes linkage to a collection of resources - /// - public class ToManyResourceLinkage : IResourceLinkage - { - /// - /// Creates a To-many resource linkage object - /// - /// - /// - public ToManyResourceLinkage(IResourceIdentifier[] resourceIdentifiers) - { - Identifiers = resourceIdentifiers ?? new IResourceIdentifier[] {}; - } - - public bool IsToMany { get { return true; } } - public IResourceIdentifier[] Identifiers { get; private set; } - } -} \ No newline at end of file diff --git a/JSONAPI/Documents/ToOneResourceLinkage.cs b/JSONAPI/Documents/ToOneResourceLinkage.cs deleted file mode 100644 index d9fd509d..00000000 --- a/JSONAPI/Documents/ToOneResourceLinkage.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace JSONAPI.Documents -{ - /// - /// Describes linkage to a single resource - /// - public class ToOneResourceLinkage : IResourceLinkage - { - /// - /// Creates a to-one resource linkage object - /// - /// - public ToOneResourceLinkage(IResourceIdentifier resourceIdentifier) - { - Identifiers = resourceIdentifier != null ? new[] {resourceIdentifier} : new IResourceIdentifier[] {}; - } - - public bool IsToMany { get { return false; } } - public IResourceIdentifier[] Identifiers { get; private set; } - } -} \ No newline at end of file diff --git a/JSONAPI/Extensions/QueryableExtensions.cs b/JSONAPI/Extensions/QueryableExtensions.cs deleted file mode 100644 index e6aca042..00000000 --- a/JSONAPI/Extensions/QueryableExtensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Linq; -using System.Linq.Expressions; -using System.Net.Http; -using System.Reflection; -using System.Web.Http.Filters; -using JSONAPI.Core; - -namespace JSONAPI.Extensions -{ - internal static class QueryableExtensions - { - } -} diff --git a/JSONAPI/Extensions/StringExtensions.cs b/JSONAPI/Extensions/StringExtensions.cs deleted file mode 100644 index 7f4e9ad4..00000000 --- a/JSONAPI/Extensions/StringExtensions.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Text.RegularExpressions; - -namespace JSONAPI.Extensions -{ - public static class StringExtensions - { - private static readonly Regex PascalizeRegex = new Regex(@"(?:^|_|\-|\.)(.)"); - - public static string Pascalize(this string word) - { - return PascalizeRegex.Replace( - word, - match => match.Groups[1].Value.ToUpper()); - } - - public static string Depascalize(this string word) - { - return Regex.Replace( - Regex.Replace( - Regex.Replace(word, @"([A-Z]+)([A-Z][a-z])", "$1_$2"), @"([a-z\d])([A-Z])", - "$1_$2"), @"[-\s]", "_").ToLower(); - } - - public static string Dasherize(this string word) - { - return Depascalize(word).Replace('_', '-'); - } - } -} diff --git a/JSONAPI/Extensions/TypeExtensions.cs b/JSONAPI/Extensions/TypeExtensions.cs deleted file mode 100644 index c7d849ca..00000000 --- a/JSONAPI/Extensions/TypeExtensions.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Extensions -{ - public static class TypeExtensions - { - public static bool CanWriteAsJsonApiAttribute(this Type objectType) - { - if (objectType.IsGenericType && objectType.GetGenericTypeDefinition() == typeof (Nullable<>)) - objectType = objectType.GetGenericArguments()[0]; - - return objectType.IsPrimitive - || typeof (Decimal).IsAssignableFrom(objectType) - || typeof (Guid).IsAssignableFrom(objectType) - || typeof (DateTime).IsAssignableFrom(objectType) - || typeof (DateTimeOffset).IsAssignableFrom(objectType) - || typeof (String).IsAssignableFrom(objectType) - || typeof (JToken).IsAssignableFrom(objectType) - || objectType.IsEnum; - } - - public static IEnumerable CreateEnumerableInstance(this Type type) - { - Type relType; - if (type.IsGenericType) - { - relType = type.GetGenericArguments()[0]; - } - else - { - // Must be an array at this point, right?? - relType = type.GetElementType(); - } - - // Hmm...now we have to create an object that fits this property. This could get messy... - if (!type.IsInterface && !type.IsAbstract) - { - // Whew...okay, just instantiate one of these... - return (IEnumerable)Activator.CreateInstance(type); - } - - // Ugh...now we're really in trouble...hopefully one of these will work: - if (type.IsGenericType) - { - if (type.IsAssignableFrom(typeof(List<>).MakeGenericType(relType))) - { - return (IEnumerable) Activator.CreateInstance(typeof(List<>).MakeGenericType(relType)); - } - - if (type.IsAssignableFrom(typeof(HashSet<>).MakeGenericType(relType))) - { - return - (IEnumerable) Activator.CreateInstance(typeof(HashSet<>).MakeGenericType(relType)); - } - - //TODO: Other likely candidates?? - } - - return null; - } - } -} diff --git a/JSONAPI/Http/BaseUrlService.cs b/JSONAPI/Http/BaseUrlService.cs deleted file mode 100644 index df1ee1a1..00000000 --- a/JSONAPI/Http/BaseUrlService.cs +++ /dev/null @@ -1,115 +0,0 @@ -using System; -using System.Net.Http; - -namespace JSONAPI.Http -{ - /// - /// Default implementation of IBaseUrlService - /// - public class BaseUrlService : IBaseUrlService - { - private string _contextPath = string.Empty; - private Uri _publicOrigin; - - /// - /// Default constructor - /// - public BaseUrlService() { } - - /// - /// Constructor which provides a context path for the routes of JSONAPI.NET - /// - /// context path for the routes - public BaseUrlService(string contextPath) - { - CleanContextPath(contextPath); - } - - /// - /// Constructor which provides a public origin host and a context path for the routes of JSONAPI.NET. - /// If only public origin is desired provide emtpy string to contextPath. - /// - /// public hostname - /// context path for the routes - public BaseUrlService(Uri publicOrigin, string contextPath) - { - CleanContextPath(contextPath); - this._publicOrigin = publicOrigin; - } - - /// - /// Retrieve the base path to provide in responses. - /// - /// - /// - public virtual string GetBaseUrl(HttpRequestMessage requestMessage) - { - string pathAndQuery; - string absolutUri = requestMessage.RequestUri.AbsoluteUri; - if (_publicOrigin != null) - { - var publicUriBuilder = new UriBuilder(absolutUri) - { - Host = _publicOrigin.Host, - Scheme = _publicOrigin.Scheme, - Port = _publicOrigin.Port - }; - absolutUri = publicUriBuilder.Uri.AbsoluteUri; - pathAndQuery = publicUriBuilder.Uri.PathAndQuery; - } - else - { - pathAndQuery = requestMessage.RequestUri.PathAndQuery; - } - pathAndQuery = RemoveFromBegin(pathAndQuery, GetContextPath()); - pathAndQuery= pathAndQuery.TrimStart('/'); - var baseUrl = RemoveFromEnd(absolutUri, pathAndQuery); - return baseUrl; - } - - /// - /// Provides the context path to serve JSONAPI.NET without leading and trailing slash. - /// - /// - public string GetContextPath() - { - return _contextPath; - } - - /// - /// Makes sure thre are no slashes at the beginnig or end. - /// - /// - private void CleanContextPath(string contextPath) - { - if (!string.IsNullOrEmpty(contextPath) && !contextPath.EndsWith("/")) - { - contextPath = contextPath.TrimEnd('/'); - } - if (!string.IsNullOrEmpty(contextPath) && contextPath.StartsWith("/")) - { - contextPath = contextPath.TrimStart('/'); - } - _contextPath = contextPath; - } - - - private string RemoveFromEnd(string input, string suffix) - { - if (input.EndsWith(suffix)) - { - return input.Substring(0, input.Length - suffix.Length); - } - return input; - } - private string RemoveFromBegin(string input, string prefix) - { - prefix = "/" + prefix; - if (input.StartsWith(prefix)) - { - return input.Substring(prefix.Length, input.Length - prefix.Length); - } - return input; - } - } -} \ No newline at end of file diff --git a/JSONAPI/Http/DefaultIncludeExpressionExtractor.cs b/JSONAPI/Http/DefaultIncludeExpressionExtractor.cs deleted file mode 100644 index cb040b19..00000000 --- a/JSONAPI/Http/DefaultIncludeExpressionExtractor.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Linq; -using System.Net.Http; - -namespace JSONAPI.Http -{ - /// - /// Default implementation of - /// - public class DefaultIncludeExpressionExtractor: IIncludeExpressionExtractor - { - private const string IncludeQueryParamKey = "include"; - - public string[] ExtractIncludeExpressions(HttpRequestMessage requestMessage) - { - var queryParams = requestMessage.GetQueryNameValuePairs(); - var includeParam = queryParams.FirstOrDefault(kvp => kvp.Key == IncludeQueryParamKey); - if (includeParam.Key != IncludeQueryParamKey) return new string[] { }; - return includeParam.Value.Split(','); - } - } -} diff --git a/JSONAPI/Http/DefaultSortExpressionExtractor.cs b/JSONAPI/Http/DefaultSortExpressionExtractor.cs deleted file mode 100644 index 59cb449a..00000000 --- a/JSONAPI/Http/DefaultSortExpressionExtractor.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Linq; -using System.Net.Http; - -namespace JSONAPI.Http -{ - /// - /// Default implementation of - /// - public class DefaultSortExpressionExtractor : ISortExpressionExtractor - { - private const string SortQueryParamKey = "sort"; - - public string[] ExtractSortExpressions(HttpRequestMessage requestMessage) - { - var queryParams = requestMessage.GetQueryNameValuePairs(); - var sortParam = queryParams.FirstOrDefault(kvp => kvp.Key == SortQueryParamKey); - if (sortParam.Key != SortQueryParamKey) return new string[] {}; - return sortParam.Value.Split(','); - } - } -} \ No newline at end of file diff --git a/JSONAPI/Http/DocumentMaterializerLocator.cs b/JSONAPI/Http/DocumentMaterializerLocator.cs deleted file mode 100644 index b5e3d9d0..00000000 --- a/JSONAPI/Http/DocumentMaterializerLocator.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; - -namespace JSONAPI.Http -{ - /// - /// Default implementation of - /// - public class DocumentMaterializerLocator : IDocumentMaterializerLocator - { - private readonly Func _nameResolver; - private readonly Func _typeResolver; - private readonly Func _relatedResourceMaterializerResolver; - - /// - /// Creates a new - /// - public DocumentMaterializerLocator(Func nameResolver, - Func typeResolver, - Func relatedResourceMaterializerResolver) - { - _nameResolver = nameResolver; - _typeResolver = typeResolver; - _relatedResourceMaterializerResolver = relatedResourceMaterializerResolver; - } - - public IDocumentMaterializer GetMaterializerByResourceTypeName(string resourceTypeName) - { - return _nameResolver(resourceTypeName); - } - - public IDocumentMaterializer GetMaterializerByType(Type type) - { - return _typeResolver(type); - } - - public IRelatedResourceDocumentMaterializer GetRelatedResourceMaterializer(string resourceTypeName, string relationshipName) - { - return _relatedResourceMaterializerResolver(resourceTypeName, relationshipName); - } - } -} \ No newline at end of file diff --git a/JSONAPI/Http/IBaseUrlService.cs b/JSONAPI/Http/IBaseUrlService.cs deleted file mode 100644 index dd9f3177..00000000 --- a/JSONAPI/Http/IBaseUrlService.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Net.Http; - -namespace JSONAPI.Http -{ - /// - /// Service allowing you to get the base URL for a request - /// - public interface IBaseUrlService - { - /// - /// Gets the base URL for a request - /// - string GetBaseUrl(HttpRequestMessage requestMessage); - - /// - /// Gets the context path JSONAPI is served under without slashes at the beginning and end. - /// - /// - string GetContextPath(); - } -} diff --git a/JSONAPI/Http/IDocumentMaterializer.cs b/JSONAPI/Http/IDocumentMaterializer.cs deleted file mode 100644 index b4eb4bce..00000000 --- a/JSONAPI/Http/IDocumentMaterializer.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.Documents; - -namespace JSONAPI.Http -{ - /// - /// This service provides the glue between JSONAPI.NET and your persistence layer. - /// - public interface IDocumentMaterializer - { - /// - /// Returns a document containing records that are filtered, sorted, - /// and paginated according to query parameters present in the provided request. - /// - Task GetRecords(HttpRequestMessage request, CancellationToken cancellationToken); - - /// - /// Returns a document with the resource identified by the given ID. - /// - Task GetRecordById(string id, HttpRequestMessage request, - CancellationToken cancellationToken); - - /// - /// Creates a record corresponding to the data in the request document, and returns a document - /// corresponding to the created record. - /// - Task CreateRecord(ISingleResourceDocument requestDocument, HttpRequestMessage request, - CancellationToken cancellationToken); - - /// - /// Updates the record corresponding to the data in the request document, and returns a document - /// corresponding to the updated record. - /// - Task UpdateRecord(string id, ISingleResourceDocument requestDocument, - HttpRequestMessage request, CancellationToken cancellationToken); - - /// - /// Deletes the record corresponding to the given id. - /// - Task DeleteRecord(string id, HttpRequestMessage request, CancellationToken cancellationToken); - } -} \ No newline at end of file diff --git a/JSONAPI/Http/IDocumentMaterializerLocator.cs b/JSONAPI/Http/IDocumentMaterializerLocator.cs deleted file mode 100644 index 46057845..00000000 --- a/JSONAPI/Http/IDocumentMaterializerLocator.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace JSONAPI.Http -{ - /// - /// Service to lookup document materializers - /// - public interface IDocumentMaterializerLocator - { - /// - /// Resolves a for the given resource type name. - /// - IDocumentMaterializer GetMaterializerByResourceTypeName(string resourceTypeName); - - /// - /// Resolves a for the given type. - /// - IDocumentMaterializer GetMaterializerByType(Type type); - - /// - /// Resolves a for the given resource type and relationship. - /// - IRelatedResourceDocumentMaterializer GetRelatedResourceMaterializer(string resourceTypeName, string relationshipName); - } -} diff --git a/JSONAPI/Http/IIncludeExpressionExtractor.cs b/JSONAPI/Http/IIncludeExpressionExtractor.cs deleted file mode 100644 index c8cf1358..00000000 --- a/JSONAPI/Http/IIncludeExpressionExtractor.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Net.Http; - -namespace JSONAPI.Http -{ - /// - /// Service to extract include expressions from an HTTP request - /// - public interface IIncludeExpressionExtractor - { - /// - /// Extracts include expressions from the request - /// - /// - /// - string[] ExtractIncludeExpressions(HttpRequestMessage requestMessage); - } -} diff --git a/JSONAPI/Http/IRelatedResourceDocumentMaterializer.cs b/JSONAPI/Http/IRelatedResourceDocumentMaterializer.cs deleted file mode 100644 index 893c9069..00000000 --- a/JSONAPI/Http/IRelatedResourceDocumentMaterializer.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.Documents; - -namespace JSONAPI.Http -{ - /// - /// Crafts a document corresponding to a related resource URL - /// - public interface IRelatedResourceDocumentMaterializer - { - /// - /// Builds a document containing the results of the relationship. - /// - Task GetRelatedResourceDocument(string primaryResourceId, HttpRequestMessage request, CancellationToken cancellationToken); - } -} \ No newline at end of file diff --git a/JSONAPI/Http/ISortExpressionExtractor.cs b/JSONAPI/Http/ISortExpressionExtractor.cs deleted file mode 100644 index 62f9d42f..00000000 --- a/JSONAPI/Http/ISortExpressionExtractor.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Net.Http; - -namespace JSONAPI.Http -{ - /// - /// Service to extract sort expressions from an HTTP request - /// - public interface ISortExpressionExtractor - { - /// - /// Extracts sort expressions from the request - /// - /// - /// - string[] ExtractSortExpressions(HttpRequestMessage requestMessage); - } -} diff --git a/JSONAPI/Http/JsonApiController.cs b/JSONAPI/Http/JsonApiController.cs deleted file mode 100644 index 8bc9bf22..00000000 --- a/JSONAPI/Http/JsonApiController.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using System.Web.Http; -using JSONAPI.Documents; - -namespace JSONAPI.Http -{ - /// - /// This ApiController is capable of serving all requests using JSON API. - /// - public class JsonApiController : ApiController - { - private readonly IDocumentMaterializerLocator _documentMaterializerLocator; - - /// - /// Creates a new JsonApiController - /// - /// The service locator to get document materializers for a given resource type. - public JsonApiController(IDocumentMaterializerLocator documentMaterializerLocator) - { - _documentMaterializerLocator = documentMaterializerLocator; - } - - /// - /// Returns a document corresponding to a set of records of this type. - /// - public virtual async Task GetResourceCollection(string resourceType, CancellationToken cancellationToken) - { - var materializer = _documentMaterializerLocator.GetMaterializerByResourceTypeName(resourceType); - var document = await materializer.GetRecords(Request, cancellationToken); - return Ok(document); - } - - /// - /// Returns a document corresponding to the single record matching the ID. - /// - public virtual async Task Get(string resourceType, string id, CancellationToken cancellationToken) - { - var materializer = _documentMaterializerLocator.GetMaterializerByResourceTypeName(resourceType); - var document = await materializer.GetRecordById(id, Request, cancellationToken); - return Ok(document); - } - - /// - /// Returns a document corresponding to the resource(s) related to the resource identified by the ID, - /// and the relationship name. - /// - public virtual async Task GetRelatedResource(string resourceType, string id, string relationshipName, CancellationToken cancellationToken) - { - var materializer = _documentMaterializerLocator.GetRelatedResourceMaterializer(resourceType, relationshipName); - var document = await materializer.GetRelatedResourceDocument(id, Request, cancellationToken); - return Ok(document); - } - - /// - /// Creates a new record corresponding to the data in the request document. - /// - public virtual async Task Post(string resourceType, [FromBody]ISingleResourceDocument requestDocument, CancellationToken cancellationToken) - { - var materializer = _documentMaterializerLocator.GetMaterializerByResourceTypeName(resourceType); - var document = await materializer.CreateRecord(requestDocument, Request, cancellationToken); - return Ok(document); - } - - /// - /// Updates the record with the given ID with data from the request payload. - /// - public virtual async Task Patch(string resourceType, string id, [FromBody]ISingleResourceDocument requestDocument, CancellationToken cancellationToken) - { - var materializer = _documentMaterializerLocator.GetMaterializerByResourceTypeName(resourceType); - var document = await materializer.UpdateRecord(id, requestDocument, Request, cancellationToken); - return Ok(document); - } - - /// - /// Deletes the record corresponding to the ID. - /// - public virtual async Task Delete(string resourceType, string id, CancellationToken cancellationToken) - { - var materializer = _documentMaterializerLocator.GetMaterializerByResourceTypeName(resourceType); - var document = await materializer.DeleteRecord(id, Request, cancellationToken); - return Ok(document); - } - } -} diff --git a/JSONAPI/Http/MappedDocumentMaterializer.cs b/JSONAPI/Http/MappedDocumentMaterializer.cs deleted file mode 100644 index 4c53c2e0..00000000 --- a/JSONAPI/Http/MappedDocumentMaterializer.cs +++ /dev/null @@ -1,150 +0,0 @@ -using System; -using System.Linq; -using System.Linq.Expressions; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.Core; -using JSONAPI.Documents; -using JSONAPI.Documents.Builders; -using JSONAPI.QueryableTransformers; - -namespace JSONAPI.Http -{ - /// - /// Document materializer for mapping from a database entity to a data transfer object. - /// - /// - /// - public abstract class MappedDocumentMaterializer : IDocumentMaterializer where TDto : class - { - private readonly IQueryableResourceCollectionDocumentBuilder _queryableResourceCollectionDocumentBuilder; - private readonly IBaseUrlService _baseUrlService; - private readonly ISingleResourceDocumentBuilder _singleResourceDocumentBuilder; - private readonly IQueryableEnumerationTransformer _queryableEnumerationTransformer; - private readonly ISortExpressionExtractor _sortExpressionExtractor; - private readonly IResourceTypeRegistry _resourceTypeRegistry; - - /// - /// Gets a query returning all entities for this endpoint - /// - protected abstract IQueryable GetQuery(); - - /// - /// Gets a query for only the entity matching the given ID - /// - protected abstract IQueryable GetByIdQuery(string id); - - /// - /// Gets a query for the DTOs based on the given entity query. - /// - protected abstract IQueryable GetMappedQuery(IQueryable entityQuery, Expression>[] propertiesToInclude); - - /// - /// Creates a new MappedDocumentMaterializer - /// - protected MappedDocumentMaterializer( - IQueryableResourceCollectionDocumentBuilder queryableResourceCollectionDocumentBuilder, - IBaseUrlService baseUrlService, - ISingleResourceDocumentBuilder singleResourceDocumentBuilder, - IQueryableEnumerationTransformer queryableEnumerationTransformer, - ISortExpressionExtractor sortExpressionExtractor, - IResourceTypeRegistry resourceTypeRegistry) - { - _queryableResourceCollectionDocumentBuilder = queryableResourceCollectionDocumentBuilder; - _baseUrlService = baseUrlService; - _singleResourceDocumentBuilder = singleResourceDocumentBuilder; - _queryableEnumerationTransformer = queryableEnumerationTransformer; - _sortExpressionExtractor = sortExpressionExtractor; - _resourceTypeRegistry = resourceTypeRegistry; - } - - private string ResourceTypeName - { - get { return _resourceTypeRegistry.GetRegistrationForType(typeof (TDto)).ResourceTypeName; } - } - - public virtual async Task GetRecords(HttpRequestMessage request, CancellationToken cancellationToken) - { - var entityQuery = GetQuery(); - var includePaths = GetIncludePathsForQuery() ?? new Expression>[] { }; - var jsonApiPaths = includePaths.Select(ConvertToJsonKeyPath).ToArray(); - var mappedQuery = GetMappedQuery(entityQuery, includePaths); - var sortationPaths = _sortExpressionExtractor.ExtractSortExpressions(request); - if (sortationPaths == null || !sortationPaths.Any()) - sortationPaths = GetDefaultSortExpressions(); - - return await _queryableResourceCollectionDocumentBuilder.BuildDocument(mappedQuery, request, sortationPaths, cancellationToken, jsonApiPaths); - } - - public virtual async Task GetRecordById(string id, HttpRequestMessage request, CancellationToken cancellationToken) - { - var entityQuery = GetByIdQuery(id); - var includePaths = GetIncludePathsForSingleResource() ?? new Expression>[] { }; - var jsonApiPaths = includePaths.Select(ConvertToJsonKeyPath).ToArray(); - var mappedQuery = GetMappedQuery(entityQuery, includePaths); - var primaryResource = await _queryableEnumerationTransformer.FirstOrDefault(mappedQuery, cancellationToken); - if (primaryResource == null) - throw JsonApiException.CreateForNotFound( - string.Format("No record exists with type `{0}` and ID `{1}`.", ResourceTypeName, id)); - - await OnResourceFetched(primaryResource, cancellationToken); - - var baseUrl = _baseUrlService.GetBaseUrl(request); - return _singleResourceDocumentBuilder.BuildDocument(primaryResource, baseUrl, jsonApiPaths, null); - } - - public abstract Task CreateRecord(ISingleResourceDocument requestDocument, - HttpRequestMessage request, - CancellationToken cancellationToken); - - public abstract Task UpdateRecord(string id, ISingleResourceDocument requestDocument, - HttpRequestMessage request, - CancellationToken cancellationToken); - - public abstract Task DeleteRecord(string id, HttpRequestMessage request, CancellationToken cancellationToken); - - /// - /// Returns a list of property paths to be included when constructing a query for this resource type - /// - protected virtual Expression>[] GetIncludePathsForQuery() - { - return null; - } - - /// - /// Returns a list of property paths to be included when returning a single resource of this resource type - /// - protected virtual Expression>[] GetIncludePathsForSingleResource() - { - return null; - } - - /// - /// Hook for specifying sort expressions when fetching a collection - /// - /// - protected virtual string[] GetDefaultSortExpressions() - { - return new[] { "id" }; - } - - /// - /// Hook for performing any final modifications to the resource before serialization - /// - /// - /// - /// - protected virtual Task OnResourceFetched(TDto resource, CancellationToken cancellationToken) - { - return Task.FromResult(0); - } - - private string ConvertToJsonKeyPath(Expression> expression) - { - var visitor = new PathVisitor(_resourceTypeRegistry); - visitor.Visit(expression); - return visitor.Path; - } - } -} diff --git a/JSONAPI/Http/QueryableToManyRelatedResourceDocumentMaterializer.cs b/JSONAPI/Http/QueryableToManyRelatedResourceDocumentMaterializer.cs deleted file mode 100644 index 6aa2286f..00000000 --- a/JSONAPI/Http/QueryableToManyRelatedResourceDocumentMaterializer.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Linq; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.Documents; -using JSONAPI.Documents.Builders; - -namespace JSONAPI.Http -{ - /// - /// Base class for implementations of that use IQueryable to get related resources - /// for a to-many relationship. - /// - public abstract class QueryableToManyRelatedResourceDocumentMaterializer : IRelatedResourceDocumentMaterializer - { - private readonly IQueryableResourceCollectionDocumentBuilder _queryableResourceCollectionDocumentBuilder; - private readonly ISortExpressionExtractor _sortExpressionExtractor; - private readonly IIncludeExpressionExtractor _includeExpressionExtractor; - /// - /// List of includes given by url. - /// - protected string[] Includes = {}; - - /// - /// Creates a new QueryableRelatedResourceDocumentMaterializer - /// - protected QueryableToManyRelatedResourceDocumentMaterializer( - IQueryableResourceCollectionDocumentBuilder queryableResourceCollectionDocumentBuilder, - ISortExpressionExtractor sortExpressionExtractor, - IIncludeExpressionExtractor includeExpressionExtractor) - { - _queryableResourceCollectionDocumentBuilder = queryableResourceCollectionDocumentBuilder; - _sortExpressionExtractor = sortExpressionExtractor; - _includeExpressionExtractor = includeExpressionExtractor; - } - - public async Task GetRelatedResourceDocument(string primaryResourceId, HttpRequestMessage request, - CancellationToken cancellationToken) - { - Includes = _includeExpressionExtractor.ExtractIncludeExpressions(request); - var query = await GetRelatedQuery(primaryResourceId, cancellationToken); - var sortExpressions = _sortExpressionExtractor.ExtractSortExpressions(request); - if (sortExpressions == null || sortExpressions.Length < 1) - sortExpressions = GetDefaultSortExpressions(); - - - return await _queryableResourceCollectionDocumentBuilder.BuildDocument(query, request, sortExpressions, cancellationToken, Includes); // TODO: allow implementors to specify metadata - } - - /// - /// Gets the query for the related resources - /// - protected abstract Task> GetRelatedQuery(string primaryResourceId, CancellationToken cancellationToken); - - /// - /// If the client doesn't request any sort expressions, these expressions will be used for sorting instead. - /// - /// - protected virtual string[] GetDefaultSortExpressions() - { - return null; - } - } -} \ No newline at end of file diff --git a/JSONAPI/Http/QueryableToOneRelatedResourceDocumentMaterializer.cs b/JSONAPI/Http/QueryableToOneRelatedResourceDocumentMaterializer.cs deleted file mode 100644 index da9b23f4..00000000 --- a/JSONAPI/Http/QueryableToOneRelatedResourceDocumentMaterializer.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using JSONAPI.Documents; -using JSONAPI.Documents.Builders; - -namespace JSONAPI.Http -{ - /// - /// Base class for implementations of that use IQueryable to get related resources - /// for a to-many relationship. - /// - public abstract class QueryableToOneRelatedResourceDocumentMaterializer : IRelatedResourceDocumentMaterializer - { - private readonly ISingleResourceDocumentBuilder _singleResourceDocumentBuilder; - private readonly IBaseUrlService _baseUrlService; - - /// - /// Creates a new QueryableRelatedResourceDocumentMaterializer - /// - protected QueryableToOneRelatedResourceDocumentMaterializer( - ISingleResourceDocumentBuilder singleResourceDocumentBuilder, IBaseUrlService baseUrlService) - { - _singleResourceDocumentBuilder = singleResourceDocumentBuilder; - _baseUrlService = baseUrlService; - } - - public async Task GetRelatedResourceDocument(string primaryResourceId, HttpRequestMessage request, - CancellationToken cancellationToken) - { - var record = await GetRelatedRecord(primaryResourceId, cancellationToken); - var baseUrl = _baseUrlService.GetBaseUrl(request); - return _singleResourceDocumentBuilder.BuildDocument(record, baseUrl, null, null); // TODO: allow implementors to specify includes and metadata - } - - /// - /// Gets the query for the related resources - /// - protected abstract Task GetRelatedRecord(string primaryResourceId, CancellationToken cancellationToken); - } -} \ No newline at end of file diff --git a/JSONAPI/JSONAPI.csproj b/JSONAPI/JSONAPI.csproj deleted file mode 100644 index 9bd3d2e2..00000000 --- a/JSONAPI/JSONAPI.csproj +++ /dev/null @@ -1,215 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {52B19FD6-EFAA-45B5-9C3E-A652E27608D1} - Library - Properties - JSONAPI - JSONAPI - v4.5 - 512 - ..\ - true - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - bin\Debug\JSONAPI.XML - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - bin\Release\JSONAPI.XML - - - - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - - - - - - - False - ..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll - - - - - False - ..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll - - - False - ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.2\lib\net45\System.Web.Http.WebHost.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/JSONAPI/JSONAPI.nuspec b/JSONAPI/JSONAPI.nuspec deleted file mode 100644 index 1264b22a..00000000 --- a/JSONAPI/JSONAPI.nuspec +++ /dev/null @@ -1,20 +0,0 @@ - - - - $id$ - $version$ - JSONAPI.NET - S'pht'Kr - S'pht'Kr - https://github.com/SphtKr/JSONAPI.NET/blob/master/LICENSE.md - https://github.com/SphtKr/JSONAPI.NET - https://raw.githubusercontent.com/SphtKr/JSONAPI.NET/master/JSONAPI/JSONAPI_NET_icon_512.png - false - A toolkit for using WebAPI to quickly build REST services complying with the JSON API spec (jsonapi.org). - - Bugfix: Issue #1, an unexpected property key in the resource object would cause the parser to hang. - - Copyright 2014 - JSON WebAPI REST ember emberjs ember.js ember-data - - \ No newline at end of file diff --git a/JSONAPI/JSONAPI_NET_icon.xcf b/JSONAPI/JSONAPI_NET_icon.xcf deleted file mode 100644 index 0987e805..00000000 Binary files a/JSONAPI/JSONAPI_NET_icon.xcf and /dev/null differ diff --git a/JSONAPI/JSONAPI_NET_icon_512.png b/JSONAPI/JSONAPI_NET_icon_512.png deleted file mode 100644 index 0a7a6877..00000000 Binary files a/JSONAPI/JSONAPI_NET_icon_512.png and /dev/null differ diff --git a/JSONAPI/JSONAPI_NET_logo.xcf b/JSONAPI/JSONAPI_NET_logo.xcf deleted file mode 100644 index 992eceb9..00000000 Binary files a/JSONAPI/JSONAPI_NET_logo.xcf and /dev/null differ diff --git a/JSONAPI/JSONAPI_NET_logo_512_128.png b/JSONAPI/JSONAPI_NET_logo_512_128.png deleted file mode 100644 index d250b356..00000000 Binary files a/JSONAPI/JSONAPI_NET_logo_512_128.png and /dev/null differ diff --git a/JSONAPI/Json/BasicMetadata.cs b/JSONAPI/Json/BasicMetadata.cs deleted file mode 100644 index 12d5a29e..00000000 --- a/JSONAPI/Json/BasicMetadata.cs +++ /dev/null @@ -1,22 +0,0 @@ -using JSONAPI.Documents; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Json -{ - /// - /// Default implementation of IMetadata - /// - public class BasicMetadata : IMetadata - { - /// - /// Creates a new BasicMetadata - /// - /// - public BasicMetadata(JObject metaObject) - { - MetaObject = metaObject; - } - - public JObject MetaObject { get; private set; } - } -} \ No newline at end of file diff --git a/JSONAPI/Json/DeserializationException.cs b/JSONAPI/Json/DeserializationException.cs deleted file mode 100644 index f6b732d0..00000000 --- a/JSONAPI/Json/DeserializationException.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; - -namespace JSONAPI.Json -{ - /// - /// An exception that may be thrown by document formatters during deserialization - /// in response to a JSON API-noncompliant document being submitted by the client. - /// - public class DeserializationException : Exception - { - /// - /// The title of the error - /// - public string Title { get; private set; } - - /// - /// The path in the document where the error occurred. - /// - public string Pointer { get; private set; } - - /// - /// Creates a new DeserializationException - /// - /// - /// - /// - public DeserializationException(string title, string message, string pointer) - : base(message) - { - Title = title; - Pointer = pointer; - } - } -} diff --git a/JSONAPI/Json/ErrorDocumentFormatter.cs b/JSONAPI/Json/ErrorDocumentFormatter.cs deleted file mode 100644 index a5ef94f4..00000000 --- a/JSONAPI/Json/ErrorDocumentFormatter.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Threading.Tasks; -using JSONAPI.Documents; -using Newtonsoft.Json; - -namespace JSONAPI.Json -{ - /// - /// Default implementation of IErrorDocumentFormatter - /// - public class ErrorDocumentFormatter : IErrorDocumentFormatter - { - private readonly IErrorFormatter _errorFormatter; - private readonly IMetadataFormatter _metadataFormatter; - - /// - /// Creates a new ErrorDocumentFormatter - /// - /// - /// - public ErrorDocumentFormatter(IErrorFormatter errorFormatter, IMetadataFormatter metadataFormatter) - { - _errorFormatter = errorFormatter; - _metadataFormatter = metadataFormatter; - } - - public Task Serialize(IErrorDocument document, JsonWriter writer) - { - writer.WriteStartObject(); - writer.WritePropertyName("errors"); - writer.WriteStartArray(); - foreach (var error in document.Errors) - { - _errorFormatter.Serialize(error, writer); - } - writer.WriteEndArray(); - - if (document.Metadata != null) - { - writer.WritePropertyName("meta"); - _metadataFormatter.Serialize(document.Metadata, writer); - } - - writer.WriteEndObject(); - - return Task.FromResult(0); - } - - public Task Deserialize(JsonReader reader, string currentPath) - { - // The client should never be sending us errors. - throw new NotSupportedException(); - } - } -} diff --git a/JSONAPI/Json/ErrorFormatter.cs b/JSONAPI/Json/ErrorFormatter.cs deleted file mode 100644 index d1e33337..00000000 --- a/JSONAPI/Json/ErrorFormatter.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using System.Net; -using System.Threading.Tasks; -using JSONAPI.Documents; -using Newtonsoft.Json; - -namespace JSONAPI.Json -{ - /// - /// Default implementation of IErrorFormatter - /// - public class ErrorFormatter : IErrorFormatter - { - private readonly ILinkFormatter _linkFormatter; - private readonly IMetadataFormatter _metadataFormatter; - - /// - /// Creates a new errorFormatter - /// - /// - /// - public ErrorFormatter(ILinkFormatter linkFormatter, IMetadataFormatter metadataFormatter) - { - _linkFormatter = linkFormatter; - _metadataFormatter = metadataFormatter; - } - - public Task Serialize(IError error, JsonWriter writer) - { - writer.WriteStartObject(); - - if (error.Id != null) - { - writer.WritePropertyName("id"); - writer.WriteValue(error.Id); - } - - if (error.AboutLink != null) - { - writer.WritePropertyName("links"); - writer.WriteStartObject(); - writer.WritePropertyName("about"); - _linkFormatter.Serialize(error.AboutLink, writer); - writer.WriteEndObject(); - } - - if (error.Status != default(HttpStatusCode)) - { - writer.WritePropertyName("status"); - writer.WriteValue(((int)error.Status).ToString()); - } - - if (error.Code != null) - { - writer.WritePropertyName("code"); - writer.WriteValue(error.Code); - } - - if (error.Title != null) - { - writer.WritePropertyName("title"); - writer.WriteValue(error.Title); - } - - if (error.Detail != null) - { - writer.WritePropertyName("detail"); - writer.WriteValue(error.Detail); - } - - if (error.Pointer != null || error.Parameter != null) - { - writer.WritePropertyName("source"); - writer.WriteStartObject(); - if (error.Pointer != null) - { - writer.WritePropertyName("pointer"); - writer.WriteValue(error.Pointer); - } - if (error.Parameter != null) - { - writer.WritePropertyName("parameter"); - writer.WriteValue(error.Parameter); - } - writer.WriteEndObject(); - } - - if (error.Metadata != null) - { - writer.WritePropertyName("meta"); - _metadataFormatter.Serialize(error.Metadata, writer); - } - - writer.WriteEndObject(); - - return Task.FromResult(0); - } - - public Task Deserialize(JsonReader reader, string currentPath) - { - // The client should never be sending us errors - throw new NotSupportedException(); - } - } -} \ No newline at end of file diff --git a/JSONAPI/Json/IErrorDocumentFormatter.cs b/JSONAPI/Json/IErrorDocumentFormatter.cs deleted file mode 100644 index 01efeb71..00000000 --- a/JSONAPI/Json/IErrorDocumentFormatter.cs +++ /dev/null @@ -1,11 +0,0 @@ -using JSONAPI.Documents; - -namespace JSONAPI.Json -{ - /// - /// Service responsible for serializing IErrorDocument instances - /// - public interface IErrorDocumentFormatter : IJsonApiFormatter - { - } -} \ No newline at end of file diff --git a/JSONAPI/Json/IErrorFormatter.cs b/JSONAPI/Json/IErrorFormatter.cs deleted file mode 100644 index 9417b053..00000000 --- a/JSONAPI/Json/IErrorFormatter.cs +++ /dev/null @@ -1,11 +0,0 @@ -using JSONAPI.Documents; - -namespace JSONAPI.Json -{ - /// - /// Service responsible for serializing IError instances - /// - public interface IErrorFormatter : IJsonApiFormatter - { - } -} \ No newline at end of file diff --git a/JSONAPI/Json/IJsonApiFormatter.cs b/JSONAPI/Json/IJsonApiFormatter.cs deleted file mode 100644 index 4ddae298..00000000 --- a/JSONAPI/Json/IJsonApiFormatter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Threading.Tasks; -using Newtonsoft.Json; - -namespace JSONAPI.Json -{ - /// - /// Interface responsible for serializing and deserializing JSON API document components - /// - /// The type of component this service can format - public interface IJsonApiFormatter - { - /// - /// Serializes the given component - /// - /// The component to serialize - /// The JSON writer to serialize with - /// A task that resolves when serialization is complete. - Task Serialize(T component, JsonWriter writer); - - /// - /// Deserializes the given component - /// - /// The JSON reader to deserialize with - /// A JSON pointer pointing to the current thing being deserialized - /// - /// A task that resolves with the deserialized object - Task Deserialize(JsonReader reader, string currentPath); - } -} \ No newline at end of file diff --git a/JSONAPI/Json/ILinkFormatter.cs b/JSONAPI/Json/ILinkFormatter.cs deleted file mode 100644 index 93a8e5c3..00000000 --- a/JSONAPI/Json/ILinkFormatter.cs +++ /dev/null @@ -1,11 +0,0 @@ -using JSONAPI.Documents; - -namespace JSONAPI.Json -{ - /// - /// Service responsible for serializing ILink instances - /// - public interface ILinkFormatter : IJsonApiFormatter - { - } -} \ No newline at end of file diff --git a/JSONAPI/Json/IMetadataFormatter.cs b/JSONAPI/Json/IMetadataFormatter.cs deleted file mode 100644 index fe6d61c3..00000000 --- a/JSONAPI/Json/IMetadataFormatter.cs +++ /dev/null @@ -1,11 +0,0 @@ -using JSONAPI.Documents; - -namespace JSONAPI.Json -{ - /// - /// Service responsible for serializing IMetadata instances - /// - public interface IMetadataFormatter : IJsonApiFormatter - { - } -} \ No newline at end of file diff --git a/JSONAPI/Json/IRelationshipObjectFormatter.cs b/JSONAPI/Json/IRelationshipObjectFormatter.cs deleted file mode 100644 index 8762a1d9..00000000 --- a/JSONAPI/Json/IRelationshipObjectFormatter.cs +++ /dev/null @@ -1,11 +0,0 @@ -using JSONAPI.Documents; - -namespace JSONAPI.Json -{ - /// - /// Service responsible for serializing IRelationshipObject instances - /// - public interface IRelationshipObjectFormatter : IJsonApiFormatter - { - } -} \ No newline at end of file diff --git a/JSONAPI/Json/IResourceCollectionDocumentFormatter.cs b/JSONAPI/Json/IResourceCollectionDocumentFormatter.cs deleted file mode 100644 index 03a97970..00000000 --- a/JSONAPI/Json/IResourceCollectionDocumentFormatter.cs +++ /dev/null @@ -1,11 +0,0 @@ -using JSONAPI.Documents; - -namespace JSONAPI.Json -{ - /// - /// Service responsible for formatting IResourceCollectionDocument instances - /// - public interface IResourceCollectionDocumentFormatter : IJsonApiFormatter - { - } -} \ No newline at end of file diff --git a/JSONAPI/Json/IResourceLinkageFormatter.cs b/JSONAPI/Json/IResourceLinkageFormatter.cs deleted file mode 100644 index eb4d0d6b..00000000 --- a/JSONAPI/Json/IResourceLinkageFormatter.cs +++ /dev/null @@ -1,11 +0,0 @@ -using JSONAPI.Documents; - -namespace JSONAPI.Json -{ - /// - /// Service responsible for serializing IResourceLinkage instances - /// - public interface IResourceLinkageFormatter : IJsonApiFormatter - { - } -} \ No newline at end of file diff --git a/JSONAPI/Json/IResourceObjectFormatter.cs b/JSONAPI/Json/IResourceObjectFormatter.cs deleted file mode 100644 index c3be78f0..00000000 --- a/JSONAPI/Json/IResourceObjectFormatter.cs +++ /dev/null @@ -1,11 +0,0 @@ -using JSONAPI.Documents; - -namespace JSONAPI.Json -{ - /// - /// Service responsible for serializing IResourceObject instances - /// - public interface IResourceObjectFormatter : IJsonApiFormatter - { - } -} \ No newline at end of file diff --git a/JSONAPI/Json/ISingleResourceDocumentFormatter.cs b/JSONAPI/Json/ISingleResourceDocumentFormatter.cs deleted file mode 100644 index 0d9174b8..00000000 --- a/JSONAPI/Json/ISingleResourceDocumentFormatter.cs +++ /dev/null @@ -1,11 +0,0 @@ -using JSONAPI.Documents; - -namespace JSONAPI.Json -{ - /// - /// Service responsible for formatting ISingleResourceDocument instances - /// - public interface ISingleResourceDocumentFormatter : IJsonApiFormatter - { - } -} \ No newline at end of file diff --git a/JSONAPI/Json/JsonApiFormatter.cs b/JSONAPI/Json/JsonApiFormatter.cs deleted file mode 100644 index 4d1ddfa6..00000000 --- a/JSONAPI/Json/JsonApiFormatter.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Net.Http; -using System.Net.Http.Formatting; -using System.Net.Http.Headers; -using System.Threading.Tasks; -using System.Web.Http; -using JSONAPI.Documents; -using JSONAPI.Documents.Builders; -using Newtonsoft.Json; - -namespace JSONAPI.Json -{ - /// - /// MediaTypeFormatter for JSON API - /// - public class JsonApiFormatter : JsonMediaTypeFormatter - { - private readonly ISingleResourceDocumentFormatter _singleResourceDocumentFormatter; - private readonly IResourceCollectionDocumentFormatter _resourceCollectionDocumentFormatter; - private readonly IErrorDocumentFormatter _errorDocumentFormatter; - private readonly IErrorDocumentBuilder _errorDocumentBuilder; - - /// - /// Creates a new JsonApiFormatter - /// - public JsonApiFormatter(ISingleResourceDocumentFormatter singleResourceDocumentFormatter, - IResourceCollectionDocumentFormatter resourceCollectionDocumentFormatter, - IErrorDocumentFormatter errorDocumentFormatter, - IErrorDocumentBuilder errorDocumentBuilder) - { - _singleResourceDocumentFormatter = singleResourceDocumentFormatter; - _resourceCollectionDocumentFormatter = resourceCollectionDocumentFormatter; - _errorDocumentFormatter = errorDocumentFormatter; - _errorDocumentBuilder = errorDocumentBuilder; - - SupportedMediaTypes.Clear(); - SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/vnd.api+json")); - } - - public override bool CanReadType(Type t) - { - return true; - } - - public override bool CanWriteType(Type t) - { - return true; - } - - public override async Task WriteToStreamAsync(Type type, object value, Stream writeStream, HttpContent content, TransportContext transportContext) - { - if (type == typeof(IJsonApiDocument) && value == null) - return; - - var contentHeaders = content == null ? null : content.Headers; - var effectiveEncoding = SelectCharacterEncoding(contentHeaders); - var writer = CreateJsonWriter(typeof(object), writeStream, effectiveEncoding); - - var singleResourceDocument = value as ISingleResourceDocument; - var resourceCollectionDocument = value as IResourceCollectionDocument; - var errorDocument = value as IErrorDocument; - if (singleResourceDocument != null) - { - await _singleResourceDocumentFormatter.Serialize(singleResourceDocument, writer); - } - else if (resourceCollectionDocument != null) - { - await _resourceCollectionDocumentFormatter.Serialize(resourceCollectionDocument, writer); - } - else if (errorDocument != null) - { - await _errorDocumentFormatter.Serialize(errorDocument, writer); - } - else - { - var error = value as HttpError; - if (error != null) - { - var httpErrorDocument = _errorDocumentBuilder.BuildFromHttpError(error, HttpStatusCode.InternalServerError); - await _errorDocumentFormatter.Serialize(httpErrorDocument, writer); - } - else - { - WriteErrorForUnsupportedType(value, writer); - } - } - - writer.Flush(); - } - - public override async Task ReadFromStreamAsync(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger) - { - var contentHeaders = content == null ? null : content.Headers; - var effectiveEncoding = SelectCharacterEncoding(contentHeaders); - var reader = CreateJsonReader(typeof(IDictionary), readStream, - effectiveEncoding); - reader.DateParseHandling = DateParseHandling.None; // We will decide whether to parse as a DateTime or DateTimeOffset according to the attribute type - - reader.Read(); - - if (typeof(ISingleResourceDocument).IsAssignableFrom(type)) - return await _singleResourceDocumentFormatter.Deserialize(reader, ""); - if (typeof(IResourceCollectionDocument).IsAssignableFrom(type)) - return await _resourceCollectionDocumentFormatter.Deserialize(reader, ""); - - throw new Exception(string.Format("The type {0} is not supported for deserialization.", type.Name)); - } - - private void WriteErrorForUnsupportedType(object obj, JsonWriter writer) - { - writer.WriteStartObject(); - writer.WritePropertyName("title"); - writer.WriteValue("Unexpected Content"); - writer.WritePropertyName("detail"); - writer.WriteValue("The JsonApiFormatter was asked to serialize an unsupported object."); - writer.WritePropertyName("meta"); - writer.WriteStartObject(); - writer.WritePropertyName("objectTypeName"); - writer.WriteValue(obj.GetType().Name); - writer.WriteEndObject(); - writer.WriteEndObject(); - } - } -} diff --git a/JSONAPI/Json/JsonHelpers.cs b/JSONAPI/Json/JsonHelpers.cs deleted file mode 100644 index a47c48e7..00000000 --- a/JSONAPI/Json/JsonHelpers.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Text.RegularExpressions; - -namespace JSONAPI.Json -{ - static class JsonHelpers - { - // http://stackoverflow.com/questions/8913138/minify-indented-json-string-in-net - public static string MinifyJson(string input) - { - return Regex.Replace(input, "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1"); - } - } -} diff --git a/JSONAPI/Json/LinkFormatter.cs b/JSONAPI/Json/LinkFormatter.cs deleted file mode 100644 index 8f0331b5..00000000 --- a/JSONAPI/Json/LinkFormatter.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Threading.Tasks; -using JSONAPI.Documents; -using Newtonsoft.Json; - -namespace JSONAPI.Json -{ - /// - /// Default implementation of ILinkFormatter - /// - public class LinkFormatter : ILinkFormatter - { - private IMetadataFormatter _metadataFormatter; - private const string HrefKeyName = "href"; - private const string MetaKeyName = "meta"; - - /// - /// Constructs a LinkFormatter - /// - public LinkFormatter() - { - - } - - /// - /// Constructs a LinkFormatter - /// - /// - public LinkFormatter(IMetadataFormatter metadataFormatter) - { - _metadataFormatter = metadataFormatter; - } - - /// - /// The formatter to use for metadata on the link object - /// - /// - public IMetadataFormatter MetadataFormatter - { - get - { - return _metadataFormatter ?? (_metadataFormatter = new MetadataFormatter()); - } - set - { - if (_metadataFormatter != null) throw new InvalidOperationException("This property can only be set once."); - _metadataFormatter = value; - } - } - - public Task Serialize(ILink link, JsonWriter writer) - { - if (link.Metadata == null) - { - writer.WriteValue(link.Href); - } - else - { - writer.WriteStartObject(); - writer.WritePropertyName(HrefKeyName); - writer.WriteValue(link.Href); - writer.WritePropertyName(MetaKeyName); - MetadataFormatter.Serialize(link.Metadata, writer); - writer.WriteEndObject(); - } - return Task.FromResult(0); - } - - public Task Deserialize(JsonReader reader, string currentPath) - { - // The client should never be sending us links. - throw new NotSupportedException(); - } - } -} \ No newline at end of file diff --git a/JSONAPI/Json/MetadataFormatter.cs b/JSONAPI/Json/MetadataFormatter.cs deleted file mode 100644 index a693fdf7..00000000 --- a/JSONAPI/Json/MetadataFormatter.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Threading.Tasks; -using JSONAPI.Documents; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Json -{ - /// - /// Default implementation of IMetadataFormatter - /// - public class MetadataFormatter : IMetadataFormatter - { - public Task Serialize(IMetadata metadata, JsonWriter writer) - { - if (metadata == null) - { - writer.WriteNull(); - } - else - { - if (metadata.MetaObject == null) - throw new JsonSerializationException("The meta object cannot be null."); - metadata.MetaObject.WriteTo(writer); - } - return Task.FromResult(0); - } - - public Task Deserialize(JsonReader reader, string currentPath) - { - IMetadata metadata; - if (reader.TokenType == JsonToken.Null) - { - metadata = null; - } - else if (reader.TokenType == JsonToken.StartObject) - { - var obj = (JObject)JToken.ReadFrom(reader); - metadata = new BasicMetadata(obj); - } - else - { - throw new DeserializationException("", "Expected an object or null for `meta`, but got " + reader.TokenType, currentPath); - } - - return Task.FromResult(metadata); - } - } -} \ No newline at end of file diff --git a/JSONAPI/Json/RelationshipObjectFormatter.cs b/JSONAPI/Json/RelationshipObjectFormatter.cs deleted file mode 100644 index a41c8411..00000000 --- a/JSONAPI/Json/RelationshipObjectFormatter.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System; -using System.Threading.Tasks; -using JSONAPI.Documents; -using Newtonsoft.Json; - -namespace JSONAPI.Json -{ - /// - /// Default implementation of IRelationshipObjectFormatter - /// - public class RelationshipObjectFormatter : IRelationshipObjectFormatter - { - private const string LinksKeyName = "links"; - private const string SelfLinkKeyName = "self"; - private const string RelatedLinkKeyName = "related"; - private const string LinkageKeyName = "data"; - private const string MetaKeyName = "meta"; - - private ILinkFormatter _linkFormatter; - private IResourceLinkageFormatter _resourceLinkageFormatter; - private IMetadataFormatter _metadataFormatter; - - /// - /// Creates a new RelationshipObjectFormatter - /// - public RelationshipObjectFormatter () - { - - } - - /// - /// Creates a new RelationshipObjectFormatter - /// - public RelationshipObjectFormatter(ILinkFormatter linkFormatter, IResourceLinkageFormatter resourceLinkageFormatter, IMetadataFormatter metadataFormatter) - { - _linkFormatter = linkFormatter; - _resourceLinkageFormatter = resourceLinkageFormatter; - _metadataFormatter = metadataFormatter; - } - - private ILinkFormatter LinkFormatter - { - get - { - return _linkFormatter ?? (_linkFormatter = new LinkFormatter()); - } - set - { - if (_linkFormatter != null) throw new InvalidOperationException("This property can only be set once."); - _linkFormatter = value; - } - } - - private IResourceLinkageFormatter ResourceLinkageFormatter - { - get - { - return _resourceLinkageFormatter ?? (_resourceLinkageFormatter = new ResourceLinkageFormatter()); - } - set - { - if (_resourceLinkageFormatter != null) throw new InvalidOperationException("This property can only be set once."); - _resourceLinkageFormatter = value; - } - } - - private IMetadataFormatter MetadataFormatter - { - get - { - return _metadataFormatter ?? (_metadataFormatter = new MetadataFormatter()); - } - set - { - if (_metadataFormatter != null) throw new InvalidOperationException("This property can only be set once."); - _metadataFormatter = value; - } - } - - public Task Serialize(IRelationshipObject relationshipObject, JsonWriter writer) - { - if (relationshipObject.Metadata == null && relationshipObject.SelfLink == null && - relationshipObject.RelatedResourceLink == null && relationshipObject.Linkage == null) - throw new JsonSerializationException( - String.Format("At least one of `{0}`, `{1}`, or `{2}` must be present in a relationship object.", - LinksKeyName, LinkageKeyName, MetaKeyName)); - - writer.WriteStartObject(); - SerializeLinks(relationshipObject, writer); - SerializeLinkage(relationshipObject, writer); - SerializeMetadata(relationshipObject, writer); - writer.WriteEndObject(); - - return Task.FromResult(0); - } - - /// - /// Serializes the relationship object's links. - /// - protected virtual void SerializeLinks(IRelationshipObject relationshipObject, JsonWriter writer) - { - if (relationshipObject.SelfLink != null || relationshipObject.RelatedResourceLink != null) - { - writer.WritePropertyName(LinksKeyName); - writer.WriteStartObject(); - - if (relationshipObject.SelfLink != null) - { - writer.WritePropertyName(SelfLinkKeyName); - LinkFormatter.Serialize(relationshipObject.SelfLink, writer); - } - if (relationshipObject.RelatedResourceLink != null) - { - writer.WritePropertyName(RelatedLinkKeyName); - LinkFormatter.Serialize(relationshipObject.RelatedResourceLink, writer); - } - - writer.WriteEndObject(); - } - } - - /// - /// Serializes the relationship object's linkage. - /// - protected virtual void SerializeLinkage(IRelationshipObject relationshipObject, JsonWriter writer) - { - if (relationshipObject.Linkage != null) - { - writer.WritePropertyName(LinkageKeyName); - ResourceLinkageFormatter.Serialize(relationshipObject.Linkage, writer); - } - } - - /// - /// Serializes the relationship object's metadata. - /// - protected virtual void SerializeMetadata(IRelationshipObject relationshipObject, JsonWriter writer) - { - if (relationshipObject.Metadata != null) - { - writer.WritePropertyName(MetaKeyName); - MetadataFormatter.Serialize(relationshipObject.Metadata, writer); - } - } - - public async Task Deserialize(JsonReader reader, string currentPath) - { - if (reader.TokenType != JsonToken.StartObject) - throw new DeserializationException("Invalid relationship object", "Expected an object, but found " + reader.TokenType, currentPath); - - IResourceLinkage linkage = null; - IMetadata metadata = null; - - while (reader.Read()) - { - if (reader.TokenType == JsonToken.EndObject) - break; - - var propertyName = (string)reader.Value; - reader.Read(); - switch (propertyName) - { - case LinkageKeyName: - linkage = await ResourceLinkageFormatter.Deserialize(reader, currentPath + "/" + LinkageKeyName); - break; - case MetaKeyName: - metadata = await MetadataFormatter.Deserialize(reader, currentPath + "/" + MetaKeyName); - break; - } - } - - return new RelationshipObject(linkage, metadata); - } - } -} \ No newline at end of file diff --git a/JSONAPI/Json/ResourceCollectionDocumentFormatter.cs b/JSONAPI/Json/ResourceCollectionDocumentFormatter.cs deleted file mode 100644 index b7a0c999..00000000 --- a/JSONAPI/Json/ResourceCollectionDocumentFormatter.cs +++ /dev/null @@ -1,172 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using JSONAPI.Documents; -using Newtonsoft.Json; - -namespace JSONAPI.Json -{ - /// - /// Default implementation of IResourceCollectionDocumentFormatter - /// - public class ResourceCollectionDocumentFormatter : IResourceCollectionDocumentFormatter - { - private IResourceObjectFormatter _resourceObjectFormatter; - private IMetadataFormatter _metadataFormatter; - private const string PrimaryDataKeyName = "data"; - private const string RelatedDataKeyName = "included"; - private const string MetaKeyName = "meta"; - - /// - /// Creates a ResourceCollectionDocumentFormatter - /// - public ResourceCollectionDocumentFormatter() - { - - } - - /// - /// Creates a ResourceCollectionDocumentFormatter - /// - /// - /// - public ResourceCollectionDocumentFormatter(IResourceObjectFormatter resourceObjectFormatter, IMetadataFormatter metadataFormatter) - { - _resourceObjectFormatter = resourceObjectFormatter; - _metadataFormatter = metadataFormatter; - } - - /// - /// The formatter to use for resource objects found in this document - /// - /// - public IResourceObjectFormatter ResourceObjectFormatter - { - get - { - return _resourceObjectFormatter ?? (_resourceObjectFormatter = new ResourceObjectFormatter()); - } - set - { - if (_resourceObjectFormatter != null) throw new InvalidOperationException("This property can only be set once."); - _resourceObjectFormatter = value; - } - } - - /// - /// The formatter to use for document-level metadata - /// - /// - public IMetadataFormatter MetadataFormatter - { - get - { - return _metadataFormatter ?? (_metadataFormatter = new MetadataFormatter()); - } - set - { - if (_metadataFormatter != null) throw new InvalidOperationException("This property can only be set once."); - _metadataFormatter = value; - } - } - - public Task Serialize(IResourceCollectionDocument document, JsonWriter writer) - { - writer.WriteStartObject(); - - if (document.Metadata != null) - { - writer.WritePropertyName(MetaKeyName); - MetadataFormatter.Serialize(document.Metadata, writer); - } - - writer.WritePropertyName(PrimaryDataKeyName); - - writer.WriteStartArray(); - foreach (var resourceObject in document.PrimaryData) - { - ResourceObjectFormatter.Serialize(resourceObject, writer); - } - writer.WriteEndArray(); - - if (document.RelatedData != null && document.RelatedData.Any()) - { - writer.WritePropertyName(RelatedDataKeyName); - writer.WriteStartArray(); - foreach (var resourceObject in document.RelatedData) - { - ResourceObjectFormatter.Serialize(resourceObject, writer); - } - writer.WriteEndArray(); - } - - - - writer.WriteEndObject(); - - writer.Flush(); - - return Task.FromResult(0); - } - - public async Task Deserialize(JsonReader reader, string currentPath) - { - if (reader.TokenType != JsonToken.StartObject) - throw new JsonSerializationException("Document root is not an object!"); - - IResourceObject[] primaryData = null; - IMetadata metadata = null; - - while (reader.Read()) - { - if (reader.TokenType != JsonToken.PropertyName) break; - - // Has to be a property name - var propertyName = (string)reader.Value; - reader.Read(); - - switch (propertyName) - { - case RelatedDataKeyName: - // TODO: If we want to capture related resources, this would be the place to do it - reader.Skip(); - break; - case PrimaryDataKeyName: - primaryData = await DeserializePrimaryData(reader, currentPath + "/" + PrimaryDataKeyName); - break; - case MetaKeyName: - metadata = await MetadataFormatter.Deserialize(reader, currentPath + "/" + MetaKeyName); - break; - default: - reader.Skip(); - break; - } - } - - return new ResourceCollectionDocument(primaryData ?? new IResourceObject[] { }, new IResourceObject[] { }, metadata); - } - - private async Task DeserializePrimaryData(JsonReader reader, string currentPath) - { - if (reader.TokenType != JsonToken.StartArray) - throw new JsonSerializationException("Expected an array, but encountered " + reader.TokenType); - - var primaryData = new List(); - - var index = 0; - while (reader.Read()) - { - if (reader.TokenType == JsonToken.EndArray) - break; - - var resourceObject = await ResourceObjectFormatter.Deserialize(reader, currentPath + "/" + index); - primaryData.Add(resourceObject); - - index++; - } - - return primaryData.ToArray(); - } - } -} \ No newline at end of file diff --git a/JSONAPI/Json/ResourceLinkageFormatter.cs b/JSONAPI/Json/ResourceLinkageFormatter.cs deleted file mode 100644 index 538b5255..00000000 --- a/JSONAPI/Json/ResourceLinkageFormatter.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System.Linq; -using System.Threading.Tasks; -using JSONAPI.Documents; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Json -{ - /// - /// Default implementation of IResourceLinkageFormatter - /// - public class ResourceLinkageFormatter : IResourceLinkageFormatter - { - public Task Serialize(IResourceLinkage linkage, JsonWriter writer) - { - if (linkage.IsToMany) - { - writer.WriteStartArray(); - foreach (var resourceIdentifier in linkage.Identifiers) - { - WriteResourceIdentifier(resourceIdentifier, writer); - } - writer.WriteEndArray(); - } - else - { - var initialIdentifier = linkage.Identifiers.FirstOrDefault(); - if (initialIdentifier == null) - writer.WriteNull(); - else - { - WriteResourceIdentifier(initialIdentifier, writer); - } - - } - return Task.FromResult(0); - } - - private void WriteResourceIdentifier(IResourceIdentifier resourceIdentifier, JsonWriter writer) - { - writer.WriteStartObject(); - writer.WritePropertyName("type"); - writer.WriteValue(resourceIdentifier.Type); - writer.WritePropertyName("id"); - writer.WriteValue(resourceIdentifier.Id); - writer.WriteEndObject(); - } - - public Task Deserialize(JsonReader reader, string currentPath) - { - IResourceLinkage linkage; - if (reader.TokenType == JsonToken.StartArray) - { - var array = JToken.ReadFrom(reader); - var resourceIdentifiers = array.Select(t => ReadResourceIdentifier(t, currentPath)).ToArray(); - - linkage = new ToManyResourceLinkage(resourceIdentifiers); - } - else if (reader.TokenType == JsonToken.StartObject) - { - var obj = JToken.ReadFrom(reader); - var resourceIdentifier = ReadResourceIdentifier(obj, currentPath); - - linkage = new ToOneResourceLinkage(resourceIdentifier); - } - else if (reader.TokenType == JsonToken.Null) - { - linkage = new ToOneResourceLinkage(null); - } - else - { - throw new DeserializationException("Invalid linkage for relationship", - "Expected an array, object, or null for linkage, but got " + reader.TokenType, currentPath); - } - - return Task.FromResult(linkage); - } - - private IResourceIdentifier ReadResourceIdentifier(JToken t, string currentPath) - { - var jobject = t as JObject; - if (jobject == null) - throw new DeserializationException("Invalid resource identifier", "Resource identifiers must be an object.", currentPath); - - var typeToken = jobject["type"]; - if (typeToken == null) - throw new DeserializationException("Resource identifier missing type", "The `type` key is missing.", currentPath); - if (typeToken.Type != JTokenType.String) - throw new DeserializationException("Resource identifier type invalid", - "Expected a string value for `type` but encountered " + typeToken.Type, currentPath + "/type"); - - var type = typeToken.Value(); - if (string.IsNullOrWhiteSpace(type)) - throw new DeserializationException("Resource identifier type empty", "The `type` key cannot be empty or whitespace.", currentPath + "/type"); - - var idToken = jobject["id"]; - if (idToken == null) - throw new DeserializationException("Resource identifier missing id", "The `id` key is missing.", currentPath); - if (idToken.Type != JTokenType.String) - throw new DeserializationException("Resource identifier id invalid", - "Expected a string value for `id` but encountered " + idToken.Type, currentPath + "/id"); - - var id = idToken.Value(); - if (string.IsNullOrWhiteSpace(id)) - throw new DeserializationException("Resource identifier id empty", "The `id` key cannot be empty or whitespace.", currentPath + "/id"); - - return new ResourceIdentifier(type, id); - } - } -} \ No newline at end of file diff --git a/JSONAPI/Json/ResourceObjectFormatter.cs b/JSONAPI/Json/ResourceObjectFormatter.cs deleted file mode 100644 index 18907217..00000000 --- a/JSONAPI/Json/ResourceObjectFormatter.cs +++ /dev/null @@ -1,272 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using JSONAPI.Documents; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace JSONAPI.Json -{ - /// - /// Default implementation of IResourceObjectFormatter - /// - public class ResourceObjectFormatter : IResourceObjectFormatter - { - private IRelationshipObjectFormatter _relationshipObjectFormatter; - private ILinkFormatter _linkFormatter; - private IMetadataFormatter _metadataFormatter; - private const string TypeKeyName = "type"; - private const string IdKeyName = "id"; - private const string AttributesKeyName = "attributes"; - private const string RelationshipsKeyName = "relationships"; - private const string MetaKeyName = "meta"; - private const string LinksKeyName = "links"; - private const string SelfLinkKeyName = "self"; - - /// - /// Constructs a new ResourceObjectFormatter - /// - public ResourceObjectFormatter() - { - - } - - /// - /// Constructs a new ResourceObjectFormatter - /// - /// The formatter to use for relationship objects - /// The formatter to use for links - /// The formatter to use for metadata - public ResourceObjectFormatter(IRelationshipObjectFormatter relationshipObjectFormatter, ILinkFormatter linkFormatter, IMetadataFormatter metadataFormatter) - { - _relationshipObjectFormatter = relationshipObjectFormatter; - _linkFormatter = linkFormatter; - _metadataFormatter = metadataFormatter; - } - - /// - /// The formatter to use for relationship objects belonging to this resource - /// - /// - public IRelationshipObjectFormatter RelationshipObjectFormatter - { - get - { - return _relationshipObjectFormatter ?? (_relationshipObjectFormatter = new RelationshipObjectFormatter()); - } - set - { - if (_relationshipObjectFormatter != null) throw new InvalidOperationException("This property can only be set once."); - _relationshipObjectFormatter = value; - } - } - - /// - /// The formatter to use for links - /// - /// - public ILinkFormatter LinkFormatter - { - get - { - return _linkFormatter ?? (_linkFormatter = new LinkFormatter()); - } - set - { - if (_linkFormatter != null) throw new InvalidOperationException("This property can only be set once."); - _linkFormatter = value; - } - } - - /// - /// The formatter to use for metadata that belongs to this resource object - /// - /// - public IMetadataFormatter MetadataFormatter - { - get - { - return _metadataFormatter ?? (_metadataFormatter = new MetadataFormatter()); - } - set - { - if (_metadataFormatter != null) throw new InvalidOperationException("This property can only be set once."); - _metadataFormatter = value; - } - } - - public Task Serialize(IResourceObject resourceObject, JsonWriter writer) - { - if (resourceObject == null) - { - writer.WriteNull(); - return Task.FromResult(0); - } - - writer.WriteStartObject(); - - writer.WritePropertyName(TypeKeyName); - writer.WriteValue(resourceObject.Type); - writer.WritePropertyName(IdKeyName); - writer.WriteValue(resourceObject.Id); - - if (resourceObject.Attributes != null && resourceObject.Attributes.Any()) - { - writer.WritePropertyName(AttributesKeyName); - writer.WriteStartObject(); - foreach (var attribute in resourceObject.Attributes) - { - writer.WritePropertyName(attribute.Key); - if (attribute.Value == null) - writer.WriteNull(); - else - { - if (attribute.Value.Type == JTokenType.Integer) - { - var ulongValue = attribute.Value.Value(); - if (ulongValue > long.MaxValue) - { - writer.WriteRawValue(ulongValue.ToString()); - continue; - } - } - attribute.Value.WriteTo(writer); - } - } - writer.WriteEndObject(); - } - - if (resourceObject.Relationships != null) - { - var relationshipsToRender = resourceObject.Relationships.Where(r => r.Value != null).ToArray(); - if (relationshipsToRender.Any()) - { - writer.WritePropertyName(RelationshipsKeyName); - writer.WriteStartObject(); - foreach (var relationship in relationshipsToRender) - { - if (relationship.Value == null) continue; - writer.WritePropertyName(relationship.Key); - RelationshipObjectFormatter.Serialize(relationship.Value, writer); - } - writer.WriteEndObject(); - } - } - - if (resourceObject.SelfLink != null) - { - writer.WritePropertyName(LinksKeyName); - writer.WriteStartObject(); - writer.WritePropertyName(SelfLinkKeyName); - LinkFormatter.Serialize(resourceObject.SelfLink, writer); - writer.WriteEndObject(); - } - - if (resourceObject.Metadata != null) - { - writer.WritePropertyName(MetaKeyName); - MetadataFormatter.Serialize(resourceObject.Metadata, writer); - } - - writer.WriteEndObject(); - - return Task.FromResult(0); - } - - public async Task Deserialize(JsonReader reader, string currentPath) - { - if (reader.TokenType != JsonToken.StartObject) - throw new DeserializationException("Invalid resource object", "Expected an object.", currentPath); - - string type = null; - string id = null; - IMetadata metadata = null; - IDictionary attributes = null; - IDictionary relationships = null; - - while (reader.Read()) - { - if (reader.TokenType == JsonToken.EndObject) - break; - - var propertyName = (string)reader.Value; - reader.Read(); - - switch (propertyName) - { - case TypeKeyName: - type = (string) reader.Value; - break; - case IdKeyName: - id = (string) reader.Value; - break; - case MetaKeyName: - metadata = await MetadataFormatter.Deserialize(reader, currentPath + "/" + MetaKeyName); - break; - case AttributesKeyName: - attributes = DeserializeAttributes(reader, currentPath + "/" + AttributesKeyName); - break; - case RelationshipsKeyName: - relationships = await DeserializeRelationships(reader, currentPath + "/" + RelationshipsKeyName); - break; - default: - reader.Skip(); - break; - } - } - - if (string.IsNullOrEmpty(type)) - throw new DeserializationException("Resource object missing type", "Expected a value for `type`", currentPath + "/type"); - - return new ResourceObject(type, id, - attributes ?? new Dictionary(), - relationships ?? new Dictionary(), - metadata: metadata); - } - - private IDictionary DeserializeAttributes(JsonReader reader, string currentPath) - { - if (reader.TokenType != JsonToken.StartObject) - throw new DeserializationException("Invalid attributes object", "Expected an object but encountered " + reader.TokenType, currentPath); - - var attributes = new Dictionary(); - - while (reader.Read()) - { - if (reader.TokenType == JsonToken.EndObject) - break; - - var attributeName = (string)reader.Value; - reader.Read(); - - var attributeValue = JToken.ReadFrom(reader); - attributes.Add(attributeName, attributeValue); - } - - return attributes; - } - - private async Task> DeserializeRelationships(JsonReader reader, string currentPath) - { - if (reader.TokenType != JsonToken.StartObject) - throw new DeserializationException("Invalid relationship object", "Expected an object but encountered " + reader.TokenType, currentPath); - - var relationships = new Dictionary(); - - while (reader.Read()) - { - if (reader.TokenType == JsonToken.EndObject) - break; - - var relationshipName = (string)reader.Value; - reader.Read(); - - var relationship = await RelationshipObjectFormatter.Deserialize(reader, currentPath + "/" + relationshipName); - relationships.Add(relationshipName, relationship); - } - - return relationships; - } - } -} \ No newline at end of file diff --git a/JSONAPI/Json/SingleResourceDocumentFormatter.cs b/JSONAPI/Json/SingleResourceDocumentFormatter.cs deleted file mode 100644 index 816e963c..00000000 --- a/JSONAPI/Json/SingleResourceDocumentFormatter.cs +++ /dev/null @@ -1,147 +0,0 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using JSONAPI.Documents; -using Newtonsoft.Json; - -namespace JSONAPI.Json -{ - /// - /// Default implementation of ISingleResourceDocumentFormatter - /// - public class SingleResourceDocumentFormatter : ISingleResourceDocumentFormatter - { - private IResourceObjectFormatter _resourceObjectFormatter; - private IMetadataFormatter _metadataFormatter; - private const string PrimaryDataKeyName = "data"; - private const string RelatedDataKeyName = "included"; - private const string MetaKeyName = "meta"; - - /// - /// Creates a SingleResourceDocumentFormatter with default parameters - /// - public SingleResourceDocumentFormatter() - { - } - - /// - /// Creates a SingleResourceDocumentFormatter - /// - /// - /// - public SingleResourceDocumentFormatter(IResourceObjectFormatter resourceObjectFormatter, IMetadataFormatter metadataFormatter) - { - _resourceObjectFormatter = resourceObjectFormatter; - _metadataFormatter = metadataFormatter; - } - - /// - /// The formatter to use for resource objects found in this document - /// - /// - public IResourceObjectFormatter ResourceObjectFormatter - { - get - { - return _resourceObjectFormatter ?? (_resourceObjectFormatter = new ResourceObjectFormatter()); - } - set - { - if (_resourceObjectFormatter != null) throw new InvalidOperationException("This property can only be set once."); - _resourceObjectFormatter = value; - } - } - - /// - /// The formatter to use for document-level metadata - /// - /// - public IMetadataFormatter MetadataFormatter - { - get - { - return _metadataFormatter ?? (_metadataFormatter = new MetadataFormatter()); - } - set - { - if (_metadataFormatter != null) throw new InvalidOperationException("This property can only be set once."); - _metadataFormatter = value; - } - } - - public Task Serialize(ISingleResourceDocument document, JsonWriter writer) - { - writer.WriteStartObject(); - - writer.WritePropertyName(PrimaryDataKeyName); - - ResourceObjectFormatter.Serialize(document.PrimaryData, writer); - - if (document.RelatedData != null && document.RelatedData.Any()) - { - writer.WritePropertyName(RelatedDataKeyName); - writer.WriteStartArray(); - foreach (var resourceObject in document.RelatedData) - { - ResourceObjectFormatter.Serialize(resourceObject, writer); - } - writer.WriteEndArray(); - } - - if (document.Metadata != null) - { - writer.WritePropertyName(MetaKeyName); - MetadataFormatter.Serialize(document.Metadata, writer); - } - - writer.WriteEndObject(); - - return Task.FromResult(0); - } - - public async Task Deserialize(JsonReader reader, string currentPath) - { - if (reader.TokenType != JsonToken.StartObject) - throw new DeserializationException("Invalid document root", "Document root is not an object!", currentPath); - - IResourceObject primaryData = null; - IMetadata metadata = null; - - while (reader.Read()) - { - if (reader.TokenType != JsonToken.PropertyName) break; - - // Has to be a property name - var propertyName = (string)reader.Value; - reader.Read(); - - switch (propertyName) - { - case RelatedDataKeyName: - // TODO: If we want to capture related resources, this would be the place to do it - reader.Skip(); - break; - case PrimaryDataKeyName: - primaryData = await DeserializePrimaryData(reader, currentPath + "/" + PrimaryDataKeyName); - break; - case MetaKeyName: - metadata = await MetadataFormatter.Deserialize(reader, currentPath + "/" + MetaKeyName); - break; - default: - reader.Skip(); - break; - } - } - - return new SingleResourceDocument(primaryData, new IResourceObject[] { }, metadata); - } - - private async Task DeserializePrimaryData(JsonReader reader, string currentPath) - { - if (reader.TokenType == JsonToken.Null) return null; - - var primaryData = await ResourceObjectFormatter.Deserialize(reader, currentPath); - return primaryData; - } - } -} \ No newline at end of file diff --git a/JSONAPI/Properties/AssemblyInfo.cs b/JSONAPI/Properties/AssemblyInfo.cs deleted file mode 100644 index 53bb7fbb..00000000 --- a/JSONAPI/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("JSONAPI")] -[assembly: AssemblyDescription("A toolkit for using WebAPI and (optionally) EntityFramework to quickly build REST services complying with the JSON API spec (jsonapi.org).")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("JSONAPI.NET")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5b46482f-733f-42bf-b507-37767a6bb948")] - -[assembly: InternalsVisibleTo("JSONAPI.Tests")] -[assembly: InternalsVisibleTo("JSONAPI.EntityFramework")] -[assembly: InternalsVisibleTo("JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests")] -[assembly: InternalsVisibleTo("JSONAPI.Autofac")] - -// This assembly is the default dynamic assembly generated Castle DynamicProxy, -// used by Moq. Paste in a single line. -[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.2.1.0")] -[assembly: AssemblyFileVersion("0.2.1.0")] diff --git a/JSONAPI/QueryableTransformers/DefaultFilteringTransformer.cs b/JSONAPI/QueryableTransformers/DefaultFilteringTransformer.cs deleted file mode 100644 index f449d1bb..00000000 --- a/JSONAPI/QueryableTransformers/DefaultFilteringTransformer.cs +++ /dev/null @@ -1,446 +0,0 @@ -using System; -using System.Globalization; -using System.Linq; -using System.Linq.Expressions; -using System.Net.Http; -using System.Reflection; -using JSONAPI.Core; -using JSONAPI.Documents.Builders; - -namespace JSONAPI.QueryableTransformers -{ - /// - /// This transformer filters an IQueryable based on query-string values. - /// - public class DefaultFilteringTransformer : IQueryableFilteringTransformer - { - private readonly IResourceTypeRegistry _resourceTypeRegistry; - - /// - /// Creates a new FilteringQueryableTransformer - /// - /// The registry used to look up registered type information. - public DefaultFilteringTransformer(IResourceTypeRegistry resourceTypeRegistry) - { - _resourceTypeRegistry = resourceTypeRegistry; - } - - public IQueryable Filter(IQueryable query, HttpRequestMessage request) - { - var parameter = Expression.Parameter(typeof(T)); - var bodyExpr = GetPredicateBody(request, parameter); - var lambdaExpr = Expression.Lambda>(bodyExpr, parameter); - return query.Where(lambdaExpr); - } - - // Borrowed from http://stackoverflow.com/questions/3631547/select-right-generic-method-with-reflection - // ReSharper disable once UnusedMember.Local - private readonly Lazy _whereMethod = new Lazy(() => - typeof(Queryable).GetMethods() - .Where(x => x.Name == "Where") - .Select(x => new { M = x, P = x.GetParameters() }) - .Where(x => x.P.Length == 2 - && x.P[0].ParameterType.IsGenericType - && x.P[0].ParameterType.GetGenericTypeDefinition() == typeof(IQueryable<>) - && x.P[1].ParameterType.IsGenericType - && x.P[1].ParameterType.GetGenericTypeDefinition() == typeof(Expression<>)) - .Select(x => new { x.M, A = x.P[1].ParameterType.GetGenericArguments() }) - .Where(x => x.A[0].IsGenericType - && x.A[0].GetGenericTypeDefinition() == typeof(Func<,>)) - .Select(x => new { x.M, A = x.A[0].GetGenericArguments() }) - .Where(x => x.A[0].IsGenericParameter - && x.A[1] == typeof(bool)) - .Select(x => x.M) - .SingleOrDefault() - ); - - private Expression GetPredicateBody(HttpRequestMessage request, ParameterExpression param) - { - Expression workingExpr = null; - - var type = param.Type; - var queryPairs = request.GetQueryNameValuePairs(); - foreach (var queryPair in queryPairs) - { - if (String.IsNullOrWhiteSpace(queryPair.Key)) - continue; - - if (!queryPair.Key.StartsWith("filter.")) - continue; - - var filterField = queryPair.Key.Substring(7); // Skip "filter." - - IResourceTypeRegistration registration; - try - { - registration = _resourceTypeRegistry.GetRegistrationForType(type); - } - catch (TypeRegistrationNotFoundException) - { - throw JsonApiException.CreateForBadRequest("No registration exists for the specified type"); - } - - var expr = GetPredicate(filterField, registration, param, queryPair.Value); - workingExpr = workingExpr == null ? expr : Expression.AndAlso(workingExpr, expr); - } - - return workingExpr ?? Expression.Constant(true); // No filters, so return everything - } - - private Expression GetPredicate(string filterField, IResourceTypeRegistration registration, ParameterExpression param, string queryValue) - { - if (filterField == "id") - return GetPredicateBodyForProperty(registration.IdProperty, queryValue, param); - - var resourceTypeField = registration.GetFieldByName(filterField); - if (resourceTypeField == null) - throw JsonApiException.CreateForBadRequest( - string.Format("No attribute {0} exists on the specified type.", filterField)); - - if (string.IsNullOrWhiteSpace(queryValue)) - queryValue = null; - - // See if it is a field property - var fieldModelProperty = resourceTypeField as ResourceTypeAttribute; - if (fieldModelProperty != null) - return GetPredicateBodyForField(fieldModelProperty, queryValue, param); - - // See if it is a relationship property - var relationshipModelProperty = resourceTypeField as ResourceTypeRelationship; - if (relationshipModelProperty != null) - return GetPredicateBodyForRelationship(relationshipModelProperty, queryValue, param); - - throw JsonApiException.CreateForBadRequest( - string.Format("The attribute {0} is unsupported for filtering.", filterField)); - } - - private Expression GetPredicateBodyForField(ResourceTypeAttribute resourceTypeAttribute, string queryValue, - ParameterExpression param) - { - return GetPredicateBodyForProperty(resourceTypeAttribute.Property, queryValue, param); - } - - // ReSharper disable once FunctionComplexityOverflow - // TODO: should probably break this method up - private Expression GetPredicateBodyForProperty(PropertyInfo prop, string queryValue, ParameterExpression param) - { - var propertyType = prop.PropertyType; - - Expression expr; - if (propertyType == typeof(String)) - { - if (String.IsNullOrWhiteSpace(queryValue)) - { - Expression propertyExpr = Expression.Property(param, prop); - expr = Expression.Equal(propertyExpr, Expression.Constant(null)); - } - else - { - Expression propertyExpr = Expression.Property(param, prop); - expr = Expression.Equal(propertyExpr, Expression.Constant(queryValue)); - } - } - else if (propertyType == typeof(Boolean)) - { - bool value; - expr = bool.TryParse(queryValue, out value) - ? GetPropertyExpression(value, prop, param) - : Expression.Constant(false); - } - else if (propertyType == typeof(Boolean?)) - { - bool tmp; - var value = bool.TryParse(queryValue, out tmp) ? tmp : (bool?)null; - expr = GetPropertyExpression(value, prop, param); - } - else if (propertyType == typeof(SByte)) - { - SByte value; - expr = SByte.TryParse(queryValue, out value) - ? GetPropertyExpression(value, prop, param) - : Expression.Constant(false); - } - else if (propertyType == typeof(SByte?)) - { - SByte tmp; - var value = SByte.TryParse(queryValue, out tmp) ? tmp : (SByte?)null; - expr = GetPropertyExpression(value, prop, param); - } - else if (propertyType == typeof(Byte)) - { - Byte value; - expr = Byte.TryParse(queryValue, out value) - ? GetPropertyExpression(value, prop, param) - : Expression.Constant(false); - } - else if (propertyType == typeof(Byte?)) - { - Byte tmp; - var value = Byte.TryParse(queryValue, out tmp) ? tmp : (Byte?)null; - expr = GetPropertyExpression(value, prop, param); - } - else if (propertyType == typeof(Int16)) - { - Int16 value; - expr = Int16.TryParse(queryValue, out value) - ? GetPropertyExpression(value, prop, param) - : Expression.Constant(false); - } - else if (propertyType == typeof(Int16?)) - { - Int16 tmp; - var value = Int16.TryParse(queryValue, out tmp) ? tmp : (Int16?)null; - expr = GetPropertyExpression(value, prop, param); - } - else if (propertyType == typeof(UInt16)) - { - UInt16 value; - expr = UInt16.TryParse(queryValue, out value) - ? GetPropertyExpression(value, prop, param) - : Expression.Constant(false); - } - else if (propertyType == typeof(UInt16?)) - { - UInt16 tmp; - var value = UInt16.TryParse(queryValue, out tmp) ? tmp : (UInt16?)null; - expr = GetPropertyExpression(value, prop, param); - } - else if (propertyType == typeof(Int32)) - { - Int32 value; - expr = Int32.TryParse(queryValue, out value) - ? GetPropertyExpression(value, prop, param) - : Expression.Constant(false); - } - else if (propertyType == typeof(Int32?)) - { - Int32 tmp; - var value = Int32.TryParse(queryValue, out tmp) ? tmp : (Int32?)null; - expr = GetPropertyExpression(value, prop, param); - } - else if (propertyType == typeof(UInt32)) - { - UInt32 value; - expr = UInt32.TryParse(queryValue, out value) - ? GetPropertyExpression(value, prop, param) - : Expression.Constant(false); - } - else if (propertyType == typeof(UInt32?)) - { - UInt32 tmp; - var value = UInt32.TryParse(queryValue, out tmp) ? tmp : (UInt32?)null; - expr = GetPropertyExpression(value, prop, param); - } - else if (propertyType == typeof(Int64)) - { - Int64 value; - expr = Int64.TryParse(queryValue, out value) - ? GetPropertyExpression(value, prop, param) - : Expression.Constant(false); - } - else if (propertyType == typeof(Int64?)) - { - Int64 tmp; - var value = Int64.TryParse(queryValue, out tmp) ? tmp : (Int64?)null; - expr = GetPropertyExpression(value, prop, param); - } - else if (propertyType == typeof(UInt64)) - { - UInt64 value; - expr = UInt64.TryParse(queryValue, out value) - ? GetPropertyExpression(value, prop, param) - : Expression.Constant(false); - } - else if (propertyType == typeof(UInt64?)) - { - UInt64 tmp; - var value = UInt64.TryParse(queryValue, out tmp) ? tmp : (UInt64?)null; - expr = GetPropertyExpression(value, prop, param); - } - else if (propertyType == typeof(Single)) - { - Single value; - expr = Single.TryParse(queryValue, NumberStyles.Any, CultureInfo.InvariantCulture, out value) - ? GetPropertyExpression(value, prop, param) - : Expression.Constant(false); - } - else if (propertyType == typeof(Single?)) - { - Single tmp; - var value = Single.TryParse(queryValue, NumberStyles.Any, CultureInfo.InvariantCulture, out tmp) ? tmp : (Single?)null; - expr = GetPropertyExpression(value, prop, param); - } - else if (propertyType == typeof(Double)) - { - Double value; - expr = Double.TryParse(queryValue, NumberStyles.Any, CultureInfo.InvariantCulture, out value) - ? GetPropertyExpression(value, prop, param) - : Expression.Constant(false); - } - else if (propertyType == typeof(Double?)) - { - Double tmp; - var value = Double.TryParse(queryValue, NumberStyles.Any, CultureInfo.InvariantCulture, out tmp) ? tmp : (Double?)null; - expr = GetPropertyExpression(value, prop, param); - } - else if (propertyType == typeof(Decimal)) - { - Decimal value; - expr = Decimal.TryParse(queryValue, NumberStyles.Any, CultureInfo.InvariantCulture, out value) - ? GetPropertyExpression(value, prop, param) - : Expression.Constant(false); - } - else if (propertyType == typeof(Decimal?)) - { - Decimal tmp; - var value = Decimal.TryParse(queryValue, NumberStyles.Any, CultureInfo.InvariantCulture, out tmp) ? tmp : (Decimal?)null; - expr = GetPropertyExpression(value, prop, param); - } - else if (propertyType == typeof(DateTime)) - { - DateTime value; - expr = DateTime.TryParse(queryValue, out value) - ? GetPropertyExpression(value, prop, param) - : Expression.Constant(false); - } - else if (propertyType == typeof(DateTime?)) - { - DateTime tmp; - var value = DateTime.TryParse(queryValue, out tmp) ? tmp : (DateTime?)null; - expr = GetPropertyExpression(value, prop, param); - } - else if (propertyType == typeof(DateTimeOffset)) - { - DateTimeOffset value; - expr = DateTimeOffset.TryParse(queryValue, out value) - ? GetPropertyExpression(value, prop, param) - : Expression.Constant(false); - } - else if (propertyType == typeof(DateTimeOffset?)) - { - DateTimeOffset tmp; - var value = DateTimeOffset.TryParse(queryValue, out tmp) ? tmp : (DateTimeOffset?)null; - expr = GetPropertyExpression(value, prop, param); - } - else if (propertyType.IsEnum) - { - int value; - expr = (int.TryParse(queryValue, out value) && Enum.IsDefined(propertyType, value)) - ? GetEnumPropertyExpression(value, prop, param) - : Expression.Constant(false); - } - else if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof (Nullable<>) && - propertyType.GenericTypeArguments[0].IsEnum) - { - int tmp; - var value = int.TryParse(queryValue, out tmp) ? tmp : (int?) null; - expr = GetEnumPropertyExpression(value, prop, param); - } - else - { - expr = Expression.Constant(true); - } - - return expr; - } - - private Expression GetPredicateBodyForRelationship(ResourceTypeRelationship resourceTypeProperty, string queryValue, ParameterExpression param) - { - var relatedType = resourceTypeProperty.RelatedType; - PropertyInfo relatedIdProperty; - try - { - var registration = _resourceTypeRegistry.GetRegistrationForType(relatedType); - relatedIdProperty = registration.IdProperty; - } - catch (TypeRegistrationNotFoundException) - { - throw JsonApiException.CreateForBadRequest("No registration exists for the specified type"); - } - - var prop = resourceTypeProperty.Property; - - if (resourceTypeProperty.IsToMany) - { - var propertyExpr = Expression.Property(param, prop); - - if (string.IsNullOrWhiteSpace(queryValue)) - { - var leftExpr = Expression.Equal(propertyExpr, Expression.Constant(null)); - - var asQueryableCallExpr = Expression.Call( - typeof(Queryable), - "AsQueryable", - new[] { relatedType }, - propertyExpr); - var anyCallExpr = Expression.Call( - typeof(Queryable), - "Any", - new[] { relatedType }, - asQueryableCallExpr); - var rightExpr = Expression.Not(anyCallExpr); - - return Expression.OrElse(leftExpr, rightExpr); - } - else - { - var leftExpr = Expression.NotEqual(propertyExpr, Expression.Constant(null)); - - var idValue = queryValue.Trim(); - var idExpr = Expression.Constant(idValue); - var anyParam = Expression.Parameter(relatedType); - var relatedIdPropertyExpr = Expression.Property(anyParam, relatedIdProperty); - var relatedIdPropertyEqualsIdExpr = Expression.Equal(relatedIdPropertyExpr, idExpr); - var anyPredicateExpr = Expression.Lambda(relatedIdPropertyEqualsIdExpr, anyParam); - var asQueryableCallExpr = Expression.Call( - typeof(Queryable), - "AsQueryable", - new[] { relatedType }, - propertyExpr); - var rightExpr = Expression.Call( - typeof(Queryable), - "Any", - new[] { relatedType }, - asQueryableCallExpr, - anyPredicateExpr); - - return Expression.AndAlso(leftExpr, rightExpr); - } - } - else - { - var propertyExpr = Expression.Property(param, prop); - - if (string.IsNullOrWhiteSpace(queryValue)) - return Expression.Equal(propertyExpr, Expression.Constant(null)); - - var leftExpr = Expression.NotEqual(propertyExpr, Expression.Constant(null)); - - var idValue = queryValue.Trim(); - var idExpr = Expression.Constant(idValue); - var relatedIdPropertyExpr = Expression.Property(propertyExpr, relatedIdProperty); - var rightExpr = Expression.Equal(relatedIdPropertyExpr, idExpr); - - return Expression.AndAlso(leftExpr, rightExpr); - } - } - - private static Expression GetPropertyExpression(T value, PropertyInfo property, - ParameterExpression param) - { - Expression propertyExpr = Expression.Property(param, property); - var valueExpr = Expression.Constant(value); - Expression castedConstantExpr = Expression.Convert(valueExpr, typeof(T)); - return Expression.Equal(propertyExpr, castedConstantExpr); - } - - private static Expression GetEnumPropertyExpression(int? value, PropertyInfo property, - ParameterExpression param) - { - Expression propertyExpr = Expression.Property(param, property); - var castedValueExpr = Expression.Convert(Expression.Constant(value), typeof(int?)); - var castedPropertyExpr = Expression.Convert(propertyExpr, typeof(int?)); - return Expression.Equal(castedPropertyExpr, castedValueExpr); - } - } -} diff --git a/JSONAPI/QueryableTransformers/DefaultPaginationTransformResult.cs b/JSONAPI/QueryableTransformers/DefaultPaginationTransformResult.cs deleted file mode 100644 index 5c68886c..00000000 --- a/JSONAPI/QueryableTransformers/DefaultPaginationTransformResult.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Linq; -using JSONAPI.ActionFilters; - -namespace JSONAPI.QueryableTransformers -{ - /// - /// Default implementation of IPaginationTransformResult`1 - /// - /// - public class DefaultPaginationTransformResult : IPaginationTransformResult - { - public IQueryable PagedQuery { get; set; } - public bool PaginationWasApplied { get; set; } - public int PageNumber { get; set; } - public int PageSize { get; set; } - } -} diff --git a/JSONAPI/QueryableTransformers/DefaultPaginationTransformer.cs b/JSONAPI/QueryableTransformers/DefaultPaginationTransformer.cs deleted file mode 100644 index 21c87754..00000000 --- a/JSONAPI/QueryableTransformers/DefaultPaginationTransformer.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; -using System.Linq; -using System.Net.Http; -using JSONAPI.ActionFilters; -using JSONAPI.Documents.Builders; - -namespace JSONAPI.QueryableTransformers -{ - /// - /// Performs pagination - /// - public class DefaultPaginationTransformer : IQueryablePaginationTransformer - { - private const int DefaultPageSize = 100; - private const string PageNumberQueryParam = "page.number"; - private const string PageSizeQueryParam = "page.size"; - - private readonly int? _maxPageSize; - - /// - /// Creates a DefaultPaginationTransformer - /// - /// The maximum page size to allow clients to request. Leave null for no restriction. - public DefaultPaginationTransformer(int? maxPageSize = null) - { - if (maxPageSize <= 0) throw new ArgumentOutOfRangeException("maxPageSize", "The maximum page size must be 1 or greater."); - - _maxPageSize = maxPageSize; - } - - public IPaginationTransformResult ApplyPagination(IQueryable query, HttpRequestMessage request) - { - var hasPageNumberParam = false; - var hasPageSizeParam = false; - var pageNumber = 0; - var pageSize = _maxPageSize ?? DefaultPageSize; - foreach (var kvp in request.GetQueryNameValuePairs()) - { - if (kvp.Key == PageNumberQueryParam) - { - hasPageNumberParam = true; - if (!int.TryParse(kvp.Value, out pageNumber)) - throw JsonApiException.CreateForParameterError("Invalid page number", - "Page number must be a positive integer.", PageNumberQueryParam); - - } - else if (kvp.Key == PageSizeQueryParam) - { - hasPageSizeParam = true; - if (!int.TryParse(kvp.Value, out pageSize)) - throw JsonApiException.CreateForParameterError("Invalid page size", - "Page size must be a positive integer.", PageSizeQueryParam); - } - } - - if (!hasPageNumberParam && !hasPageSizeParam) - { - return new DefaultPaginationTransformResult - { - PagedQuery = query, - PaginationWasApplied = false - }; - } - - if ((hasPageNumberParam && !hasPageSizeParam)) - throw JsonApiException.CreateForParameterError("Page size missing", - string.Format("In order for paging to work properly, if either {0} or {1} is set, both must be.", - PageNumberQueryParam, PageSizeQueryParam), PageNumberQueryParam); - - if ((!hasPageNumberParam && hasPageSizeParam)) - throw JsonApiException.CreateForParameterError("Page number missing", - string.Format("In order for paging to work properly, if either {0} or {1} is set, both must be.", - PageNumberQueryParam, PageSizeQueryParam), PageSizeQueryParam); - - if (pageNumber < 0) - throw JsonApiException.CreateForParameterError("Page number out of bounds", - "Page number must not be negative.", PageNumberQueryParam); - - if (pageSize <= 0) - throw JsonApiException.CreateForParameterError("Page size out of bounds", - "Page size must be greater than or equal to 1.", PageSizeQueryParam); - - if (_maxPageSize != null && pageSize > _maxPageSize.Value) - pageSize = _maxPageSize.Value; - - var skip = pageNumber * pageSize; - return new DefaultPaginationTransformResult - { - PageNumber = pageNumber, - PageSize = pageSize, - PagedQuery = query.Skip(skip).Take(pageSize), - PaginationWasApplied = true - }; - } - } -} diff --git a/JSONAPI/QueryableTransformers/DefaultSortingTransformer.cs b/JSONAPI/QueryableTransformers/DefaultSortingTransformer.cs deleted file mode 100644 index 2898a58b..00000000 --- a/JSONAPI/QueryableTransformers/DefaultSortingTransformer.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Reflection; -using JSONAPI.Core; -using JSONAPI.Documents.Builders; - -namespace JSONAPI.QueryableTransformers -{ - /// - /// This transform sorts an IQueryable according to query parameters. - /// - public class DefaultSortingTransformer : IQueryableSortingTransformer - { - private readonly IResourceTypeRegistry _resourceTypeRegistry; - - /// - /// Creates a new SortingQueryableTransformer - /// - /// The registry used to look up registered type information. - public DefaultSortingTransformer(IResourceTypeRegistry resourceTypeRegistry) - { - _resourceTypeRegistry = resourceTypeRegistry; - } - - public IOrderedQueryable Sort(IQueryable query, string[] sortExpressions) - { - if (sortExpressions == null || sortExpressions.Length == 0) - sortExpressions = new [] { "id" }; - - var selectors = new List>(); - var usedProperties = new Dictionary(); - - var registration = _resourceTypeRegistry.GetRegistrationForType(typeof (T)); - - foreach (var sortExpression in sortExpressions) - { - if (string.IsNullOrEmpty(sortExpression)) - throw JsonApiException.CreateForParameterError("Empty sort expression", "One of the sort expressions is empty.", "sort"); - - bool ascending; - string fieldName; - if (sortExpression[0] == '-') - { - ascending = false; - fieldName = sortExpression.Substring(1); - } - else - { - ascending = true; - fieldName = sortExpression; - } - - if (string.IsNullOrWhiteSpace(fieldName)) - throw JsonApiException.CreateForParameterError("Empty sort expression", "One of the sort expressions is empty.", "sort"); - - var paramExpr = Expression.Parameter(typeof(T)); - Expression sortValueExpression; - - if (fieldName == "id") - { - sortValueExpression = registration.GetSortByIdExpression(paramExpr); - } - else - { - var modelProperty = registration.GetFieldByName(fieldName); - if (modelProperty == null) - throw JsonApiException.CreateForParameterError("Attribute not found", - string.Format("The attribute \"{0}\" does not exist on type \"{1}\".", - fieldName, registration.ResourceTypeName), "sort"); - - var property = modelProperty.Property; - - if (usedProperties.ContainsKey(property)) - throw JsonApiException.CreateForParameterError("Attribute specified more than once", - string.Format("The attribute \"{0}\" was specified more than once.", fieldName), "sort"); - - usedProperties[property] = null; - sortValueExpression = Expression.Property(paramExpr, property); - } - - var selector = GetSelector(paramExpr, sortValueExpression, !ascending); - selectors.Add(selector); - } - - var firstSelector = selectors.First(); - - IOrderedQueryable workingQuery = firstSelector.ApplyInitially(query); - return selectors.Skip(1).Aggregate(workingQuery, (current, selector) => selector.ApplySubsequently(current)); - } - - private ISelector GetSelector(ParameterExpression paramExpr, Expression sortValueExpression, bool isDescending) - { - var lambda = Expression.Lambda(sortValueExpression, paramExpr); - var selectorType = typeof (Selector<,>).MakeGenericType(typeof (T), sortValueExpression.Type); - var selector = Activator.CreateInstance(selectorType, isDescending, lambda); - return (ISelector)selector; - } - } - - internal interface ISelector - { - IOrderedQueryable ApplyInitially(IQueryable unsortedQuery); - IOrderedQueryable ApplySubsequently(IOrderedQueryable currentQuery); - } - - internal class Selector : ISelector - { - private readonly bool _isDescending; - private readonly Expression> _propertyAccessorExpression; - - public Selector(bool isDescending, Expression> propertyAccessorExpression) - { - _isDescending = isDescending; - _propertyAccessorExpression = propertyAccessorExpression; - } - - public IOrderedQueryable ApplyInitially(IQueryable unsortedQuery) - { - if (_isDescending) return unsortedQuery.OrderByDescending(_propertyAccessorExpression); - return unsortedQuery.OrderBy(_propertyAccessorExpression); - } - - public IOrderedQueryable ApplySubsequently(IOrderedQueryable currentQuery) - { - if (_isDescending) return currentQuery.ThenByDescending(_propertyAccessorExpression); - return currentQuery.ThenBy(_propertyAccessorExpression); - } - } -} diff --git a/JSONAPI/QueryableTransformers/IQueryableEnumerationTransformer.cs b/JSONAPI/QueryableTransformers/IQueryableEnumerationTransformer.cs deleted file mode 100644 index c10eb983..00000000 --- a/JSONAPI/QueryableTransformers/IQueryableEnumerationTransformer.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace JSONAPI.QueryableTransformers -{ - /// - /// Provides a service to asynchronously materialize the results of an IQueryable into - /// a concrete in-memory representation for serialization. - /// - public interface IQueryableEnumerationTransformer - { - /// - /// Enumerates the specified query. - /// - /// The query to enumerate - /// The request's cancellation token. If this token is cancelled during enumeration, enumeration must halt. - /// The queryable element type - /// A task yielding the enumerated results of the query - Task Enumerate(IQueryable query, CancellationToken cancellationToken); - - /// - /// Gets the first result for the specified query. - /// - /// The query to enumerate - /// The request's cancellation token. If this token is cancelled during enumeration, enumeration must halt. - /// The queryable element type - /// A task yielding the enumerated results of the query - Task FirstOrDefault(IQueryable query, CancellationToken cancellationToken); - } -} diff --git a/JSONAPI/QueryableTransformers/IQueryableFilteringTransformer.cs b/JSONAPI/QueryableTransformers/IQueryableFilteringTransformer.cs deleted file mode 100644 index fdb5f770..00000000 --- a/JSONAPI/QueryableTransformers/IQueryableFilteringTransformer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Linq; -using System.Net.Http; - -namespace JSONAPI.QueryableTransformers -{ - /// - /// Service for filtering an IQueryable according to an HTTP request. - /// - public interface IQueryableFilteringTransformer - { - /// - /// Filters the provided queryable based on information from the request message. - /// - /// The input query - /// The request message - /// The element type of the query - /// The filtered query - IQueryable Filter(IQueryable query, HttpRequestMessage request); - } -} diff --git a/JSONAPI/QueryableTransformers/IQueryablePaginationTransformer.cs b/JSONAPI/QueryableTransformers/IQueryablePaginationTransformer.cs deleted file mode 100644 index 01ff8e1d..00000000 --- a/JSONAPI/QueryableTransformers/IQueryablePaginationTransformer.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Linq; -using System.Net.Http; - -namespace JSONAPI.QueryableTransformers -{ - /// - /// Provides a service to provide a page of data based on information from the request. - /// - public interface IQueryablePaginationTransformer - { - /// - /// Pages the query according to information from the request. - /// - /// The query to page - /// The request message - /// The queryable element type - /// The result of pagination - IPaginationTransformResult ApplyPagination(IQueryable query, HttpRequestMessage request); - } - - /// - /// The result of a pagination transform - /// - /// - public interface IPaginationTransformResult - { - /// - /// A query that has been paginated - /// - IQueryable PagedQuery { get; } - - /// - /// Whether the query has been paginated or not - /// - bool PaginationWasApplied { get; } - - /// - /// The current page of the query - /// - int PageNumber { get; } - - /// - /// The size of this page of data - /// - int PageSize { get; } - } -} diff --git a/JSONAPI/QueryableTransformers/IQueryableSortingTransformer.cs b/JSONAPI/QueryableTransformers/IQueryableSortingTransformer.cs deleted file mode 100644 index 9583527c..00000000 --- a/JSONAPI/QueryableTransformers/IQueryableSortingTransformer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Linq; -using System.Net.Http; - -namespace JSONAPI.QueryableTransformers -{ - /// - /// Service for sorting an IQueryable according to an HTTP request. - /// - public interface IQueryableSortingTransformer - { - /// - /// Sorts the provided queryable based on information from the request message. - /// - /// The input query - /// The expressions to sort by - /// The element type of the query - /// The sorted query - IOrderedQueryable Sort(IQueryable query, string[] sortExpressions); - } -} \ No newline at end of file diff --git a/JSONAPI/QueryableTransformers/SynchronousEnumerationTransformer.cs b/JSONAPI/QueryableTransformers/SynchronousEnumerationTransformer.cs deleted file mode 100644 index 2c7b0b95..00000000 --- a/JSONAPI/QueryableTransformers/SynchronousEnumerationTransformer.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace JSONAPI.QueryableTransformers -{ - /// - /// Synchronously enumerates an IQueryable - /// - public class SynchronousEnumerationTransformer : IQueryableEnumerationTransformer - { - public Task Enumerate(IQueryable query, CancellationToken cancellationToken) - { - return Task.FromResult(query.ToArray()); - } - - public Task FirstOrDefault(IQueryable query, CancellationToken cancellationToken) - { - return Task.FromResult(query.FirstOrDefault()); - } - } -} diff --git a/JSONAPI/app.config b/JSONAPI/app.config deleted file mode 100644 index cc1baa1c..00000000 --- a/JSONAPI/app.config +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/JSONAPI/packages.config b/JSONAPI/packages.config deleted file mode 100644 index 16569ef0..00000000 --- a/JSONAPI/packages.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index 04dcb5c3..00000000 --- a/LICENSE.md +++ /dev/null @@ -1,8 +0,0 @@ -The MIT License (MIT) -Copyright (c) 2014 Robert Blake - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md deleted file mode 100644 index ee1dc2e9..00000000 --- a/README.md +++ /dev/null @@ -1,145 +0,0 @@ -JSONAPI.NET -=========== -[![jsonapi MyGet Build Status](https://www.myget.org/BuildSource/Badge/jsonapi?identifier=caf48269-c15b-4850-a29e-b41a23d9854d)](https://www.myget.org/) - -_Deprecation notice_ ------------------- - -JSONAPI.NET is no longer actively maintained. It is not recommended for use in new projects. It does NOT work with .NET Core. Please consider [one of the other .NET server implementations](http://jsonapi.org/implementations/#server-libraries-net) instead. - - -What is JSONAPI.NET? -==================== - -JSONAPI.NET is a set of utility classes that aim to make it possible to implement [JSON API spec](http://jsonapi.org/) compliant RESTful web services quickly and easily using ASP.NET MVC WebAPI. In practice, the primary target is to build backend web services that work with the Ember Data library and [Ember.js](http://emberjs.com). Since the JSON API spec project originated from the Ember Data and Active Model Serializers project, Ember Data's included RESTAdapter is very close to JSON API spec compliant--but not quite. You will need to use the separately available [JSON API Adapter](https://github.com/kurko/ember-json-api) to connect with Ember Data, and it is currently a primary goal of this project to work well with this adapter (coverage of the whole JSON API spec is far from complete). - -How do I use it? ----------------- - -At its most basic level, JSONAPI includes a Json.NET `JsonMediaTypeFormatter`, which can be used to transform WebAPI JSON output into JSON API spec compliant messages. You can use the media formatter by adding an instance of it to the Json.NET Formatters collection, probably in your WebApiConfig class, like this: - -```C# -public static void Register(HttpConfiguration config) -{ - //... - JsonApiFormatter formatter = new JSONAPI.Json.JsonApiFormatter(); - formatter.PluralizationService = new JSONAPI.Core.PluralizationService(); - GlobalConfiguration.Configuration.Formatters.Add(formatter); - //... -} -``` - -In connection with the media formatter, a `PluralizationService` is required to translate between singular and plural object names, since the spec (usually?) uses plural class/type names, and your class names are likely singular. The `JSONAPI.Core.PluralizationService` is provided as a horribly naive sample implementation (it simply adds or strips "s" from the end of the class name), but at least lets you manually add explicit mappings with the `AddMapping(string singular, string plural)` method. - -> :information_source: HINT: the `JSONAPI.EntityFramework` library includes a `PluralizationService` that uses EntityFramework's much more sophisticated inflector! - -That will configure a working formatter. Note that the formatter (by default) will only handle requests having an `Accept` or `Content-type` header of `application/vnd.api+json`, the media type defined for the JSON API spec. - -Essentially, that's it! At this point your WebAPI methods should be able to produce and consume JSON that conforms to (a subset of) the JSON API spec! There is, of course, much more that you can configure. - -Serializing Relationships -------------------------- - -One of the benefits of the JSON API spec is that it provides several ways to [serialize relationships](http://jsonapi.org/format/#document-structure-resource-relationships). This gives you a lot of flexibility to improve your API performance for both the server and client: If related objects are expensive to retrieve or compute, you can represent the relationship as a URL to avoid that cost if the client never accesses it. If it is not expensive, or you know the client will need them, you can bundle them in the same response to reduce the number of network requests. JSONAPI.NET provides you three attributes you can use to decorate your models to specify how a relationship property will be serialized. - -* `SerializeAs`: Decorate a property with this attribute to specify that the related objects should be serialized as ids, a link, or with the serialized object(s) embedded within the parent object (embedding is NOT part of the spec, but is supported by Ember Data!) -* `IncludeInPayload`: Decorate a property with this attribute to cause the related objects to be included with the parent object in the same response message. This is called a Compound Document in the spec. This only makes sense to use with `[SerializeAs(SerializeAsOptions.Ids)]`. -* `LinkTemplate`: If you use `[SerializeAs(SerializeAsOptions.Link)]`, you must also use this attribute to specify the format of the link sent to the client. Two template parameters are supported, `{0}` will be replaced with the Id(s) of the related object, and `{1}` will be replaced with the Id of the parent object. - -> :information_source: As a side note, the RelationAggregator class handles the work of pulling any included related objects into the document--which may be a recursive process: for example, if an object has a relationship of its own type and that relationship property is annotated to be included, then it will recursively include all related objects of the same type! However, those related objects will all be included in a flat array for that type, according to the spec. - -# Great! But what's all this other stuff? - - -JSONAPI.Net intends to be so much more than just a media formatter. It provides subclasses of WebAPI's `ApiController` that automate some of the boilerplate that goes into building a web service, especially one that can comply with the JSON API spec. While `JSONAPI.ApiController` doesn't do much, it can be subclassed to make default actions for the HTTP methods that WebAPI supports. - -A `JSONAPI.IMaterializer` object can be added to that `ApiController` to broker between the WebAPI layer and your persistence layer. If you create an implementation of `IMaterializer`, you can begin to use the base `ApiController`'s handler methods, such as the Get() handler--which already handles the JSON API spec for requesting multiple objects with a list of comma-separated Ids! - -# Didn't I read something about using Entity Framework? - -The classes in the `JSONAPI.EntityFramework` namespace take great advantage of the patterns set out in the `JSONAPI` namespace. The `EntityFrameworkMaterializer` is an `IMaterializer` that can operate with your own `DbContext` class to retrieve objects by Id/Primary Key, and can retrieve and update existing objects from your context in a way that Entity Framework expects for change tracking…that means, in theory, you can use the provided `JSONAPI.EntityFramework.ApiController` base class to handle GET, PUT, POST, and DELETE without writing any additional code! You will still almost certainly subclass `ApiController` to implement your business logic, but that means you only have to worry about your business logic--not implementing the JSON API spec or messing with your persistence layer. - - - -# Configuration JSONAPI.EntityFramework - -- [ ] Add some hints about the configuration of JSONAPI.EntityFramework - -## Manipulate entities before JSONAPI.EntityFramework persists them -To change your entities before they get persisted you can extend the `EntityFrameworkDocumentMaterializer` class. You need to register your custom DocumentMaterializer in your `JsonApiConfiguration` like that: -```C# -configuration.RegisterEntityFrameworkResourceType(c =>c.UseDocumentMaterializer()); -``` -Afterwards you can override the `OnCreate`, `OnUpdate` or `OnDelete` methods in your `CustomDocumentMaterializer`. - -```C# -protected override async Task OnCreate(Task record) -{ - await base.OnUpdate(record); - var entity = await record; - entity.CreatedOn = DateTime.Now; - entity.CreatedBy = Principal?.Identity; -} -``` - -> :information_source: HINT: To get the `Principal` you can add the following part into your `Startup.cs` which registers the `Principal` in Autofac and define a constructor Parameter on your `CustomDocumentMaterializer` of type `IPrincipal`. - -```C# - -configurator.OnApplicationLifetimeScopeCreating(builder => -{ -// ... -builder.Register(ctx => HttpContext.Current.GetOwinContext()).As(); -builder.Register((c, p) => - { - var owin = c.Resolve(); - return owin.Authentication.User; - }) - .As() - .InstancePerRequest(); -} -``` - - -## Set the context path of JSONAPI.EntityFramework - -Per default the routes created for the registered models from EntityFramework will appear in root folder. This can conflict with folders of the file system or other routes you may want to serve from the same project. -To solve the issue we can create an instance of the `BaseUrlService` and put it in the configuration. -The `BaseUrlService` can be created with the context path parameter which will be used to register the routes and put into responses. - -```C# -var configuration = new JsonApiConfiguration(); -configuration.RegisterEntityFrameworkResourceType(); -// ... registration stuff you need - -// this makes JSONAPI.NET create the route 'api/posts' -configuration.CustomBaseUrlService = new BaseUrlService("api"); -``` - -## Set the public origin host of JSONAPI -Since JSONAPI.NET returns urls it could result wrong links if JSONAPI runs behind a reverse proxy. Configure the public origin address as follows: -```C# -var configuration = new JsonApiConfiguration(); -configuration.RegisterEntityFrameworkResourceType(); -// ... registration stuff you need - -// this makes JSONAPI.NET to set the urls in responses to https://api.example.com/posts -// Important: don't leave the second string parameter! see below. -configuration.CustomBaseUrlService = new BaseUrlService(new Uri("https://api.example.com/"), ""); - -// this can also be combined with the context paht for routing like that: -// this makes JSONAPI.NET create the route 'api/posts' and response urls to be https://api.example.com:9443/api/posts -configuration.CustomBaseUrlService = new BaseUrlService(new Uri("https://api.example.com:9443/"), "api"); - -``` - -# Metadata - - - -## Pagination - -### total-pages / total-count -When using Entity Framework you can register type `EntityFrameworkQueryableResourceCollectionDocumentBuilder` to enable the `total-pages` and `total-count` meta properties. -When pagination is used the `total-pages` and `total-count` meta properties are provided to indicate the number of pages and records to the client. - diff --git a/doc/JSONAPI.EntityFramework.shfbproj b/doc/JSONAPI.EntityFramework.shfbproj new file mode 100644 index 00000000..77f8702f --- /dev/null +++ b/doc/JSONAPI.EntityFramework.shfbproj @@ -0,0 +1,76 @@ + + + + + Debug + AnyCPU + 2.0 + {dde8ab8c-3295-4a5d-ab00-74054a2987ab} + 1.9.9.0 + + Documentation + Documentation + Documentation + + .NET Framework 4.0 + JSONAPI.EntityFramework\ + API Documentation + en-US + OnlyWarningsAndErrors + Website + False + False + False + False + True + + + + 2 + False + C#, Visual Basic + Blank + True + VS2013 + False + Guid + JSONAPI.EntityFramework + AboveNamespaces + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JSONAPI + {52B19FD6-EFAA-45B5-9C3E-A652E27608D1} + + + + + \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/SearchHelp.aspx b/doc/JSONAPI.EntityFramework/SearchHelp.aspx new file mode 100644 index 00000000..6d661efa --- /dev/null +++ b/doc/JSONAPI.EntityFramework/SearchHelp.aspx @@ -0,0 +1,233 @@ +<%@ Page Language="C#" EnableViewState="False" %> + + diff --git a/doc/JSONAPI.EntityFramework/SearchHelp.inc.php b/doc/JSONAPI.EntityFramework/SearchHelp.inc.php new file mode 100644 index 00000000..b905e130 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/SearchHelp.inc.php @@ -0,0 +1,173 @@ +filename = $file; + $this->pageTitle = $title; + $this->rank = $rank; + } +} + + +/// +/// Split the search text up into keywords +/// +/// The keywords to parse +/// A list containing the words for which to search +function ParseKeywords($keywords) +{ + $keywordList = array(); + $words = preg_split("/[^\w]+/", $keywords); + + foreach($words as $word) + { + $checkWord = strtolower($word); + $first = substr($checkWord, 0, 1); + if(strlen($checkWord) > 2 && !ctype_digit($first) && !in_array($checkWord, $keywordList)) + { + array_push($keywordList, $checkWord); + } + } + + return $keywordList; +} + + +/// +/// Search for the specified keywords and return the results as a block of +/// HTML. +/// +/// The keywords for which to search +/// The file list +/// The dictionary used to find the words +/// True to sort by title, false to sort by +/// ranking +/// A block of HTML representing the search results. +function Search($keywords, $fileInfo, $wordDictionary, $sortByTitle) +{ + $sb = "
    "; + $matches = array(); + $matchingFileIndices = array(); + $rankings = array(); + + $isFirst = true; + + foreach($keywords as $word) + { + if (!array_key_exists($word, $wordDictionary)) + { + return "Nothing found"; + } + $occurrences = $wordDictionary[$word]; + + $matches[$word] = $occurrences; + $occurrenceIndices = array(); + + // Get a list of the file indices for this match + foreach($occurrences as $entry) + array_push($occurrenceIndices, ($entry >> 16)); + + if($isFirst) + { + $isFirst = false; + foreach($occurrenceIndices as $i) + { + array_push($matchingFileIndices, $i); + } + } + else + { + // After the first match, remove files that do not appear for + // all found keywords. + for($idx = 0; $idx < count($matchingFileIndices); $idx++) + { + if (!in_array($matchingFileIndices[$idx], $occurrenceIndices)) + { + array_splice($matchingFileIndices, $idx, 1); + $idx--; + } + } + } + } + + if(count($matchingFileIndices) == 0) + { + return "Nothing found"; + } + + // Rank the files based on the number of times the words occurs + foreach($matchingFileIndices as $index) + { + // Split out the title, filename, and word count + $fileIndex = explode("\x00", $fileInfo[$index]); + + $title = $fileIndex[0]; + $filename = $fileIndex[1]; + $wordCount = intval($fileIndex[2]); + $matchCount = 0; + + foreach($keywords as $words) + { + $occurrences = $matches[$word]; + + foreach($occurrences as $entry) + { + if(($entry >> 16) == $index) + $matchCount += $entry & 0xFFFF; + } + } + + $r = new Ranking($filename, $title, $matchCount * 1000 / $wordCount); + array_push($rankings, $r); + + if(count($rankings) > 99) + break; + } + + // Sort by rank in descending order or by page title in ascending order + if($sortByTitle) + { + usort($rankings, "cmprankbytitle"); + } + else + { + usort($rankings, "cmprank"); + } + + // Format the file list and return the results + foreach($rankings as $r) + { + $f = $r->filename; + $t = $r->pageTitle; + $sb .= "
  1. $t
  2. "; + } + + $sb .= "rank - $x->rank; +} + +function cmprankbytitle($x, $y) +{ + return strcmp($x->pageTitle, $y->pageTitle); +} + +?> diff --git a/doc/JSONAPI.EntityFramework/SearchHelp.php b/doc/JSONAPI.EntityFramework/SearchHelp.php new file mode 100644 index 00000000..eaa1e117 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/SearchHelp.php @@ -0,0 +1,58 @@ + + Nothing found + $val) + { + $wordDictionary[$ftiWord] = $val; + } + } + } + } + + // Perform the search and return the results as a block of HTML + $results = Search($keywords, $fileList, $wordDictionary, $sortByTitle); + echo $results; +?> \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/Web.Config b/doc/JSONAPI.EntityFramework/Web.Config new file mode 100644 index 00000000..26672e81 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/Web.Config @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/JSONAPI.EntityFramework/WebKI.xml b/doc/JSONAPI.EntityFramework/WebKI.xml new file mode 100644 index 00000000..05e3bbb7 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/WebKI.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/JSONAPI.EntityFramework/WebTOC.xml b/doc/JSONAPI.EntityFramework/WebTOC.xml new file mode 100644 index 00000000..63ba2bbb --- /dev/null +++ b/doc/JSONAPI.EntityFramework/WebTOC.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_100.json b/doc/JSONAPI.EntityFramework/fti/FTI_100.json new file mode 100644 index 00000000..a04fa1a2 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_100.json @@ -0,0 +1 @@ +{"default":[1,393217,3080193],"documentation":[131073,262145,327684,524290,589828,655364,720900,786435,1114115,1245187,1441795,1507335,1638401,1769476,1835012,1900547,1966083,2031617,2097153,2162692,2359299,2424836,2555907,2621444,2686980,2752516,2883588,2949123,3014660,3080193,3145729,3211268,3342341,3407873,3604484,3670019],"description":[131073,196609,262145,393217,458753,851969,917505,983041,1048577,1376257,1638403,1703937,1900547,2228225,2293761,2490369,2818049,3080195,3145729,3276801,3407874,3538945,3735553],"delete":[196610,1114118,1900546],"dispose":[196611,1572868,1900547,2818052],"determines":[196609,917505,1638401,1900545,2228225,3407873],"dll":[327681,524289,589825,655361,720897,786433,1114113,1179649,1245185,1310721,1441793,1507329,1572865,1638401,1769473,1835009,1900545,1966081,2031617,2097153,2162689,2359297,2424833,2555905,2621441,2686977,2752513,2883585,2949121,3014657,3080193,3211265,3342337,3407873,3473409,3604481,3670017],"derived":[393219,1376257,3080196],"dbcontext":[458753,1638401,1900546,2031623,2097156],"data":[1507335,2097153],"disposing":[1572867]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_101.json b/doc/JSONAPI.EntityFramework/fti/FTI_101.json new file mode 100644 index 00000000..0ca34741 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_101.json @@ -0,0 +1 @@ +{"entityframework":[65537,131075,196610,262147,327689,393218,458754,524295,589833,655369,720905,786440,851970,917506,983042,1048578,1114120,1179653,1245192,1310725,1376258,1441800,1507340,1572869,1638407,1703938,1769481,1835017,1900553,1966088,2031622,2097158,2162697,2228226,2293762,2359304,2424841,2490370,2555912,2621449,2686985,2752521,2818050,2883593,2949128,3014665,3080199,3145731,3211273,3276804,3342346,3407879,3473413,3538946,3604489,3670024,3735554],"exposes":[196609,393217,458753,917505,1048577,1376257,1638401,1900545,2228225,3080193,3407873],"equals":[196609,393218,917505,1638401,1900545,2228225,3080194,3407873],"equal":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"executeasync":[196609,1900545],"exception":[196609,1900545],"encoding":[196609,1900545],"entityframeworkmaterializer":[262145,327686,458755,589830,655366,720902,851970,983042,1245189,1507337,1638408,1769478,2031619,2097157,2162694,2228227,2293762,2424838,2490370,2555909,2621446,2686982,2752518,2883590,2949125,3014662,3342343,3538946,3604486,3735554],"ephemeral":[327684,589828,720900,1769476,2162692,2424836,2621444,2686980],"enumeratequeryableasyncattribute":[393219,1179652,1376259,3080200,3145729,3211270],"entity":[1507335,2097153,3342340],"entitystate":[1507338],"entitykey":[3014659]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_102.json b/doc/JSONAPI.EntityFramework/fti/FTI_102.json new file mode 100644 index 00000000..fc051804 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_102.json @@ -0,0 +1 @@ +{"follow":[1],"following":[196609,393217,458753,917505,1048577,1376257,1638401,1900545,2228225,3080193,3407873],"finalize":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"free":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"function":[196609,327681,524289,589825,655361,720897,786433,917505,1114113,1245185,1441793,1507329,1638401,1769473,1835009,1900545,1966081,2162689,2228225,2359297,2424833,2555905,2621441,2686977,2752513,2883585,2949121,3014657,3211265,3342337,3407873,3604481,3670017],"filterattribute":[1376257,3080194],"findstate":[1507332],"false":[1572865,3342338],"filters":[3211268],"fixuprelationships":[3342340]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_103.json b/doc/JSONAPI.EntityFramework/fti/FTI_103.json new file mode 100644 index 00000000..5010dfc1 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_103.json @@ -0,0 +1 @@ +{"generic":[196609,1048577,1835013,1966084],"garbage":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"gethashcode":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"gettype":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"gets":[196609,393217,917505,1376257,1638401,1900545,2228225,3080194,3407873],"getbyidasync":[655369,1638402,2228226,2293763,2883593],"getassociationchanges":[1507338,1638401,2228225],"getbyid":[1638402,2228226,2490371,2752521,3604489],"getdetachedoriginal":[1638401,2228225,3342344],"getentitysetname":[1638401,2228225,2555910],"getkeynames":[1638401,2228225,2949126]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_104.json b/doc/JSONAPI.EntityFramework/fti/FTI_104.json new file mode 100644 index 00000000..2391052a --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_104.json @@ -0,0 +1 @@ +{"http":[131074,196609,524292,786437,1048577,1114117,1572866,1703937,1835014,1900551,1966085,2359301,2818049,3211268,3276801,3473410],"httpstatuscode":[196612,1900548],"hash":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"httpactionexecutedcontext":[393217,3080193,3211271],"hierarchy":[1638401,1900545,3080193,3407873]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_105.json b/doc/JSONAPI.EntityFramework/fti/FTI_105.json new file mode 100644 index 00000000..2682111c --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_105.json @@ -0,0 +1 @@ +{"inherited":[196649,393227,917510,1048584,1376258,1638406,1900593,2228230,2818049,3080205,3407878],"idictionary":[196610,1900546],"instance":[196609,393221,917505,1179649,1310721,1638402,1900546,2097153,2228225,3080198,3407874,3473409],"initialize":[196609,1900545],"internalservererror":[196610,1900546],"ilist":[196610,1835018,1900546,1966089],"imaterializer":[196609,327681,524291,589825,655361,720897,786434,1638402,1769473,1900545,2162689,2359302,2424833,2621441,2686977,2752513,2883585,3604481],"ienumerable":[196609,1507331,1900545,2949123],"implements":[327681,589825,655361,720897,1441793,1638401,1769473,2162689,2424833,2621441,2686977,2752513,2883585,3407873,3604481,3670017],"indicates":[393219,3080195],"isdefaultattribute":[393217,3080193],"idvalues":[655364,2883588],"initializes":[1179649,1310721,1638401,1900545,2097153,3080193,3407873,3473409],"ismodel":[1245190,1638401,2228225],"implemented":[1376257,3080193],"identifier":[1376257,3080193],"ipluralizationservice":[1441793,3407874,3670017],"inheritance":[1638401,1900545,3080193,3407873],"inherits":[1900545,3080193],"iqueryable":[2359299]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_106.json b/doc/JSONAPI.EntityFramework/fti/FTI_106.json new file mode 100644 index 00000000..90f190c8 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_106.json @@ -0,0 +1 @@ +{"jsonapi":[65537,131075,196610,262147,327689,393218,458754,524295,589833,655369,720905,786440,851970,917506,983042,1048578,1114120,1179653,1245192,1310725,1376258,1441800,1507340,1572869,1638407,1703938,1769481,1835017,1900554,1966088,2031622,2097158,2162697,2228226,2293762,2359308,2424841,2490370,2555912,2621449,2686985,2752521,2818050,2883593,2949128,3014665,3080199,3145731,3211273,3276804,3342346,3407879,3473413,3538946,3604489,3670024,3735554],"json":[196611,1900547],"jsonserializersettings":[196610,1900546]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_107.json b/doc/JSONAPI.EntityFramework/fti/FTI_107.json new file mode 100644 index 00000000..5b0d8c1a --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_107.json @@ -0,0 +1 @@ +{"keyvalues":[2752516,3604484]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_108.json b/doc/JSONAPI.EntityFramework/fti/FTI_108.json new file mode 100644 index 00000000..dfdbb850 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_108.json @@ -0,0 +1 @@ +{"link":[1],"list":[851969,983041,1703937,2293761,2490369,2818049,3538945,3735553]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_109.json b/doc/JSONAPI.EntityFramework/fti/FTI_109.json new file mode 100644 index 00000000..3ff49cb7 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_109.json @@ -0,0 +1 @@ +{"missing":[131073,262145,327684,524290,589828,655364,720900,786435,1114115,1245187,1441795,1507335,1638401,1769476,1835012,1900547,1966083,2031617,2097153,2162692,2359299,2424836,2555907,2621444,2686980,2752516,2883588,2949123,3014660,3080193,3145729,3211268,3342341,3407873,3604484,3670019],"methods":[196610,393218,917506,1638401,1900545,2228226,3080193,3407873],"members":[196609,393217,458753,917505,1048577,1376257,1638401,1900545,2228225,3080193,3407873],"modelstatedictionary":[196609,1900545],"mediatypeformatter":[196611,1900547],"mediatypeheadervalue":[196609,1900545],"materializerfactory":[196612,524294,786439,1703941,1900548],"memberwiseclone":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"materialize":[327689,851971,1638402,2228226,2621449],"method":[327681,524289,589825,655361,720897,786433,851969,983041,1114113,1245185,1441793,1507329,1572865,1703937,1769473,1835009,1966081,2162689,2293761,2359297,2424833,2490369,2555905,2621441,2686977,2752513,2818049,2883585,2949121,3014657,3211265,3342337,3538945,3604481,3670017,3735553],"match":[393217,3080193],"materializeasync":[589833,983043,1638402,2228226,2424841],"materializeupdate":[720905,1638402,1769481,2228226,3735555],"modelstate":[1048577,1900545],"managed":[1572866,1900545,2818049],"materializeentitykey":[1638401,2228225,3014663],"materializeupdateasync":[1638402,2162697,2228226,2686985,3538947],"materializer":[2359300]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_110.json b/doc/JSONAPI.EntityFramework/fti/FTI_110.json new file mode 100644 index 00000000..fd34d010 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_110.json @@ -0,0 +1 @@ +{"namespace":[131073,196609,262145,327682,393217,458753,524290,589826,655362,720898,786434,851969,917505,983041,1048577,1114114,1179650,1245186,1310722,1376257,1441794,1507330,1572866,1638402,1703937,1769474,1835010,1900546,1966082,2031618,2097154,2162690,2228225,2293761,2359298,2424834,2490369,2555906,2621442,2686978,2752514,2818049,2883586,2949122,3014658,3080194,3145729,3211266,3276801,3342338,3407874,3473410,3538945,3604482,3670018,3735553],"notfound":[196609,1900545],"new":[1179650,1310722,1638401,1900545,2097154,3080193,3407873,3473410],"null":[2359297],"namespaces":[3276802]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_111.json b/doc/JSONAPI.EntityFramework/fti/FTI_111.json new file mode 100644 index 00000000..289e2b8a --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_111.json @@ -0,0 +1 @@ +{"object":[196623,327692,393225,655369,720908,851969,917515,983041,1638420,1900560,2162700,2228243,2293762,2424844,2490370,2752524,2883596,3014663,3080202,3407884,3538945,3604489,3735553],"overrides":[196615,393217,524289,786433,1114113,1572865,1703938,1835009,1900551,1966081,2359297,2818049,3080193,3211265],"operations":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"overload":[327681,524289,589825,655361,720897,786433,851969,983041,1572865,1703937,1769473,2162689,2293761,2424833,2490369,2621441,2686977,2752513,2818049,2883585,3538945,3604481,3735553],"overridden":[393218,3080194],"onactionexecuted":[393217,3080193],"onactionexecutedasync":[393218,3080194,3211271],"onactionexecuting":[393217,3080193],"onactionexecutingasync":[393217,3080193],"override":[524289,786433,1114113,1572865,1835009,1966081,2359297,3211265],"objecttype":[1245188],"optionally":[1572865,1900545,2818049],"optional":[2359298,3342338],"overridable":[2424833,2883585,2949121],"obj":[3014660]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_112.json b/doc/JSONAPI.EntityFramework/fti/FTI_112.json new file mode 100644 index 00000000..c321eec0 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_112.json @@ -0,0 +1 @@ +{"perform":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"particular":[196609,917505,1638401,1900545,2228225,3407873],"post":[196610,1900546,1966086],"pluralizationservice":[262145,917507,1310724,1441797,3407880,3670021],"public":[327682,589826,655362,720898,1114114,1179650,1245186,1310722,1441794,1507330,1638402,1769474,1835010,1900546,1966082,2031618,2097154,2162690,2424834,2621442,2686978,2752514,2883586,3080194,3211266,3342338,3407874,3473410,3604482,3670018],"parameters":[327681,589826,655362,720897,786433,1114113,1245185,1441793,1507330,1572865,1769474,1835009,1900545,1966081,2097153,2162689,2359297,2424833,2555905,2621442,2686978,2752513,2883585,2949121,3014657,3211265,3342338,3604482,3670017],"param":[327682,589825,655361,720898,1114113,1245185,1441793,1507331,1769473,1835010,1966081,2097153,2162690,2359297,2424834,2555905,2621441,2686977,2752514,2883586,2949121,3014658,3211266,3342338,3604481,3670017],"properties":[458754,1048578,1376258,1638401,1900545,3080193],"protected":[524290,786434,1572866,2359298,2555906,2949122,3014658],"params":[655361,2752513,2883585,3604481],"paramarray":[655361,2752513,2883585,3604481],"pluralize":[917505,3407873,3670023],"parent":[1507332],"propertyname":[1507332],"putobjs":[1835012],"postedobjs":[1966084],"property":[2031619]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_113.json b/doc/JSONAPI.EntityFramework/fti/FTI_113.json new file mode 100644 index 00000000..ceb87754 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_113.json @@ -0,0 +1 @@ +{"queryablefactory":[196610,1900546,2359302]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_114.json b/doc/JSONAPI.EntityFramework/fti/FTI_114.json new file mode 100644 index 00000000..82452ef4 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_114.json @@ -0,0 +1 @@ +{"redirected":[1],"resources":[196609,393217,917505,1572868,1638401,1900547,2228225,2818050,3080193,3407873],"reclaimed":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"redirect":[196610,1900546],"redirecttoroute":[196610,1900546],"responsemessage":[196609,1900545],"returns":[196609,327681,393220,524289,589825,655361,720897,786433,917505,1114113,1245185,1441793,1507329,1638401,1769473,1835009,1900545,1966081,2162689,2228225,2359297,2424833,2555905,2621441,2686977,2752513,2883585,2949121,3014657,3080196,3211265,3342337,3407873,3604481,3670017],"represents":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"reference":[196609,327681,393217,458753,524289,589825,655361,720897,786433,851969,917505,983041,1048577,1114113,1179649,1245185,1310721,1376257,1441793,1507329,1572865,1638401,1703937,1769473,1835009,1900545,1966081,2031617,2097153,2162689,2228225,2293761,2359297,2424833,2490369,2555905,2621441,2686977,2752513,2818049,2883585,2949121,3014657,3080193,3211265,3342337,3407873,3473409,3538945,3604481,3670017,3735553],"return":[327681,524289,589825,655361,720897,786433,1114113,1245185,1441793,1507329,1769473,1835009,1966081,2162689,2359297,2424833,2555905,2621441,2686977,2752513,2883585,2949121,3014657,3211265,3342337,3604481,3670017],"request":[1048577,1900545],"requestcontext":[1048577,1900545],"releases":[1572866,1900546,2818050],"release":[1572866],"readonly":[2031617]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_115.json b/doc/JSONAPI.EntityFramework/fti/FTI_115.json new file mode 100644 index 00000000..35942126 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_115.json @@ -0,0 +1 @@ +{"search":[65537],"sort":[65537],"summary":[131073,262145,327681,524289,589825,655361,720897,786433,1114113,1245185,1441793,1507329,1638401,1769473,1835009,1900545,1966081,2031617,2162689,2359297,2424833,2555905,2621441,2686977,2752513,2883585,2949121,3014657,3080193,3145729,3211265,3342337,3407873,3604481,3670017],"string":[196623,393217,917505,1114118,1441802,1507338,1638401,1835015,1900559,2228225,2555907,2949123,3080193,3407873,3670026],"specified":[196609,393218,917505,1638401,1900545,2228225,3080194,3407873],"serves":[196609,917505,1638401,1900545,2228225,3407873],"shallow":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"statuscode":[196609,1900545],"system":[327690,655365,720906,1114116,1245188,1441796,1507343,1572865,1638401,1835018,1900545,1966084,2097153,2162698,2424842,2555908,2752522,2883594,2949124,3014666,3080194,3211273,3342342,3407873,3604485,3670020],"syntax":[327681,524289,589825,655361,720897,786433,1114113,1179649,1245185,1310721,1441793,1507329,1572865,1638401,1769473,1835009,1900545,1966081,2031617,2097153,2162689,2359297,2424833,2555905,2621441,2686977,2752513,2883585,2949121,3014657,3080193,3211265,3342337,3407873,3473409,3604481,3670017],"singularize":[917505,1441799,3407873],"sub":[1179649,1310721,1572865,2097153,3473409]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_116.json b/doc/JSONAPI.EntityFramework/fti/FTI_116.json new file mode 100644 index 00000000..f3de1913 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_116.json @@ -0,0 +1 @@ +{"topic":[1],"title":[65537],"type":[196611,327696,393218,458753,524289,589827,655363,720912,786434,851969,917507,983041,1048577,1114114,1245192,1376257,1441794,1507333,1572865,1638409,1769475,1835011,1900548,1966082,2031617,2097153,2162704,2228233,2293761,2359298,2424848,2490369,2555916,2621443,2686979,2752528,2883600,2949132,3014670,3080194,3211267,3342340,3407875,3538945,3604483,3670018,3735553],"try":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"tostring":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"top":[196609,393217,458753,851969,917505,983041,1048577,1376257,1638403,1703937,1900547,2228225,2293761,2490369,2818049,3080195,3407874,3538945,3735553],"task":[589827,655363,1114115,1835011,1966083,2162691,2424835,2686979,2883587,3211267],"typeparam":[589825,655361,786433,1507330,1769473,1900546,2621441,2686977,3342337,3604481],"typeid":[1376257,3080193],"true":[1572865],"threading":[3211269]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_117.json b/doc/JSONAPI.EntityFramework/fti/FTI_117.json new file mode 100644 index 00000000..2eeac8b0 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_117.json @@ -0,0 +1 @@ +{"ump":[196622,1900558],"uri":[196610,1900546],"unauthorized":[196610,1900546],"url":[1048577,1900545],"user":[1048577,1900545],"unique":[1376257,3080193],"unmanaged":[1572867,1900545,2818049],"used":[1572865,1900545,2818049]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_118.json b/doc/JSONAPI.EntityFramework/fti/FTI_118.json new file mode 100644 index 00000000..66417313 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_118.json @@ -0,0 +1 @@ +{"validate":[196610,1900546],"version":[327681,524289,589825,655361,720897,786433,1114113,1179649,1245185,1310721,1441793,1507329,1572865,1638401,1769473,1835009,1900545,1966081,2031617,2097153,2162689,2359297,2424833,2555905,2621441,2686977,2752513,2883585,2949121,3014657,3080193,3211265,3342337,3407873,3473409,3604481,3670017],"value":[327681,393220,524289,589825,655361,720897,786433,1114113,1245185,1441793,1507329,1769473,1835009,1966081,2031617,2162689,2359297,2424833,2555905,2621441,2686977,2752513,2883585,2949121,3014657,3080196,3211265,3342337,3604481,3670017],"void":[1572865],"virtual":[2424833,2883585,2949121]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_119.json b/doc/JSONAPI.EntityFramework/fti/FTI_119.json new file mode 100644 index 00000000..659bc55f --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_119.json @@ -0,0 +1 @@ +{"web":[3211268]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_97.json b/doc/JSONAPI.EntityFramework/fti/FTI_97.json new file mode 100644 index 00000000..2607d555 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_97.json @@ -0,0 +1 @@ +{"automatically":[1],"apicontroller":[131073,196653,524292,786437,1048587,1114117,1572867,1703940,1835014,1900609,1966085,2359301,2818053,3473412],"allows":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"authenticationheadervalue":[196610,1900546],"assembly":[327681,524289,589825,655361,720897,786433,1114113,1179649,1245185,1310721,1441793,1507329,1572865,1638401,1769473,1835009,1900545,1966081,2031617,2097153,2162689,2359297,2424833,2555905,2621441,2686977,2752513,2883585,2949121,3014657,3080193,3211265,3342337,3407873,3473409,3604481,3670017],"attribute":[393220,1376258,3080199],"actionfilterattribute":[393220,3080199],"actionfilters":[393217,1179650,1376257,3080196,3145730,3211270,3276801],"actioncontext":[1048577,1900545],"allowmultiple":[1376257,3080193],"actionexecutedcontext":[3211268]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_98.json b/doc/JSONAPI.EntityFramework/fti/FTI_98.json new file mode 100644 index 00000000..f02528c1 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_98.json @@ -0,0 +1 @@ +{"badrequest":[196611,1900547],"boolean":[196610,1245186,1572867,1900546,2818050,3342343],"bool":[1245185,1572865,3342337]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_99.json b/doc/JSONAPI.EntityFramework/fti/FTI_99.json new file mode 100644 index 00000000..48308e0b --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_99.json @@ -0,0 +1 @@ +{"classes":[131073,262145,3145729],"class":[131073,196609,262145,327681,393220,458753,524289,589825,655361,720897,786433,851969,917505,983041,1048577,1114113,1179650,1245185,1310722,1376258,1441793,1507329,1572865,1638404,1703937,1769473,1835009,1900550,1966081,2031617,2097154,2162689,2228225,2293761,2359297,2424833,2490369,2555905,2621441,2686977,2752513,2818049,2883585,2949121,3014657,3080200,3145729,3211265,3342339,3407876,3473410,3538945,3604481,3670017,3735553],"conflict":[196609,1900545],"content":[196612,1900548],"created":[196610,1900546],"createdatroute":[196610,1900546],"current":[196612,393219,917508,1638404,1900548,2228228,3080195,3407876],"cleanup":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"collection":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"creates":[196609,393217,917505,1638401,1900545,2228225,3080193,3407873],"copy":[196609,327681,393217,524289,589825,655361,720897,786433,917505,1114113,1179649,1245185,1310721,1441793,1507329,1572865,1638402,1769473,1835009,1900546,1966081,2031617,2097153,2162689,2228225,2359297,2424833,2555905,2621441,2686977,2752513,2883585,2949121,3014657,3080194,3211265,3342337,3407874,3473409,3604481,3670017],"code":[393217,3080193],"cancellationtoken":[393217,3080193,3211275],"configuration":[1048577,1900545],"controllercontext":[1048577,1900545],"constructor":[1179649,1310721,2097153,3473409],"constructors":[1638401,1900545,3080193,3407873],"collections":[1835013,1966084],"context":[2097156],"ctor":[2097153],"core":[2359300]} \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/fti/FTI_Files.json b/doc/JSONAPI.EntityFramework/fti/FTI_Files.json new file mode 100644 index 00000000..e0ce6a58 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/fti/FTI_Files.json @@ -0,0 +1 @@ +["JSONAPI.EntityFramework - Redirect\u0000index.html\u000018","JSONAPI.EntityFramework - Search\u0000search.html\u000011","JSONAPI.EntityFramework.Http Namespace\u0000html/07bd4c44-795a-6b89-ff4d-ceceaa12276b.htm\u000029","ApiController(T, TC) Methods\u0000html/07da212f-e1b5-fd77-c9c3-6c2329846f20.htm\u0000650","JSONAPI.EntityFramework Namespace\u0000html/15e4280f-8e2f-a3f5-b650-78be00330729.htm\u000025","EntityFrameworkMaterializer.Materialize Method (Type, Object)\u0000html/1730c17e-c52e-360b-f949-2a4c24b1befb.htm\u0000196","EnumerateQueryableAsyncAttribute Methods\u0000html/2701266e-b6c0-dde2-8d11-7d73e812be45.htm\u0000241","EntityFrameworkMaterializer Properties\u0000html/28b270ad-7692-7774-2d02-8acf0b8996f9.htm\u000027","ApiController(T, TC).MaterializerFactory Method\u0000html/2c0f4db2-85cf-e8cc-19f1-35fb5fdb4786.htm\u0000109","EntityFrameworkMaterializer.MaterializeAsync(T) Method (T)\u0000html/2ebac89b-16cc-4c8a-68b3-0490722f0e14.htm\u0000205","EntityFrameworkMaterializer.GetByIdAsync(T) Method (Object[])\u0000html/2fc97a05-da4f-bade-fec4-6ce75c07e8bc.htm\u0000220","EntityFrameworkMaterializer.MaterializeUpdate Method (Type, Object)\u0000html/2ff2095e-78a6-5e6c-c3c6-1595fdd48ac5.htm\u0000196","ApiController(T, TC).MaterializerFactory(TM) Method\u0000html/371aba5b-c59f-5ae2-fe25-c28b6a791d7b.htm\u0000156","EntityFrameworkMaterializer.Materialize Method\u0000html/3eed7f6b-390a-07c2-2921-be906828ba45.htm\u000030","PluralizationService Methods\u0000html/41929b61-5dad-106e-73e1-1a4d2cbcb698.htm\u0000147","EntityFrameworkMaterializer.MaterializeAsync Method\u0000html/43108f08-16a6-8a42-e39f-96bb74e8c1bf.htm\u000030","ApiController(T, TC) Properties\u0000html/438fd8ba-cb72-fa6d-f960-75a50467c30c.htm\u0000102","ApiController(T, TC).Delete Method\u0000html/4a1f57cc-79c8-2c08-4d98-db4058273922.htm\u0000154","EnumerateQueryableAsyncAttribute Constructor\u0000html/4c86ddaf-64ff-693a-9e2a-53d2cd076aa0.htm\u000063","EntityFrameworkMaterializer.IsModel Method\u0000html/4d37bf36-e4d6-5c39-0c0d-947ed34acd4f.htm\u0000137","PluralizationService Constructor\u0000html/5670e8df-1898-855e-5d40-9f57710029df.htm\u000061","EnumerateQueryableAsyncAttribute Properties\u0000html/5ad1c883-7ac8-b992-5e03-b41b91a00d7d.htm\u000059","PluralizationService.Singularize Method\u0000html/5b27ee15-edc3-a55b-5b8b-67bb244c08ad.htm\u0000142","EntityFrameworkMaterializer.GetAssociationChanges(T1, T2) Method\u0000html/6a5ca17e-e2db-755d-5e5b-b3e3be5b4e9b.htm\u0000345","ApiController(T, TC).Dispose Method (Boolean)\u0000html/6c23b2a8-b994-4536-6fc3-afade0f91a33.htm\u0000119","EntityFrameworkMaterializer Class\u0000html/6df37ffc-86f8-41a4-fd5a-a37d259bf0fa.htm\u0000300","ApiController(T, TC).MaterializerFactory Method\u0000html/88111ca7-4b46-b950-17c5-777051c25ecb.htm\u000047","EntityFrameworkMaterializer.MaterializeUpdate(T) Method (T)\u0000html/89e2da30-a837-8a4e-6444-f0e311a53bc9.htm\u0000196","ApiController(T, TC).Put Method\u0000html/8e2a2452-49ad-090c-c928-842366f4c53a.htm\u0000251","ApiController(T, TC) Class\u0000html/8efec7ac-68f7-ad41-a00d-be1e2e872e66.htm\u0000905","ApiController(T, TC).Post Method\u0000html/8f2b95e5-015b-69a9-5c7b-34c7ab5780bb.htm\u0000199","EntityFrameworkMaterializer.DbContext Property\u0000html/91a91929-9b6b-2772-7635-804659c1f97d.htm\u000083","EntityFrameworkMaterializer Constructor\u0000html/98526291-7a55-a2c0-08e6-943d77516215.htm\u0000102","EntityFrameworkMaterializer.MaterializeUpdateAsync Method (Type, Object)\u0000html/98d60769-47c4-18fb-c63a-7e62f37aae6e.htm\u0000208","EntityFrameworkMaterializer Methods\u0000html/abfc46dc-150f-d53a-cf6a-58943a14517e.htm\u0000221","EntityFrameworkMaterializer.GetByIdAsync Method\u0000html/ad6a3345-5e74-d28d-9d00-0dc267e7f967.htm\u000033","ApiController(T, TC).QueryableFactory Method\u0000html/ade58a6f-ba3f-5310-da5f-039ca1abb647.htm\u0000177","EntityFrameworkMaterializer.MaterializeAsync Method (Type, Object)\u0000html/b2c4512b-5dac-60fb-0a52-70f8e9179b70.htm\u0000210","EntityFrameworkMaterializer.GetById Method\u0000html/bc692047-23da-f896-c881-4a5f7dede626.htm\u000033","EntityFrameworkMaterializer.GetEntitySetName Method\u0000html/bc79aaf3-58d1-3557-5470-b6a0c5c58497.htm\u0000137","EntityFrameworkMaterializer.Materialize(T) Method (T)\u0000html/bed5a4f4-9fd5-3c2f-1901-5956cb5b0373.htm\u0000196","EntityFrameworkMaterializer.MaterializeUpdateAsync(T) Method (T)\u0000html/c3f8cb7a-4cdc-5389-5713-9747afdc28f9.htm\u0000205","EntityFrameworkMaterializer.GetById Method (Type, Object[])\u0000html/d0181d5a-e42c-c8eb-5009-a83afa9bd2c6.htm\u0000214","ApiController(T, TC).Dispose Method\u0000html/d0d99559-192d-78b9-7f57-497ac23ab350.htm\u000065","EntityFrameworkMaterializer.GetByIdAsync Method (Type, Object[])\u0000html/d2bb875b-b24d-f596-c91b-5852f732618f.htm\u0000228","EntityFrameworkMaterializer.GetKeyNames Method\u0000html/d2f26545-8e12-f85b-ccd7-7d84e27b8cfc.htm\u0000151","EntityFrameworkMaterializer.MaterializeEntityKey Method\u0000html/d4ad7991-3a8c-c2e0-fa99-04961986bf30.htm\u0000182","EnumerateQueryableAsyncAttribute Class\u0000html/d95520ab-5500-139d-0c81-2d7bfb312544.htm\u0000358","JSONAPI.EntityFramework.ActionFilters Namespace\u0000html/db674e66-d6db-87a6-42ed-c1b5283a41d9.htm\u000026","EnumerateQueryableAsyncAttribute.OnActionExecutedAsync Method\u0000html/df676c29-93bb-a6c7-ae9c-89fc3d87a791.htm\u0000206","Namespaces\u0000html/e07fd430-ab76-0616-db59-1db2ad643280.htm\u000016","EntityFrameworkMaterializer.GetDetachedOriginal(T) Method\u0000html/e18adb08-399a-103d-3070-99866de5dcff.htm\u0000249","PluralizationService Class\u0000html/ed000be8-1c5d-2cca-5782-7bf3efb12355.htm\u0000221","ApiController(T, TC) Constructor\u0000html/ed7c768c-e85e-6e1b-3779-02b3892de22d.htm\u000073","EntityFrameworkMaterializer.MaterializeUpdateAsync Method\u0000html/edd56717-2deb-c819-27dd-1dc645330c3c.htm\u000030","EntityFrameworkMaterializer.GetById(T) Method (Object[])\u0000html/f4f4023a-231d-23f4-244c-b7dd1d662683.htm\u0000211","PluralizationService.Pluralize Method\u0000html/fd1d8e27-c123-5604-cbc4-e02e76638ffa.htm\u0000142","EntityFrameworkMaterializer.MaterializeUpdate Method\u0000html/fff25c2a-79a5-4ef1-4b74-1e52466db7ea.htm\u000030"] \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/07bd4c44-795a-6b89-ff4d-ceceaa12276b.htm b/doc/JSONAPI.EntityFramework/html/07bd4c44-795a-6b89-ff4d-ceceaa12276b.htm new file mode 100644 index 00000000..47f6a81c --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/07bd4c44-795a-6b89-ff4d-ceceaa12276b.htm @@ -0,0 +1,3 @@ +JSONAPI.EntityFramework.Http Namespace \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/07da212f-e1b5-fd77-c9c3-6c2329846f20.htm b/doc/JSONAPI.EntityFramework/html/07da212f-e1b5-fd77-c9c3-6c2329846f20.htm new file mode 100644 index 00000000..34fdc097 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/07da212f-e1b5-fd77-c9c3-6c2329846f20.htm @@ -0,0 +1,3 @@ +ApiController(T, TC) Methods
    ApiControllerT, TC Methods

    The ApiControllerT, TC generic type exposes the following members.

    Methods
    +   + NameDescription
    Protected methodBadRequest (Inherited from ApiController.)
    Protected methodBadRequest(String) (Inherited from ApiController.)
    Protected methodBadRequest(ModelStateDictionary) (Inherited from ApiController.)
    Protected methodConflict (Inherited from ApiController.)
    Protected methodContent``1(HttpStatusCode, UMP) (Inherited from ApiController.)
    Protected methodContent``1(HttpStatusCode, UMP, MediaTypeFormatter) (Inherited from ApiController.)
    Protected methodContent``1(HttpStatusCode, UMP, MediaTypeFormatter, String) (Inherited from ApiController.)
    Protected methodContent``1(HttpStatusCode, UMP, MediaTypeFormatter, MediaTypeHeaderValue) (Inherited from ApiController.)
    Protected methodCreated``1(String, UMP) (Inherited from ApiController.)
    Protected methodCreated``1(Uri, UMP) (Inherited from ApiController.)
    Protected methodCreatedAtRoute``1(String, Object, UMP) (Inherited from ApiController.)
    Protected methodCreatedAtRoute``1(String, IDictionaryString, Object, UMP) (Inherited from ApiController.)
    Public methodDelete (Overrides ApiControllerTDelete(String).)
    Public methodDispose (Inherited from ApiController.)
    Protected methodDispose(Boolean) (Overrides ApiController.Dispose(Boolean).)
    Public methodEquals
    Determines whether the specified Object is equal to the current Object.
    (Inherited from Object.)
    Public methodExecuteAsync (Inherited from ApiController.)
    Protected methodFinalize
    Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
    (Inherited from Object.)
    Public methodGet (Inherited from ApiControllerT.)
    Public methodGet(String) (Inherited from ApiControllerT.)
    Public methodGetHashCode
    Serves as a hash function for a particular type.
    (Inherited from Object.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Protected methodInitialize (Inherited from ApiController.)
    Protected methodInternalServerError (Inherited from ApiController.)
    Protected methodInternalServerError(Exception) (Inherited from ApiController.)
    Protected methodJson``1(UMP) (Inherited from ApiController.)
    Protected methodJson``1(UMP, JsonSerializerSettings) (Inherited from ApiController.)
    Protected methodJson``1(UMP, JsonSerializerSettings, Encoding) (Inherited from ApiController.)
    Protected methodMaterializerFactory (Overrides ApiControllerTMaterializerFactory.)
    Protected methodMaterializerFactoryTM (Overrides ApiControllerTMaterializerFactory.)
    Protected methodMemberwiseClone
    Creates a shallow copy of the current Object.
    (Inherited from Object.)
    Protected methodNotFound (Inherited from ApiController.)
    Protected methodOk (Inherited from ApiController.)
    Protected methodOk``1(UMP) (Inherited from ApiController.)
    Public methodPost (Overrides ApiControllerTPost(IListT).)
    Public methodPut (Overrides ApiControllerTPut(String, IListT).)
    Protected methodQueryableFactory (Overrides ApiControllerTQueryableFactory(IMaterializer).)
    Protected methodRedirect(String) (Inherited from ApiController.)
    Protected methodRedirect(Uri) (Inherited from ApiController.)
    Protected methodRedirectToRoute(String, Object) (Inherited from ApiController.)
    Protected methodRedirectToRoute(String, IDictionaryString, Object) (Inherited from ApiController.)
    Protected methodResponseMessage (Inherited from ApiController.)
    Protected methodStatusCode (Inherited from ApiController.)
    Public methodToString
    Returns a string that represents the current object.
    (Inherited from Object.)
    Protected methodUnauthorized(AuthenticationHeaderValue) (Inherited from ApiController.)
    Protected methodUnauthorized(IEnumerableAuthenticationHeaderValue) (Inherited from ApiController.)
    Public methodValidate``1(UMP) (Inherited from ApiController.)
    Public methodValidate``1(UMP, String) (Inherited from ApiController.)
    Top
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/15e4280f-8e2f-a3f5-b650-78be00330729.htm b/doc/JSONAPI.EntityFramework/html/15e4280f-8e2f-a3f5-b650-78be00330729.htm new file mode 100644 index 00000000..3346cf53 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/15e4280f-8e2f-a3f5-b650-78be00330729.htm @@ -0,0 +1,3 @@ +JSONAPI.EntityFramework Namespace
    JSONAPI.EntityFramework Namespace

    [Missing <summary> documentation for "N:JSONAPI.EntityFramework"]

    Classes
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/1730c17e-c52e-360b-f949-2a4c24b1befb.htm b/doc/JSONAPI.EntityFramework/html/1730c17e-c52e-360b-f949-2a4c24b1befb.htm new file mode 100644 index 00000000..84188de6 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/1730c17e-c52e-360b-f949-2a4c24b1befb.htm @@ -0,0 +1,7 @@ +EntityFrameworkMaterializer.Materialize Method (Type, Object)
    EntityFrameworkMaterializerMaterialize Method (Type, Object)

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.Materialize(System.Type,System.Object)"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public Object Materialize(
    +	Type type,
    +	Object ephemeral
    +)

    Parameters

    type
    Type: SystemType

    [Missing <param name="type"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.Materialize(System.Type,System.Object)"]

    ephemeral
    Type: SystemObject

    [Missing <param name="ephemeral"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.Materialize(System.Type,System.Object)"]

    Return Value

    Type: Object

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.Materialize(System.Type,System.Object)"]

    Implements

    IMaterializerMaterialize(Type, Object)
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/2701266e-b6c0-dde2-8d11-7d73e812be45.htm b/doc/JSONAPI.EntityFramework/html/2701266e-b6c0-dde2-8d11-7d73e812be45.htm new file mode 100644 index 00000000..f297e9d0 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/2701266e-b6c0-dde2-8d11-7d73e812be45.htm @@ -0,0 +1,3 @@ +EnumerateQueryableAsyncAttribute Methods
    EnumerateQueryableAsyncAttribute Methods

    The EnumerateQueryableAsyncAttribute type exposes the following members.

    Methods
    +   + NameDescription
    Public methodEquals
    Returns a value that indicates whether this instance is equal to a specified object.
    (Inherited from Attribute.)
    Protected methodFinalize
    Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
    (Inherited from Object.)
    Public methodGetHashCode
    Returns the hash code for this instance.
    (Inherited from Attribute.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Public methodIsDefaultAttribute
    When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.
    (Inherited from Attribute.)
    Public methodMatch
    When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.
    (Inherited from Attribute.)
    Protected methodMemberwiseClone
    Creates a shallow copy of the current Object.
    (Inherited from Object.)
    Public methodOnActionExecuted (Inherited from ActionFilterAttribute.)
    Public methodOnActionExecutedAsync (Overrides ActionFilterAttribute.OnActionExecutedAsync(HttpActionExecutedContext, CancellationToken).)
    Public methodOnActionExecuting (Inherited from ActionFilterAttribute.)
    Public methodOnActionExecutingAsync (Inherited from ActionFilterAttribute.)
    Public methodToString
    Returns a string that represents the current object.
    (Inherited from Object.)
    Top
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/28b270ad-7692-7774-2d02-8acf0b8996f9.htm b/doc/JSONAPI.EntityFramework/html/28b270ad-7692-7774-2d02-8acf0b8996f9.htm new file mode 100644 index 00000000..c683e993 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/28b270ad-7692-7774-2d02-8acf0b8996f9.htm @@ -0,0 +1,3 @@ +EntityFrameworkMaterializer Properties \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/2c0f4db2-85cf-e8cc-19f1-35fb5fdb4786.htm b/doc/JSONAPI.EntityFramework/html/2c0f4db2-85cf-e8cc-19f1-35fb5fdb4786.htm new file mode 100644 index 00000000..c4b093a7 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/2c0f4db2-85cf-e8cc-19f1-35fb5fdb4786.htm @@ -0,0 +1 @@ +ApiController(T, TC).MaterializerFactory Method
    ApiControllerT, TCMaterializerFactory Method

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.MaterializerFactory"]

    Namespace: JSONAPI.EntityFramework.Http
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    protected override IMaterializer MaterializerFactory()

    Return Value

    Type: IMaterializer

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.MaterializerFactory"]

    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/2ebac89b-16cc-4c8a-68b3-0490722f0e14.htm b/doc/JSONAPI.EntityFramework/html/2ebac89b-16cc-4c8a-68b3-0490722f0e14.htm new file mode 100644 index 00000000..b3f06049 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/2ebac89b-16cc-4c8a-68b3-0490722f0e14.htm @@ -0,0 +1,6 @@ +EntityFrameworkMaterializer.MaterializeAsync(T) Method (T)
    EntityFrameworkMaterializerMaterializeAsyncT Method (T)

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeAsync``1(``0)"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public Task<T> MaterializeAsync<T>(
    +	T ephemeral
    +)
    +

    Parameters

    ephemeral
    Type: T

    [Missing <param name="ephemeral"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeAsync``1(``0)"]

    Type Parameters

    T

    [Missing <typeparam name="T"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeAsync``1(``0)"]

    Return Value

    Type: TaskT

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeAsync``1(``0)"]

    Implements

    IMaterializerMaterializeAsyncT(T)
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/2fc97a05-da4f-bade-fec4-6ce75c07e8bc.htm b/doc/JSONAPI.EntityFramework/html/2fc97a05-da4f-bade-fec4-6ce75c07e8bc.htm new file mode 100644 index 00000000..45590c4b --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/2fc97a05-da4f-bade-fec4-6ce75c07e8bc.htm @@ -0,0 +1,6 @@ +EntityFrameworkMaterializer.GetByIdAsync(T) Method (Object[])
    EntityFrameworkMaterializerGetByIdAsyncT Method (Object)

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetByIdAsync``1(System.Object[])"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public Task<T> GetByIdAsync<T>(
    +	params Object[] idValues
    +)
    +

    Parameters

    idValues
    Type: SystemObject

    [Missing <param name="idValues"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetByIdAsync``1(System.Object[])"]

    Type Parameters

    T

    [Missing <typeparam name="T"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetByIdAsync``1(System.Object[])"]

    Return Value

    Type: TaskT

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetByIdAsync``1(System.Object[])"]

    Implements

    IMaterializerGetByIdAsyncT(Object)
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/2ff2095e-78a6-5e6c-c3c6-1595fdd48ac5.htm b/doc/JSONAPI.EntityFramework/html/2ff2095e-78a6-5e6c-c3c6-1595fdd48ac5.htm new file mode 100644 index 00000000..24bf9d9b --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/2ff2095e-78a6-5e6c-c3c6-1595fdd48ac5.htm @@ -0,0 +1,7 @@ +EntityFrameworkMaterializer.MaterializeUpdate Method (Type, Object)
    EntityFrameworkMaterializerMaterializeUpdate Method (Type, Object)

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeUpdate(System.Type,System.Object)"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public Object MaterializeUpdate(
    +	Type type,
    +	Object ephemeral
    +)

    Parameters

    type
    Type: SystemType

    [Missing <param name="type"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeUpdate(System.Type,System.Object)"]

    ephemeral
    Type: SystemObject

    [Missing <param name="ephemeral"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeUpdate(System.Type,System.Object)"]

    Return Value

    Type: Object

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeUpdate(System.Type,System.Object)"]

    Implements

    IMaterializerMaterializeUpdate(Type, Object)
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/371aba5b-c59f-5ae2-fe25-c28b6a791d7b.htm b/doc/JSONAPI.EntityFramework/html/371aba5b-c59f-5ae2-fe25-c28b6a791d7b.htm new file mode 100644 index 00000000..4631e009 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/371aba5b-c59f-5ae2-fe25-c28b6a791d7b.htm @@ -0,0 +1,3 @@ +ApiController(T, TC).MaterializerFactory(TM) Method
    ApiControllerT, TCMaterializerFactoryTM Method

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.MaterializerFactory``1"]

    Namespace: JSONAPI.EntityFramework.Http
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    protected override TM MaterializerFactory<TM>()
    +where TM : IMaterializer
    +

    Type Parameters

    TM

    [Missing <typeparam name="TM"/> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.MaterializerFactory``1"]

    Return Value

    Type: TM

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.MaterializerFactory``1"]

    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/3eed7f6b-390a-07c2-2921-be906828ba45.htm b/doc/JSONAPI.EntityFramework/html/3eed7f6b-390a-07c2-2921-be906828ba45.htm new file mode 100644 index 00000000..6d576423 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/3eed7f6b-390a-07c2-2921-be906828ba45.htm @@ -0,0 +1,3 @@ +EntityFrameworkMaterializer.Materialize Method \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/41929b61-5dad-106e-73e1-1a4d2cbcb698.htm b/doc/JSONAPI.EntityFramework/html/41929b61-5dad-106e-73e1-1a4d2cbcb698.htm new file mode 100644 index 00000000..e9412583 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/41929b61-5dad-106e-73e1-1a4d2cbcb698.htm @@ -0,0 +1,3 @@ +PluralizationService Methods
    PluralizationService Methods

    The PluralizationService type exposes the following members.

    Methods
    +   + NameDescription
    Public methodEquals
    Determines whether the specified Object is equal to the current Object.
    (Inherited from Object.)
    Protected methodFinalize
    Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
    (Inherited from Object.)
    Public methodGetHashCode
    Serves as a hash function for a particular type.
    (Inherited from Object.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Protected methodMemberwiseClone
    Creates a shallow copy of the current Object.
    (Inherited from Object.)
    Public methodPluralize
    Public methodSingularize
    Public methodToString
    Returns a string that represents the current object.
    (Inherited from Object.)
    Top
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/43108f08-16a6-8a42-e39f-96bb74e8c1bf.htm b/doc/JSONAPI.EntityFramework/html/43108f08-16a6-8a42-e39f-96bb74e8c1bf.htm new file mode 100644 index 00000000..820ae76f --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/43108f08-16a6-8a42-e39f-96bb74e8c1bf.htm @@ -0,0 +1,3 @@ +EntityFrameworkMaterializer.MaterializeAsync Method \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/438fd8ba-cb72-fa6d-f960-75a50467c30c.htm b/doc/JSONAPI.EntityFramework/html/438fd8ba-cb72-fa6d-f960-75a50467c30c.htm new file mode 100644 index 00000000..91c1249e --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/438fd8ba-cb72-fa6d-f960-75a50467c30c.htm @@ -0,0 +1,3 @@ +ApiController(T, TC) Properties \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/4a1f57cc-79c8-2c08-4d98-db4058273922.htm b/doc/JSONAPI.EntityFramework/html/4a1f57cc-79c8-2c08-4d98-db4058273922.htm new file mode 100644 index 00000000..124347fc --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/4a1f57cc-79c8-2c08-4d98-db4058273922.htm @@ -0,0 +1,5 @@ +ApiController(T, TC).Delete Method
    ApiControllerT, TCDelete Method

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.Delete(System.String)"]

    Namespace: JSONAPI.EntityFramework.Http
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public override Task Delete(
    +	string id
    +)

    Parameters

    id
    Type: SystemString

    [Missing <param name="id"/> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.Delete(System.String)"]

    Return Value

    Type: Task

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.Delete(System.String)"]

    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/4c86ddaf-64ff-693a-9e2a-53d2cd076aa0.htm b/doc/JSONAPI.EntityFramework/html/4c86ddaf-64ff-693a-9e2a-53d2cd076aa0.htm new file mode 100644 index 00000000..f23b2042 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/4c86ddaf-64ff-693a-9e2a-53d2cd076aa0.htm @@ -0,0 +1 @@ +EnumerateQueryableAsyncAttribute Constructor
    EnumerateQueryableAsyncAttribute Constructor
    Initializes a new instance of the EnumerateQueryableAsyncAttribute class

    Namespace: JSONAPI.EntityFramework.ActionFilters
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public EnumerateQueryableAsyncAttribute()
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/4d37bf36-e4d6-5c39-0c0d-947ed34acd4f.htm b/doc/JSONAPI.EntityFramework/html/4d37bf36-e4d6-5c39-0c0d-947ed34acd4f.htm new file mode 100644 index 00000000..8d4fe86b --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/4d37bf36-e4d6-5c39-0c0d-947ed34acd4f.htm @@ -0,0 +1,5 @@ +EntityFrameworkMaterializer.IsModel Method
    EntityFrameworkMaterializerIsModel Method

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.IsModel(System.Type)"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public bool IsModel(
    +	Type objectType
    +)

    Parameters

    objectType
    Type: SystemType

    [Missing <param name="objectType"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.IsModel(System.Type)"]

    Return Value

    Type: Boolean

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.IsModel(System.Type)"]

    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/5670e8df-1898-855e-5d40-9f57710029df.htm b/doc/JSONAPI.EntityFramework/html/5670e8df-1898-855e-5d40-9f57710029df.htm new file mode 100644 index 00000000..6fe23f07 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/5670e8df-1898-855e-5d40-9f57710029df.htm @@ -0,0 +1 @@ +PluralizationService Constructor
    PluralizationService Constructor
    Initializes a new instance of the PluralizationService class

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public PluralizationService()
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/5ad1c883-7ac8-b992-5e03-b41b91a00d7d.htm b/doc/JSONAPI.EntityFramework/html/5ad1c883-7ac8-b992-5e03-b41b91a00d7d.htm new file mode 100644 index 00000000..51a8c0da --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/5ad1c883-7ac8-b992-5e03-b41b91a00d7d.htm @@ -0,0 +1,3 @@ +EnumerateQueryableAsyncAttribute Properties \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/5b27ee15-edc3-a55b-5b8b-67bb244c08ad.htm b/doc/JSONAPI.EntityFramework/html/5b27ee15-edc3-a55b-5b8b-67bb244c08ad.htm new file mode 100644 index 00000000..e08e706c --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/5b27ee15-edc3-a55b-5b8b-67bb244c08ad.htm @@ -0,0 +1,5 @@ +PluralizationService.Singularize Method
    PluralizationServiceSingularize Method

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.PluralizationService.Singularize(System.String)"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public string Singularize(
    +	string s
    +)

    Parameters

    s
    Type: SystemString

    [Missing <param name="s"/> documentation for "M:JSONAPI.EntityFramework.PluralizationService.Singularize(System.String)"]

    Return Value

    Type: String

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.PluralizationService.Singularize(System.String)"]

    Implements

    IPluralizationServiceSingularize(String)
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/6a5ca17e-e2db-755d-5e5b-b3e3be5b4e9b.htm b/doc/JSONAPI.EntityFramework/html/6a5ca17e-e2db-755d-5e5b-b3e3be5b4e9b.htm new file mode 100644 index 00000000..238b6490 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/6a5ca17e-e2db-755d-5e5b-b3e3be5b4e9b.htm @@ -0,0 +1,10 @@ +EntityFrameworkMaterializer.GetAssociationChanges(T1, T2) Method
    EntityFrameworkMaterializerGetAssociationChangesT1, T2 Method

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetAssociationChanges``2(``0,System.String,System.Data.Entity.EntityState)"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public IEnumerable<T2> GetAssociationChanges<T1, T2>(
    +	T1 parent,
    +	string propertyName,
    +	EntityState findState
    +)
    +

    Parameters

    parent
    Type: T1

    [Missing <param name="parent"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetAssociationChanges``2(``0,System.String,System.Data.Entity.EntityState)"]

    propertyName
    Type: SystemString

    [Missing <param name="propertyName"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetAssociationChanges``2(``0,System.String,System.Data.Entity.EntityState)"]

    findState
    Type: EntityState

    [Missing <param name="findState"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetAssociationChanges``2(``0,System.String,System.Data.Entity.EntityState)"]

    Type Parameters

    T1

    [Missing <typeparam name="T1"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetAssociationChanges``2(``0,System.String,System.Data.Entity.EntityState)"]

    T2

    [Missing <typeparam name="T2"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetAssociationChanges``2(``0,System.String,System.Data.Entity.EntityState)"]

    Return Value

    Type: IEnumerableT2

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetAssociationChanges``2(``0,System.String,System.Data.Entity.EntityState)"]

    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/6c23b2a8-b994-4536-6fc3-afade0f91a33.htm b/doc/JSONAPI.EntityFramework/html/6c23b2a8-b994-4536-6fc3-afade0f91a33.htm new file mode 100644 index 00000000..639af69d --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/6c23b2a8-b994-4536-6fc3-afade0f91a33.htm @@ -0,0 +1,5 @@ +ApiController(T, TC).Dispose Method (Boolean)
    ApiControllerT, TCDispose Method (Boolean)

    Namespace: JSONAPI.EntityFramework.Http
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    protected override void Dispose(
    +	bool disposing
    +)

    Parameters

    disposing
    Type: SystemBoolean
    True to release both managed and unmanaged resources; false to release only unmanaged resources
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/6df37ffc-86f8-41a4-fd5a-a37d259bf0fa.htm b/doc/JSONAPI.EntityFramework/html/6df37ffc-86f8-41a4-fd5a-a37d259bf0fa.htm new file mode 100644 index 00000000..c02da102 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/6df37ffc-86f8-41a4-fd5a-a37d259bf0fa.htm @@ -0,0 +1,8 @@ +EntityFrameworkMaterializer Class
    EntityFrameworkMaterializer Class

    [Missing <summary> documentation for "T:JSONAPI.EntityFramework.EntityFrameworkMaterializer"]

    Inheritance Hierarchy
    SystemObject
      JSONAPI.EntityFrameworkEntityFrameworkMaterializer

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public class EntityFrameworkMaterializer : IMaterializer

    The EntityFrameworkMaterializer type exposes the following members.

    Constructors
    +   + NameDescription
    Public methodEntityFrameworkMaterializer
    Initializes a new instance of the EntityFrameworkMaterializer class
    Top
    Methods
    +   + NameDescription
    Public methodEquals
    Determines whether the specified Object is equal to the current Object.
    (Inherited from Object.)
    Protected methodFinalize
    Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
    (Inherited from Object.)
    Public methodGetAssociationChangesT1, T2
    Public methodGetById(Type, Object)
    Public methodGetByIdT(Object)
    Public methodGetByIdAsync(Type, Object)
    Public methodGetByIdAsyncT(Object)
    Public methodGetDetachedOriginalT
    Protected methodGetEntitySetName
    Public methodGetHashCode
    Serves as a hash function for a particular type.
    (Inherited from Object.)
    Protected methodGetKeyNames
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Public methodIsModel
    Public methodMaterialize(Type, Object)
    Public methodMaterializeT(T)
    Public methodMaterializeAsync(Type, Object)
    Public methodMaterializeAsyncT(T)
    Protected methodMaterializeEntityKey
    Public methodMaterializeUpdate(Type, Object)
    Public methodMaterializeUpdateT(T)
    Public methodMaterializeUpdateAsync(Type, Object)
    Public methodMaterializeUpdateAsyncT(T)
    Protected methodMemberwiseClone
    Creates a shallow copy of the current Object.
    (Inherited from Object.)
    Public methodToString
    Returns a string that represents the current object.
    (Inherited from Object.)
    Top
    Properties
    +   + NameDescription
    Public propertyDbContext
    Top
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/88111ca7-4b46-b950-17c5-777051c25ecb.htm b/doc/JSONAPI.EntityFramework/html/88111ca7-4b46-b950-17c5-777051c25ecb.htm new file mode 100644 index 00000000..f070f9f2 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/88111ca7-4b46-b950-17c5-777051c25ecb.htm @@ -0,0 +1,3 @@ +ApiController(T, TC).MaterializerFactory Method
    ApiControllerT, TCMaterializerFactory Method
    Overload List
    +   + NameDescription
    Protected methodMaterializerFactory (Overrides ApiControllerTMaterializerFactory.)
    Protected methodMaterializerFactoryTM (Overrides ApiControllerTMaterializerFactory.)
    Top
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/89e2da30-a837-8a4e-6444-f0e311a53bc9.htm b/doc/JSONAPI.EntityFramework/html/89e2da30-a837-8a4e-6444-f0e311a53bc9.htm new file mode 100644 index 00000000..251f9786 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/89e2da30-a837-8a4e-6444-f0e311a53bc9.htm @@ -0,0 +1,6 @@ +EntityFrameworkMaterializer.MaterializeUpdate(T) Method (T)
    EntityFrameworkMaterializerMaterializeUpdateT Method (T)

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeUpdate``1(``0)"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public T MaterializeUpdate<T>(
    +	T ephemeral
    +)
    +

    Parameters

    ephemeral
    Type: T

    [Missing <param name="ephemeral"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeUpdate``1(``0)"]

    Type Parameters

    T

    [Missing <typeparam name="T"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeUpdate``1(``0)"]

    Return Value

    Type: T

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeUpdate``1(``0)"]

    Implements

    IMaterializerMaterializeUpdateT(T)
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/8e2a2452-49ad-090c-c928-842366f4c53a.htm b/doc/JSONAPI.EntityFramework/html/8e2a2452-49ad-090c-c928-842366f4c53a.htm new file mode 100644 index 00000000..2107b5eb --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/8e2a2452-49ad-090c-c928-842366f4c53a.htm @@ -0,0 +1,7 @@ +ApiController(T, TC).Put Method
    ApiControllerT, TCPut Method

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.Put(System.String,System.Collections.Generic.IList{`0})"]

    Namespace: JSONAPI.EntityFramework.Http
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public override Task<IList<T>> Put(
    +	string id,
    +	IList<T> putObjs
    +)

    Parameters

    id
    Type: SystemString

    [Missing <param name="id"/> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.Put(System.String,System.Collections.Generic.IList{`0})"]

    putObjs
    Type: System.Collections.GenericIListT

    [Missing <param name="putObjs"/> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.Put(System.String,System.Collections.Generic.IList{`0})"]

    Return Value

    Type: TaskIListT

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.Put(System.String,System.Collections.Generic.IList{`0})"]

    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/8efec7ac-68f7-ad41-a00d-be1e2e872e66.htm b/doc/JSONAPI.EntityFramework/html/8efec7ac-68f7-ad41-a00d-be1e2e872e66.htm new file mode 100644 index 00000000..b35c945b --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/8efec7ac-68f7-ad41-a00d-be1e2e872e66.htm @@ -0,0 +1,11 @@ +ApiController(T, TC) Class
    ApiControllerT, TC Class

    [Missing <summary> documentation for "T:JSONAPI.EntityFramework.Http.ApiController`2"]

    Inheritance Hierarchy
    SystemObject
      ApiController
        JSONAPI.HttpApiControllerT
          JSONAPI.EntityFramework.HttpApiControllerT, TC

    Namespace: JSONAPI.EntityFramework.Http
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public class ApiController<T, TC> : ApiController<T>
    +where T : class
    +where TC : DbContext
    +

    Type Parameters

    T

    [Missing <typeparam name="T"/> documentation for "T:JSONAPI.EntityFramework.Http.ApiController`2"]

    TC

    [Missing <typeparam name="TC"/> documentation for "T:JSONAPI.EntityFramework.Http.ApiController`2"]

    The ApiControllerT, TC type exposes the following members.

    Constructors
    +   + NameDescription
    Public methodApiControllerT, TC
    Initializes a new instance of the ApiControllerT, TC class
    Top
    Methods
    +   + NameDescription
    Protected methodBadRequest (Inherited from ApiController.)
    Protected methodBadRequest(String) (Inherited from ApiController.)
    Protected methodBadRequest(ModelStateDictionary) (Inherited from ApiController.)
    Protected methodConflict (Inherited from ApiController.)
    Protected methodContent``1(HttpStatusCode, UMP) (Inherited from ApiController.)
    Protected methodContent``1(HttpStatusCode, UMP, MediaTypeFormatter) (Inherited from ApiController.)
    Protected methodContent``1(HttpStatusCode, UMP, MediaTypeFormatter, String) (Inherited from ApiController.)
    Protected methodContent``1(HttpStatusCode, UMP, MediaTypeFormatter, MediaTypeHeaderValue) (Inherited from ApiController.)
    Protected methodCreated``1(String, UMP) (Inherited from ApiController.)
    Protected methodCreated``1(Uri, UMP) (Inherited from ApiController.)
    Protected methodCreatedAtRoute``1(String, Object, UMP) (Inherited from ApiController.)
    Protected methodCreatedAtRoute``1(String, IDictionaryString, Object, UMP) (Inherited from ApiController.)
    Public methodDelete (Overrides ApiControllerTDelete(String).)
    Public methodDispose (Inherited from ApiController.)
    Protected methodDispose(Boolean)
    Releases the unmanaged resources used by the ApiControllerT, TC and optionally releases the managed resources
    (Overrides ApiController.Dispose(Boolean).)
    Public methodEquals
    Determines whether the specified Object is equal to the current Object.
    (Inherited from Object.)
    Public methodExecuteAsync (Inherited from ApiController.)
    Protected methodFinalize
    Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
    (Inherited from Object.)
    Public methodGet (Inherited from ApiControllerT.)
    Public methodGet(String) (Inherited from ApiControllerT.)
    Public methodGetHashCode
    Serves as a hash function for a particular type.
    (Inherited from Object.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Protected methodInitialize (Inherited from ApiController.)
    Protected methodInternalServerError (Inherited from ApiController.)
    Protected methodInternalServerError(Exception) (Inherited from ApiController.)
    Protected methodJson``1(UMP) (Inherited from ApiController.)
    Protected methodJson``1(UMP, JsonSerializerSettings) (Inherited from ApiController.)
    Protected methodJson``1(UMP, JsonSerializerSettings, Encoding) (Inherited from ApiController.)
    Protected methodMaterializerFactory (Overrides ApiControllerTMaterializerFactory.)
    Protected methodMaterializerFactoryTM (Overrides ApiControllerTMaterializerFactory.)
    Protected methodMemberwiseClone
    Creates a shallow copy of the current Object.
    (Inherited from Object.)
    Protected methodNotFound (Inherited from ApiController.)
    Protected methodOk (Inherited from ApiController.)
    Protected methodOk``1(UMP) (Inherited from ApiController.)
    Public methodPost (Overrides ApiControllerTPost(IListT).)
    Public methodPut (Overrides ApiControllerTPut(String, IListT).)
    Protected methodQueryableFactory (Overrides ApiControllerTQueryableFactory(IMaterializer).)
    Protected methodRedirect(String) (Inherited from ApiController.)
    Protected methodRedirect(Uri) (Inherited from ApiController.)
    Protected methodRedirectToRoute(String, Object) (Inherited from ApiController.)
    Protected methodRedirectToRoute(String, IDictionaryString, Object) (Inherited from ApiController.)
    Protected methodResponseMessage (Inherited from ApiController.)
    Protected methodStatusCode (Inherited from ApiController.)
    Public methodToString
    Returns a string that represents the current object.
    (Inherited from Object.)
    Protected methodUnauthorized(AuthenticationHeaderValue) (Inherited from ApiController.)
    Protected methodUnauthorized(IEnumerableAuthenticationHeaderValue) (Inherited from ApiController.)
    Public methodValidate``1(UMP) (Inherited from ApiController.)
    Public methodValidate``1(UMP, String) (Inherited from ApiController.)
    Top
    Properties
    +   + NameDescription
    Public propertyActionContext (Inherited from ApiController.)
    Public propertyConfiguration (Inherited from ApiController.)
    Public propertyControllerContext (Inherited from ApiController.)
    Public propertyModelState (Inherited from ApiController.)
    Public propertyRequest (Inherited from ApiController.)
    Public propertyRequestContext (Inherited from ApiController.)
    Public propertyUrl (Inherited from ApiController.)
    Public propertyUser (Inherited from ApiController.)
    Top
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/8f2b95e5-015b-69a9-5c7b-34c7ab5780bb.htm b/doc/JSONAPI.EntityFramework/html/8f2b95e5-015b-69a9-5c7b-34c7ab5780bb.htm new file mode 100644 index 00000000..36a6e2b9 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/8f2b95e5-015b-69a9-5c7b-34c7ab5780bb.htm @@ -0,0 +1,5 @@ +ApiController(T, TC).Post Method
    ApiControllerT, TCPost Method

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.Post(System.Collections.Generic.IList{`0})"]

    Namespace: JSONAPI.EntityFramework.Http
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public override Task<IList<T>> Post(
    +	IList<T> postedObjs
    +)

    Parameters

    postedObjs
    Type: System.Collections.GenericIListT

    [Missing <param name="postedObjs"/> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.Post(System.Collections.Generic.IList{`0})"]

    Return Value

    Type: TaskIListT

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.Post(System.Collections.Generic.IList{`0})"]

    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/91a91929-9b6b-2772-7635-804659c1f97d.htm b/doc/JSONAPI.EntityFramework/html/91a91929-9b6b-2772-7635-804659c1f97d.htm new file mode 100644 index 00000000..6ca03656 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/91a91929-9b6b-2772-7635-804659c1f97d.htm @@ -0,0 +1,2 @@ +EntityFrameworkMaterializer.DbContext Property
    EntityFrameworkMaterializerDbContext Property

    [Missing <summary> documentation for "P:JSONAPI.EntityFramework.EntityFrameworkMaterializer.DbContext"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public DbContext DbContext { get; }

    Property Value

    Type: DbContext
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/98526291-7a55-a2c0-08e6-943d77516215.htm b/doc/JSONAPI.EntityFramework/html/98526291-7a55-a2c0-08e6-943d77516215.htm new file mode 100644 index 00000000..eaf27e8c --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/98526291-7a55-a2c0-08e6-943d77516215.htm @@ -0,0 +1,5 @@ +EntityFrameworkMaterializer Constructor
    EntityFrameworkMaterializer Constructor
    Initializes a new instance of the EntityFrameworkMaterializer class

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public EntityFrameworkMaterializer(
    +	DbContext context
    +)

    Parameters

    context
    Type: DbContext

    [Missing <param name="context"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.#ctor(System.Data.Entity.DbContext)"]

    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/98d60769-47c4-18fb-c63a-7e62f37aae6e.htm b/doc/JSONAPI.EntityFramework/html/98d60769-47c4-18fb-c63a-7e62f37aae6e.htm new file mode 100644 index 00000000..3bfe8cba --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/98d60769-47c4-18fb-c63a-7e62f37aae6e.htm @@ -0,0 +1,7 @@ +EntityFrameworkMaterializer.MaterializeUpdateAsync Method (Type, Object)
    EntityFrameworkMaterializerMaterializeUpdateAsync Method (Type, Object)

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeUpdateAsync(System.Type,System.Object)"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public Task<Object> MaterializeUpdateAsync(
    +	Type type,
    +	Object ephemeral
    +)

    Parameters

    type
    Type: SystemType

    [Missing <param name="type"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeUpdateAsync(System.Type,System.Object)"]

    ephemeral
    Type: SystemObject

    [Missing <param name="ephemeral"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeUpdateAsync(System.Type,System.Object)"]

    Return Value

    Type: TaskObject

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeUpdateAsync(System.Type,System.Object)"]

    Implements

    IMaterializerMaterializeUpdateAsync(Type, Object)
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/abfc46dc-150f-d53a-cf6a-58943a14517e.htm b/doc/JSONAPI.EntityFramework/html/abfc46dc-150f-d53a-cf6a-58943a14517e.htm new file mode 100644 index 00000000..bbf54567 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/abfc46dc-150f-d53a-cf6a-58943a14517e.htm @@ -0,0 +1,3 @@ +EntityFrameworkMaterializer Methods
    EntityFrameworkMaterializer Methods

    The EntityFrameworkMaterializer type exposes the following members.

    Methods
    +   + NameDescription
    Public methodEquals
    Determines whether the specified Object is equal to the current Object.
    (Inherited from Object.)
    Protected methodFinalize
    Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
    (Inherited from Object.)
    Public methodGetAssociationChangesT1, T2
    Public methodGetById(Type, Object)
    Public methodGetByIdT(Object)
    Public methodGetByIdAsync(Type, Object)
    Public methodGetByIdAsyncT(Object)
    Public methodGetDetachedOriginalT
    Protected methodGetEntitySetName
    Public methodGetHashCode
    Serves as a hash function for a particular type.
    (Inherited from Object.)
    Protected methodGetKeyNames
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Public methodIsModel
    Public methodMaterialize(Type, Object)
    Public methodMaterializeT(T)
    Public methodMaterializeAsync(Type, Object)
    Public methodMaterializeAsyncT(T)
    Protected methodMaterializeEntityKey
    Public methodMaterializeUpdate(Type, Object)
    Public methodMaterializeUpdateT(T)
    Public methodMaterializeUpdateAsync(Type, Object)
    Public methodMaterializeUpdateAsyncT(T)
    Protected methodMemberwiseClone
    Creates a shallow copy of the current Object.
    (Inherited from Object.)
    Public methodToString
    Returns a string that represents the current object.
    (Inherited from Object.)
    Top
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/ad6a3345-5e74-d28d-9d00-0dc267e7f967.htm b/doc/JSONAPI.EntityFramework/html/ad6a3345-5e74-d28d-9d00-0dc267e7f967.htm new file mode 100644 index 00000000..bbd1eb54 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/ad6a3345-5e74-d28d-9d00-0dc267e7f967.htm @@ -0,0 +1,3 @@ +EntityFrameworkMaterializer.GetByIdAsync Method \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/ade58a6f-ba3f-5310-da5f-039ca1abb647.htm b/doc/JSONAPI.EntityFramework/html/ade58a6f-ba3f-5310-da5f-039ca1abb647.htm new file mode 100644 index 00000000..b4bd79ed --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/ade58a6f-ba3f-5310-da5f-039ca1abb647.htm @@ -0,0 +1,5 @@ +ApiController(T, TC).QueryableFactory Method
    ApiControllerT, TCQueryableFactory Method

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.QueryableFactory(JSONAPI.Core.IMaterializer)"]

    Namespace: JSONAPI.EntityFramework.Http
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    protected override IQueryable<T> QueryableFactory(
    +	IMaterializer materializer = null
    +)

    Parameters

    materializer (Optional)
    Type: JSONAPI.CoreIMaterializer

    [Missing <param name="materializer"/> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.QueryableFactory(JSONAPI.Core.IMaterializer)"]

    Return Value

    Type: IQueryableT

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.Http.ApiController`2.QueryableFactory(JSONAPI.Core.IMaterializer)"]

    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/b2c4512b-5dac-60fb-0a52-70f8e9179b70.htm b/doc/JSONAPI.EntityFramework/html/b2c4512b-5dac-60fb-0a52-70f8e9179b70.htm new file mode 100644 index 00000000..c714b11e --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/b2c4512b-5dac-60fb-0a52-70f8e9179b70.htm @@ -0,0 +1,7 @@ +EntityFrameworkMaterializer.MaterializeAsync Method (Type, Object)
    EntityFrameworkMaterializerMaterializeAsync Method (Type, Object)

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeAsync(System.Type,System.Object)"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public virtual Task<Object> MaterializeAsync(
    +	Type type,
    +	Object ephemeral
    +)

    Parameters

    type
    Type: SystemType

    [Missing <param name="type"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeAsync(System.Type,System.Object)"]

    ephemeral
    Type: SystemObject

    [Missing <param name="ephemeral"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeAsync(System.Type,System.Object)"]

    Return Value

    Type: TaskObject

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeAsync(System.Type,System.Object)"]

    Implements

    IMaterializerMaterializeAsync(Type, Object)
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/bc692047-23da-f896-c881-4a5f7dede626.htm b/doc/JSONAPI.EntityFramework/html/bc692047-23da-f896-c881-4a5f7dede626.htm new file mode 100644 index 00000000..9b93cafb --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/bc692047-23da-f896-c881-4a5f7dede626.htm @@ -0,0 +1,3 @@ +EntityFrameworkMaterializer.GetById Method \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/bc79aaf3-58d1-3557-5470-b6a0c5c58497.htm b/doc/JSONAPI.EntityFramework/html/bc79aaf3-58d1-3557-5470-b6a0c5c58497.htm new file mode 100644 index 00000000..7b5d883b --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/bc79aaf3-58d1-3557-5470-b6a0c5c58497.htm @@ -0,0 +1,5 @@ +EntityFrameworkMaterializer.GetEntitySetName Method
    EntityFrameworkMaterializerGetEntitySetName Method

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetEntitySetName(System.Type)"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    protected string GetEntitySetName(
    +	Type type
    +)

    Parameters

    type
    Type: SystemType

    [Missing <param name="type"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetEntitySetName(System.Type)"]

    Return Value

    Type: String

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetEntitySetName(System.Type)"]

    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/bed5a4f4-9fd5-3c2f-1901-5956cb5b0373.htm b/doc/JSONAPI.EntityFramework/html/bed5a4f4-9fd5-3c2f-1901-5956cb5b0373.htm new file mode 100644 index 00000000..daea4e8a --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/bed5a4f4-9fd5-3c2f-1901-5956cb5b0373.htm @@ -0,0 +1,6 @@ +EntityFrameworkMaterializer.Materialize(T) Method (T)
    EntityFrameworkMaterializerMaterializeT Method (T)

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.Materialize``1(``0)"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public T Materialize<T>(
    +	T ephemeral
    +)
    +

    Parameters

    ephemeral
    Type: T

    [Missing <param name="ephemeral"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.Materialize``1(``0)"]

    Type Parameters

    T

    [Missing <typeparam name="T"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.Materialize``1(``0)"]

    Return Value

    Type: T

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.Materialize``1(``0)"]

    Implements

    IMaterializerMaterializeT(T)
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/c3f8cb7a-4cdc-5389-5713-9747afdc28f9.htm b/doc/JSONAPI.EntityFramework/html/c3f8cb7a-4cdc-5389-5713-9747afdc28f9.htm new file mode 100644 index 00000000..908e6295 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/c3f8cb7a-4cdc-5389-5713-9747afdc28f9.htm @@ -0,0 +1,6 @@ +EntityFrameworkMaterializer.MaterializeUpdateAsync(T) Method (T)
    EntityFrameworkMaterializerMaterializeUpdateAsyncT Method (T)

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeUpdateAsync``1(``0)"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public Task<T> MaterializeUpdateAsync<T>(
    +	T ephemeral
    +)
    +

    Parameters

    ephemeral
    Type: T

    [Missing <param name="ephemeral"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeUpdateAsync``1(``0)"]

    Type Parameters

    T

    [Missing <typeparam name="T"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeUpdateAsync``1(``0)"]

    Return Value

    Type: TaskT

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeUpdateAsync``1(``0)"]

    Implements

    IMaterializerMaterializeUpdateAsyncT(T)
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/d0181d5a-e42c-c8eb-5009-a83afa9bd2c6.htm b/doc/JSONAPI.EntityFramework/html/d0181d5a-e42c-c8eb-5009-a83afa9bd2c6.htm new file mode 100644 index 00000000..ceef4f6f --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/d0181d5a-e42c-c8eb-5009-a83afa9bd2c6.htm @@ -0,0 +1,7 @@ +EntityFrameworkMaterializer.GetById Method (Type, Object[])
    EntityFrameworkMaterializerGetById Method (Type, Object)

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetById(System.Type,System.Object[])"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public Object GetById(
    +	Type type,
    +	params Object[] keyValues
    +)

    Parameters

    type
    Type: SystemType

    [Missing <param name="type"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetById(System.Type,System.Object[])"]

    keyValues
    Type: SystemObject

    [Missing <param name="keyValues"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetById(System.Type,System.Object[])"]

    Return Value

    Type: Object

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetById(System.Type,System.Object[])"]

    Implements

    IMaterializerGetById(Type, Object)
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/d0d99559-192d-78b9-7f57-497ac23ab350.htm b/doc/JSONAPI.EntityFramework/html/d0d99559-192d-78b9-7f57-497ac23ab350.htm new file mode 100644 index 00000000..6f479679 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/d0d99559-192d-78b9-7f57-497ac23ab350.htm @@ -0,0 +1,3 @@ +ApiController(T, TC).Dispose Method \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/d2bb875b-b24d-f596-c91b-5852f732618f.htm b/doc/JSONAPI.EntityFramework/html/d2bb875b-b24d-f596-c91b-5852f732618f.htm new file mode 100644 index 00000000..a57402f0 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/d2bb875b-b24d-f596-c91b-5852f732618f.htm @@ -0,0 +1,7 @@ +EntityFrameworkMaterializer.GetByIdAsync Method (Type, Object[])
    EntityFrameworkMaterializerGetByIdAsync Method (Type, Object)

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetByIdAsync(System.Type,System.Object[])"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public virtual Task<Object> GetByIdAsync(
    +	Type type,
    +	params Object[] idValues
    +)

    Parameters

    type
    Type: SystemType

    [Missing <param name="type"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetByIdAsync(System.Type,System.Object[])"]

    idValues
    Type: SystemObject

    [Missing <param name="idValues"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetByIdAsync(System.Type,System.Object[])"]

    Return Value

    Type: TaskObject

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetByIdAsync(System.Type,System.Object[])"]

    Implements

    IMaterializerGetByIdAsync(Type, Object)
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/d2f26545-8e12-f85b-ccd7-7d84e27b8cfc.htm b/doc/JSONAPI.EntityFramework/html/d2f26545-8e12-f85b-ccd7-7d84e27b8cfc.htm new file mode 100644 index 00000000..aa02d1fa --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/d2f26545-8e12-f85b-ccd7-7d84e27b8cfc.htm @@ -0,0 +1,5 @@ +EntityFrameworkMaterializer.GetKeyNames Method
    EntityFrameworkMaterializerGetKeyNames Method

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetKeyNames(System.Type)"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    protected virtual IEnumerable<string> GetKeyNames(
    +	Type type
    +)

    Parameters

    type
    Type: SystemType

    [Missing <param name="type"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetKeyNames(System.Type)"]

    Return Value

    Type: IEnumerableString

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetKeyNames(System.Type)"]

    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/d4ad7991-3a8c-c2e0-fa99-04961986bf30.htm b/doc/JSONAPI.EntityFramework/html/d4ad7991-3a8c-c2e0-fa99-04961986bf30.htm new file mode 100644 index 00000000..545cc025 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/d4ad7991-3a8c-c2e0-fa99-04961986bf30.htm @@ -0,0 +1,7 @@ +EntityFrameworkMaterializer.MaterializeEntityKey Method
    EntityFrameworkMaterializerMaterializeEntityKey Method

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeEntityKey(System.Type,System.Object)"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    protected EntityKey MaterializeEntityKey(
    +	Type type,
    +	Object obj
    +)

    Parameters

    type
    Type: SystemType

    [Missing <param name="type"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeEntityKey(System.Type,System.Object)"]

    obj
    Type: SystemObject

    [Missing <param name="obj"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeEntityKey(System.Type,System.Object)"]

    Return Value

    Type: EntityKey

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.MaterializeEntityKey(System.Type,System.Object)"]

    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/d95520ab-5500-139d-0c81-2d7bfb312544.htm b/doc/JSONAPI.EntityFramework/html/d95520ab-5500-139d-0c81-2d7bfb312544.htm new file mode 100644 index 00000000..7f3ed8f7 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/d95520ab-5500-139d-0c81-2d7bfb312544.htm @@ -0,0 +1,8 @@ +EnumerateQueryableAsyncAttribute Class
    EnumerateQueryableAsyncAttribute Class

    [Missing <summary> documentation for "T:JSONAPI.EntityFramework.ActionFilters.EnumerateQueryableAsyncAttribute"]

    Inheritance Hierarchy
    SystemObject
      SystemAttribute
        FilterAttribute
          ActionFilterAttribute
            JSONAPI.EntityFramework.ActionFiltersEnumerateQueryableAsyncAttribute

    Namespace: JSONAPI.EntityFramework.ActionFilters
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public class EnumerateQueryableAsyncAttribute : ActionFilterAttribute

    The EnumerateQueryableAsyncAttribute type exposes the following members.

    Constructors
    +   + NameDescription
    Public methodEnumerateQueryableAsyncAttribute
    Initializes a new instance of the EnumerateQueryableAsyncAttribute class
    Top
    Methods
    +   + NameDescription
    Public methodEquals
    Returns a value that indicates whether this instance is equal to a specified object.
    (Inherited from Attribute.)
    Protected methodFinalize
    Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
    (Inherited from Object.)
    Public methodGetHashCode
    Returns the hash code for this instance.
    (Inherited from Attribute.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Public methodIsDefaultAttribute
    When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.
    (Inherited from Attribute.)
    Public methodMatch
    When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.
    (Inherited from Attribute.)
    Protected methodMemberwiseClone
    Creates a shallow copy of the current Object.
    (Inherited from Object.)
    Public methodOnActionExecuted (Inherited from ActionFilterAttribute.)
    Public methodOnActionExecutedAsync (Overrides ActionFilterAttribute.OnActionExecutedAsync(HttpActionExecutedContext, CancellationToken).)
    Public methodOnActionExecuting (Inherited from ActionFilterAttribute.)
    Public methodOnActionExecutingAsync (Inherited from ActionFilterAttribute.)
    Public methodToString
    Returns a string that represents the current object.
    (Inherited from Object.)
    Top
    Properties
    +   + NameDescription
    Public propertyAllowMultiple (Inherited from FilterAttribute.)
    Public propertyTypeId
    When implemented in a derived class, gets a unique identifier for this Attribute.
    (Inherited from Attribute.)
    Top
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/db674e66-d6db-87a6-42ed-c1b5283a41d9.htm b/doc/JSONAPI.EntityFramework/html/db674e66-d6db-87a6-42ed-c1b5283a41d9.htm new file mode 100644 index 00000000..d6831479 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/db674e66-d6db-87a6-42ed-c1b5283a41d9.htm @@ -0,0 +1,3 @@ +JSONAPI.EntityFramework.ActionFilters Namespace
    JSONAPI.EntityFramework.ActionFilters Namespace

    [Missing <summary> documentation for "N:JSONAPI.EntityFramework.ActionFilters"]

    Classes
    +   + ClassDescription
    Public classEnumerateQueryableAsyncAttribute
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/df676c29-93bb-a6c7-ae9c-89fc3d87a791.htm b/doc/JSONAPI.EntityFramework/html/df676c29-93bb-a6c7-ae9c-89fc3d87a791.htm new file mode 100644 index 00000000..4f4c2059 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/df676c29-93bb-a6c7-ae9c-89fc3d87a791.htm @@ -0,0 +1,7 @@ +EnumerateQueryableAsyncAttribute.OnActionExecutedAsync Method
    EnumerateQueryableAsyncAttributeOnActionExecutedAsync Method

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.ActionFilters.EnumerateQueryableAsyncAttribute.OnActionExecutedAsync(System.Web.Http.Filters.HttpActionExecutedContext,System.Threading.CancellationToken)"]

    Namespace: JSONAPI.EntityFramework.ActionFilters
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public override Task OnActionExecutedAsync(
    +	HttpActionExecutedContext actionExecutedContext,
    +	CancellationToken cancellationToken
    +)

    Parameters

    actionExecutedContext
    Type: HttpActionExecutedContext

    [Missing <param name="actionExecutedContext"/> documentation for "M:JSONAPI.EntityFramework.ActionFilters.EnumerateQueryableAsyncAttribute.OnActionExecutedAsync(System.Web.Http.Filters.HttpActionExecutedContext,System.Threading.CancellationToken)"]

    cancellationToken
    Type: System.ThreadingCancellationToken

    [Missing <param name="cancellationToken"/> documentation for "M:JSONAPI.EntityFramework.ActionFilters.EnumerateQueryableAsyncAttribute.OnActionExecutedAsync(System.Web.Http.Filters.HttpActionExecutedContext,System.Threading.CancellationToken)"]

    Return Value

    Type: Task

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.ActionFilters.EnumerateQueryableAsyncAttribute.OnActionExecutedAsync(System.Web.Http.Filters.HttpActionExecutedContext,System.Threading.CancellationToken)"]

    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/e07fd430-ab76-0616-db59-1db2ad643280.htm b/doc/JSONAPI.EntityFramework/html/e07fd430-ab76-0616-db59-1db2ad643280.htm new file mode 100644 index 00000000..5466a0d8 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/e07fd430-ab76-0616-db59-1db2ad643280.htm @@ -0,0 +1,9 @@ +Namespaces + \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/e18adb08-399a-103d-3070-99866de5dcff.htm b/doc/JSONAPI.EntityFramework/html/e18adb08-399a-103d-3070-99866de5dcff.htm new file mode 100644 index 00000000..fce71df0 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/e18adb08-399a-103d-3070-99866de5dcff.htm @@ -0,0 +1,9 @@ +EntityFrameworkMaterializer.GetDetachedOriginal(T) Method
    EntityFrameworkMaterializerGetDetachedOriginalT Method

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetDetachedOriginal``1(``0,System.Boolean)"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public T GetDetachedOriginal<T>(
    +	T entity,
    +	bool fixupRelationships = false
    +)
    +where T : class
    +

    Parameters

    entity
    Type: T

    [Missing <param name="entity"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetDetachedOriginal``1(``0,System.Boolean)"]

    fixupRelationships (Optional)
    Type: SystemBoolean

    [Missing <param name="fixupRelationships"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetDetachedOriginal``1(``0,System.Boolean)"]

    Type Parameters

    T

    [Missing <typeparam name="T"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetDetachedOriginal``1(``0,System.Boolean)"]

    Return Value

    Type: T

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetDetachedOriginal``1(``0,System.Boolean)"]

    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/ed000be8-1c5d-2cca-5782-7bf3efb12355.htm b/doc/JSONAPI.EntityFramework/html/ed000be8-1c5d-2cca-5782-7bf3efb12355.htm new file mode 100644 index 00000000..128722d7 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/ed000be8-1c5d-2cca-5782-7bf3efb12355.htm @@ -0,0 +1,6 @@ +PluralizationService Class
    PluralizationService Class

    [Missing <summary> documentation for "T:JSONAPI.EntityFramework.PluralizationService"]

    Inheritance Hierarchy
    SystemObject
      JSONAPI.EntityFrameworkPluralizationService

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public class PluralizationService : IPluralizationService

    The PluralizationService type exposes the following members.

    Constructors
    +   + NameDescription
    Public methodPluralizationService
    Initializes a new instance of the PluralizationService class
    Top
    Methods
    +   + NameDescription
    Public methodEquals
    Determines whether the specified Object is equal to the current Object.
    (Inherited from Object.)
    Protected methodFinalize
    Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
    (Inherited from Object.)
    Public methodGetHashCode
    Serves as a hash function for a particular type.
    (Inherited from Object.)
    Public methodGetType
    Gets the Type of the current instance.
    (Inherited from Object.)
    Protected methodMemberwiseClone
    Creates a shallow copy of the current Object.
    (Inherited from Object.)
    Public methodPluralize
    Public methodSingularize
    Public methodToString
    Returns a string that represents the current object.
    (Inherited from Object.)
    Top
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/ed7c768c-e85e-6e1b-3779-02b3892de22d.htm b/doc/JSONAPI.EntityFramework/html/ed7c768c-e85e-6e1b-3779-02b3892de22d.htm new file mode 100644 index 00000000..d056b4b3 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/ed7c768c-e85e-6e1b-3779-02b3892de22d.htm @@ -0,0 +1 @@ +ApiController(T, TC) Constructor
    ApiControllerT, TC Constructor

    Namespace: JSONAPI.EntityFramework.Http
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public ApiController()
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/edd56717-2deb-c819-27dd-1dc645330c3c.htm b/doc/JSONAPI.EntityFramework/html/edd56717-2deb-c819-27dd-1dc645330c3c.htm new file mode 100644 index 00000000..6b343cd1 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/edd56717-2deb-c819-27dd-1dc645330c3c.htm @@ -0,0 +1,3 @@ +EntityFrameworkMaterializer.MaterializeUpdateAsync Method \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/f4f4023a-231d-23f4-244c-b7dd1d662683.htm b/doc/JSONAPI.EntityFramework/html/f4f4023a-231d-23f4-244c-b7dd1d662683.htm new file mode 100644 index 00000000..275b3d09 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/f4f4023a-231d-23f4-244c-b7dd1d662683.htm @@ -0,0 +1,6 @@ +EntityFrameworkMaterializer.GetById(T) Method (Object[])
    EntityFrameworkMaterializerGetByIdT Method (Object)

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetById``1(System.Object[])"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public T GetById<T>(
    +	params Object[] keyValues
    +)
    +

    Parameters

    keyValues
    Type: SystemObject

    [Missing <param name="keyValues"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetById``1(System.Object[])"]

    Type Parameters

    T

    [Missing <typeparam name="T"/> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetById``1(System.Object[])"]

    Return Value

    Type: T

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.EntityFrameworkMaterializer.GetById``1(System.Object[])"]

    Implements

    IMaterializerGetByIdT(Object)
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/fd1d8e27-c123-5604-cbc4-e02e76638ffa.htm b/doc/JSONAPI.EntityFramework/html/fd1d8e27-c123-5604-cbc4-e02e76638ffa.htm new file mode 100644 index 00000000..3f47d500 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/fd1d8e27-c123-5604-cbc4-e02e76638ffa.htm @@ -0,0 +1,5 @@ +PluralizationService.Pluralize Method
    PluralizationServicePluralize Method

    [Missing <summary> documentation for "M:JSONAPI.EntityFramework.PluralizationService.Pluralize(System.String)"]

    Namespace: JSONAPI.EntityFramework
    Assembly: JSONAPI.EntityFramework (in JSONAPI.EntityFramework.dll) Version: 0.2.1.0 (0.2.1.0)
    Syntax
    public string Pluralize(
    +	string s
    +)

    Parameters

    s
    Type: SystemString

    [Missing <param name="s"/> documentation for "M:JSONAPI.EntityFramework.PluralizationService.Pluralize(System.String)"]

    Return Value

    Type: String

    [Missing <returns> documentation for "M:JSONAPI.EntityFramework.PluralizationService.Pluralize(System.String)"]

    Implements

    IPluralizationServicePluralize(String)
    See Also
    \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/html/fff25c2a-79a5-4ef1-4b74-1e52466db7ea.htm b/doc/JSONAPI.EntityFramework/html/fff25c2a-79a5-4ef1-4b74-1e52466db7ea.htm new file mode 100644 index 00000000..ae33cf51 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/html/fff25c2a-79a5-4ef1-4b74-1e52466db7ea.htm @@ -0,0 +1,3 @@ +EntityFrameworkMaterializer.MaterializeUpdate Method \ No newline at end of file diff --git a/doc/JSONAPI.EntityFramework/icons/AlertCaution.png b/doc/JSONAPI.EntityFramework/icons/AlertCaution.png new file mode 100644 index 00000000..78f246f0 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/AlertCaution.png differ diff --git a/doc/JSONAPI.EntityFramework/icons/AlertNote.png b/doc/JSONAPI.EntityFramework/icons/AlertNote.png new file mode 100644 index 00000000..0ab92b66 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/AlertNote.png differ diff --git a/doc/JSONAPI.EntityFramework/icons/AlertSecurity.png b/doc/JSONAPI.EntityFramework/icons/AlertSecurity.png new file mode 100644 index 00000000..d40fcefc Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/AlertSecurity.png differ diff --git a/doc/JSONAPI.EntityFramework/icons/CFW.gif b/doc/JSONAPI.EntityFramework/icons/CFW.gif new file mode 100644 index 00000000..cbcabf1b Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/CFW.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/CodeExample.png b/doc/JSONAPI.EntityFramework/icons/CodeExample.png new file mode 100644 index 00000000..a3b9fba4 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/CodeExample.png differ diff --git a/doc/JSONAPI.EntityFramework/icons/Search.png b/doc/JSONAPI.EntityFramework/icons/Search.png new file mode 100644 index 00000000..42165b6d Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/Search.png differ diff --git a/doc/JSONAPI.EntityFramework/icons/SectionCollapsed.png b/doc/JSONAPI.EntityFramework/icons/SectionCollapsed.png new file mode 100644 index 00000000..8ded1ebc Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/SectionCollapsed.png differ diff --git a/doc/JSONAPI.EntityFramework/icons/SectionExpanded.png b/doc/JSONAPI.EntityFramework/icons/SectionExpanded.png new file mode 100644 index 00000000..b693921c Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/SectionExpanded.png differ diff --git a/doc/JSONAPI.EntityFramework/icons/TocClose.gif b/doc/JSONAPI.EntityFramework/icons/TocClose.gif new file mode 100644 index 00000000..e6d7b5ed Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/TocClose.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/TocCollapsed.gif b/doc/JSONAPI.EntityFramework/icons/TocCollapsed.gif new file mode 100644 index 00000000..108d4923 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/TocCollapsed.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/TocExpanded.gif b/doc/JSONAPI.EntityFramework/icons/TocExpanded.gif new file mode 100644 index 00000000..f774d9bb Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/TocExpanded.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/TocOpen.gif b/doc/JSONAPI.EntityFramework/icons/TocOpen.gif new file mode 100644 index 00000000..4992a98a Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/TocOpen.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/favicon.ico b/doc/JSONAPI.EntityFramework/icons/favicon.ico new file mode 100644 index 00000000..2b9963f8 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/favicon.ico differ diff --git a/doc/JSONAPI.EntityFramework/icons/privclass.gif b/doc/JSONAPI.EntityFramework/icons/privclass.gif new file mode 100644 index 00000000..0939694c Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/privclass.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/privdelegate.gif b/doc/JSONAPI.EntityFramework/icons/privdelegate.gif new file mode 100644 index 00000000..d3aa8a65 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/privdelegate.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/privenumeration.gif b/doc/JSONAPI.EntityFramework/icons/privenumeration.gif new file mode 100644 index 00000000..47f387ec Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/privenumeration.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/privevent.gif b/doc/JSONAPI.EntityFramework/icons/privevent.gif new file mode 100644 index 00000000..30db46df Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/privevent.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/privextension.gif b/doc/JSONAPI.EntityFramework/icons/privextension.gif new file mode 100644 index 00000000..51dd267f Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/privextension.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/privfield.gif b/doc/JSONAPI.EntityFramework/icons/privfield.gif new file mode 100644 index 00000000..cbf70f7a Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/privfield.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/privinterface.gif b/doc/JSONAPI.EntityFramework/icons/privinterface.gif new file mode 100644 index 00000000..f3b7950a Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/privinterface.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/privmethod.gif b/doc/JSONAPI.EntityFramework/icons/privmethod.gif new file mode 100644 index 00000000..71f88226 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/privmethod.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/privproperty.gif b/doc/JSONAPI.EntityFramework/icons/privproperty.gif new file mode 100644 index 00000000..b1e80746 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/privproperty.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/privstructure.gif b/doc/JSONAPI.EntityFramework/icons/privstructure.gif new file mode 100644 index 00000000..ed6d1ef6 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/privstructure.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/protclass.gif b/doc/JSONAPI.EntityFramework/icons/protclass.gif new file mode 100644 index 00000000..0f929429 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/protclass.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/protdelegate.gif b/doc/JSONAPI.EntityFramework/icons/protdelegate.gif new file mode 100644 index 00000000..b209f2d8 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/protdelegate.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/protenumeration.gif b/doc/JSONAPI.EntityFramework/icons/protenumeration.gif new file mode 100644 index 00000000..cc96bb63 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/protenumeration.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/protevent.gif b/doc/JSONAPI.EntityFramework/icons/protevent.gif new file mode 100644 index 00000000..0e510b27 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/protevent.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/protextension.gif b/doc/JSONAPI.EntityFramework/icons/protextension.gif new file mode 100644 index 00000000..dcd07f5e Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/protextension.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/protfield.gif b/doc/JSONAPI.EntityFramework/icons/protfield.gif new file mode 100644 index 00000000..9ae6833e Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/protfield.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/protinterface.gif b/doc/JSONAPI.EntityFramework/icons/protinterface.gif new file mode 100644 index 00000000..a1b96d2c Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/protinterface.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/protmethod.gif b/doc/JSONAPI.EntityFramework/icons/protmethod.gif new file mode 100644 index 00000000..2bc94687 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/protmethod.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/protoperator.gif b/doc/JSONAPI.EntityFramework/icons/protoperator.gif new file mode 100644 index 00000000..2cb75ab8 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/protoperator.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/protproperty.gif b/doc/JSONAPI.EntityFramework/icons/protproperty.gif new file mode 100644 index 00000000..55473d16 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/protproperty.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/protstructure.gif b/doc/JSONAPI.EntityFramework/icons/protstructure.gif new file mode 100644 index 00000000..af356a1d Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/protstructure.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/pubclass.gif b/doc/JSONAPI.EntityFramework/icons/pubclass.gif new file mode 100644 index 00000000..1a968ab6 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/pubclass.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/pubdelegate.gif b/doc/JSONAPI.EntityFramework/icons/pubdelegate.gif new file mode 100644 index 00000000..0a43eb26 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/pubdelegate.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/pubenumeration.gif b/doc/JSONAPI.EntityFramework/icons/pubenumeration.gif new file mode 100644 index 00000000..46888ade Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/pubenumeration.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/pubevent.gif b/doc/JSONAPI.EntityFramework/icons/pubevent.gif new file mode 100644 index 00000000..b9226da8 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/pubevent.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/pubextension.gif b/doc/JSONAPI.EntityFramework/icons/pubextension.gif new file mode 100644 index 00000000..6262d1cc Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/pubextension.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/pubfield.gif b/doc/JSONAPI.EntityFramework/icons/pubfield.gif new file mode 100644 index 00000000..5aed1757 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/pubfield.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/pubinterface.gif b/doc/JSONAPI.EntityFramework/icons/pubinterface.gif new file mode 100644 index 00000000..c38a4c46 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/pubinterface.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/pubmethod.gif b/doc/JSONAPI.EntityFramework/icons/pubmethod.gif new file mode 100644 index 00000000..2c72988f Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/pubmethod.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/puboperator.gif b/doc/JSONAPI.EntityFramework/icons/puboperator.gif new file mode 100644 index 00000000..0ebe10a7 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/puboperator.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/pubproperty.gif b/doc/JSONAPI.EntityFramework/icons/pubproperty.gif new file mode 100644 index 00000000..dfad7b43 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/pubproperty.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/pubstructure.gif b/doc/JSONAPI.EntityFramework/icons/pubstructure.gif new file mode 100644 index 00000000..1344416a Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/pubstructure.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/slMobile.gif b/doc/JSONAPI.EntityFramework/icons/slMobile.gif new file mode 100644 index 00000000..5edc31f9 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/slMobile.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/static.gif b/doc/JSONAPI.EntityFramework/icons/static.gif new file mode 100644 index 00000000..33723a92 Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/static.gif differ diff --git a/doc/JSONAPI.EntityFramework/icons/xna.gif b/doc/JSONAPI.EntityFramework/icons/xna.gif new file mode 100644 index 00000000..9e6a9d4b Binary files /dev/null and b/doc/JSONAPI.EntityFramework/icons/xna.gif differ diff --git a/doc/JSONAPI.EntityFramework/index.html b/doc/JSONAPI.EntityFramework/index.html new file mode 100644 index 00000000..a0dd9109 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/index.html @@ -0,0 +1,14 @@ + + + + + + + JSONAPI.EntityFramework - Redirect + + +

    If you are not redirected automatically, follow this link to the default topic.

    + + diff --git a/doc/JSONAPI.EntityFramework/scripts/branding-Website.js b/doc/JSONAPI.EntityFramework/scripts/branding-Website.js new file mode 100644 index 00000000..00a10dc5 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/scripts/branding-Website.js @@ -0,0 +1,620 @@ +//=============================================================================================================== +// System : Sandcastle Help File Builder +// File : branding-Website.js +// Author : Eric Woodruff (Eric@EWoodruff.us) +// Updated : 01/07/2015 +// Note : Copyright 2014-2015, Eric Woodruff, All rights reserved +// Portions Copyright 2014 Sam Harwell, All rights reserved +// +// This file contains the methods necessary to implement the lightweight TOC and search functionality. +// +// This code is published under the Microsoft Public License (Ms-PL). A copy of the license should be +// distributed with the code. It can also be found at the project website: https://GitHub.com/EWSoftware/SHFB. This +// notice, the author's name, and all copyright notices must remain intact in all applications, documentation, +// and source files. +// +// Date Who Comments +// ============================================================================================================== +// 05/04/2014 EFW Created the code based on a combination of the lightweight TOC code from Sam Harwell and +// the existing search code from SHFB. +//=============================================================================================================== + +// Width of the TOC +var tocWidth; + +// Search method (0 = To be determined, 1 = ASPX, 2 = PHP, anything else = client-side script +var searchMethod = 0; + +// Table of contents script + +// Initialize the TOC by restoring its width from the cookie if present +function InitializeToc() +{ + tocWidth = parseInt(GetCookie("TocWidth", "280")); + ResizeToc(); + $(window).resize(SetNavHeight) +} + +function SetNavHeight() +{ + $leftNav = $("#leftNav") + $topicContent = $("#TopicContent") + leftNavPadding = $leftNav.outerHeight() - $leftNav.height() + contentPadding = $topicContent.outerHeight() - $topicContent.height() + // want outer height of left navigation div to match outer height of content + leftNavHeight = $topicContent.outerHeight() - leftNavPadding + $leftNav.css("min-height", leftNavHeight + "px") +} + +// Increase the TOC width +function OnIncreaseToc() +{ + if(tocWidth < 1) + tocWidth = 280; + else + tocWidth += 100; + + if(tocWidth > 680) + tocWidth = 0; + + ResizeToc(); + SetCookie("TocWidth", tocWidth); +} + +// Reset the TOC to its default width +function OnResetToc() +{ + tocWidth = 0; + + ResizeToc(); + SetCookie("TocWidth", tocWidth); +} + +// Resize the TOC width +function ResizeToc() +{ + var toc = document.getElementById("leftNav"); + + if(toc) + { + // Set TOC width + toc.style.width = tocWidth + "px"; + + var leftNavPadding = 10; + + document.getElementById("TopicContent").style.marginLeft = (tocWidth + leftNavPadding) + "px"; + + // Position images + document.getElementById("TocResize").style.left = (tocWidth + leftNavPadding) + "px"; + + // Hide/show increase TOC width image + document.getElementById("ResizeImageIncrease").style.display = (tocWidth >= 680) ? "none" : ""; + + // Hide/show reset TOC width image + document.getElementById("ResizeImageReset").style.display = (tocWidth < 680) ? "none" : ""; + } + + SetNavHeight() +} + +// Toggle a TOC entry between its collapsed and expanded state +function Toggle(item) +{ + var isExpanded = $(item).hasClass("tocExpanded"); + + $(item).toggleClass("tocExpanded tocCollapsed"); + + if(isExpanded) + { + Collapse($(item).parent()); + } + else + { + var childrenLoaded = $(item).parent().attr("data-childrenloaded"); + + if(childrenLoaded) + { + Expand($(item).parent()); + } + else + { + var tocid = $(item).next().attr("tocid"); + + $.ajax({ + url: "../toc/" + tocid + ".xml", + async: true, + dataType: "xml", + success: function(data) + { + BuildChildren($(item).parent(), data); + } + }); + } + } +} + +// HTML encode a value for use on the page +function HtmlEncode(value) +{ + // Create an in-memory div, set it's inner text (which jQuery automatically encodes) then grab the encoded + // contents back out. The div never exists on the page. + return $('
    ').text(value).html(); +} + +// Build the child entries of a TOC entry +function BuildChildren(tocDiv, data) +{ + var childLevel = +tocDiv.attr("data-toclevel") + 1; + var childTocLevel = childLevel >= 10 ? 10 : childLevel; + var elements = data.getElementsByTagName("HelpTOCNode"); + + var isRoot = true; + + if(data.getElementsByTagName("HelpTOC").length == 0) + { + // The first node is the root node of this group, don't show it again + isRoot = false; + } + + for(var i = elements.length - 1; i > 0 || (isRoot && i == 0); i--) + { + var childHRef, childId = elements[i].getAttribute("Url"); + + if(childId != null && childId.length > 5) + { + // The Url attribute has the form "html/{childId}.htm" + childHRef = childId.substring(5, childId.length); + childId = childId.substring(5, childId.lastIndexOf(".")); + } + else + { + // The Id attribute is in raw form. There is no URL (empty container node). In this case, we'll + // just ignore it and go nowhere. It's a rare case that isn't worth trying to get the first child. + // Instead, we'll just expand the node (see below). + childHRef = "#"; + childId = elements[i].getAttribute("Id"); + } + + var existingItem = null; + + tocDiv.nextAll().each(function() + { + if(!existingItem && $(this).children().last("a").attr("tocid") == childId) + { + existingItem = $(this); + } + }); + + if(existingItem != null) + { + // First move the children of the existing item + var existingChildLevel = +existingItem.attr("data-toclevel"); + var doneMoving = false; + var inserter = tocDiv; + + existingItem.nextAll().each(function() + { + if(!doneMoving && +$(this).attr("data-toclevel") > existingChildLevel) + { + inserter.after($(this)); + inserter = $(this); + $(this).attr("data-toclevel", +$(this).attr("data-toclevel") + childLevel - existingChildLevel); + + if($(this).hasClass("current")) + $(this).attr("class", "toclevel" + (+$(this).attr("data-toclevel") + " current")); + else + $(this).attr("class", "toclevel" + (+$(this).attr("data-toclevel"))); + } + else + { + doneMoving = true; + } + }); + + // Now move the existing item itself + tocDiv.after(existingItem); + existingItem.attr("data-toclevel", childLevel); + existingItem.attr("class", "toclevel" + childLevel); + } + else + { + var hasChildren = elements[i].getAttribute("HasChildren"); + var childTitle = HtmlEncode(elements[i].getAttribute("Title")); + var expander = ""; + + if(hasChildren) + expander = ""; + + var text = "
    " + + expander + "" + + childTitle + "
    "; + + tocDiv.after(text); + } + } + + tocDiv.attr("data-childrenloaded", true); +} + +// Collapse a TOC entry +function Collapse(tocDiv) +{ + // Hide all the TOC elements after item, until we reach one with a data-toclevel less than or equal to the + // current item's value. + var tocLevel = +tocDiv.attr("data-toclevel"); + var done = false; + + tocDiv.nextAll().each(function() + { + if(!done && +$(this).attr("data-toclevel") > tocLevel) + { + $(this).hide(); + } + else + { + done = true; + } + }); +} + +// Expand a TOC entry +function Expand(tocDiv) +{ + // Show all the TOC elements after item, until we reach one with a data-toclevel less than or equal to the + // current item's value + var tocLevel = +tocDiv.attr("data-toclevel"); + var done = false; + + tocDiv.nextAll().each(function() + { + if(done) + { + return; + } + + var childTocLevel = +$(this).attr("data-toclevel"); + + if(childTocLevel == tocLevel + 1) + { + $(this).show(); + + if($(this).children("a").first().hasClass("tocExpanded")) + { + Expand($(this)); + } + } + else if(childTocLevel > tocLevel + 1) + { + // Ignore this node, handled by recursive calls + } + else + { + done = true; + } + }); +} + +// This is called to prepare for dragging the sizer div +function OnMouseDown(event) +{ + document.addEventListener("mousemove", OnMouseMove, true); + document.addEventListener("mouseup", OnMouseUp, true); + event.preventDefault(); +} + +// Resize the TOC as the sizer is dragged +function OnMouseMove(event) +{ + tocWidth = (event.clientX > 700) ? 700 : (event.clientX < 100) ? 100 : event.clientX; + + ResizeToc(); +} + +// Finish the drag operation when the mouse button is released +function OnMouseUp(event) +{ + document.removeEventListener("mousemove", OnMouseMove, true); + document.removeEventListener("mouseup", OnMouseUp, true); + + SetCookie("TocWidth", tocWidth); +} + +// Search functions + +// Transfer to the search page from a topic +function TransferToSearchPage() +{ + var searchText = document.getElementById("SearchTextBox").value.trim(); + + if(searchText.length != 0) + document.location.replace(encodeURI("../search.html?SearchText=" + searchText)); +} + +// Initiate a search when the search page loads +function OnSearchPageLoad() +{ + var queryString = decodeURI(document.location.search); + + if(queryString != "") + { + var idx, options = queryString.split(/[\?\=\&]/); + + for(idx = 0; idx < options.length; idx++) + if(options[idx] == "SearchText" && idx + 1 < options.length) + { + document.getElementById("txtSearchText").value = options[idx + 1]; + PerformSearch(); + break; + } + } +} + +// Perform a search using the best available method +function PerformSearch() +{ + var searchText = document.getElementById("txtSearchText").value; + var sortByTitle = document.getElementById("chkSortByTitle").checked; + var searchResults = document.getElementById("searchResults"); + + if(searchText.length == 0) + { + searchResults.innerHTML = "Nothing found"; + return; + } + + searchResults.innerHTML = "Searching..."; + + // Determine the search method if not done already. The ASPX and PHP searches are more efficient as they + // run asynchronously server-side. If they can't be used, it defaults to the client-side script below which + // will work but has to download the index files. For large help sites, this can be inefficient. + if(searchMethod == 0) + searchMethod = DetermineSearchMethod(); + + if(searchMethod == 1) + { + $.ajax({ + type: "GET", + url: encodeURI("SearchHelp.aspx?Keywords=" + searchText + "&SortByTitle=" + sortByTitle), + success: function(html) + { + searchResults.innerHTML = html; + } + }); + + return; + } + + if(searchMethod == 2) + { + $.ajax({ + type: "GET", + url: encodeURI("SearchHelp.php?Keywords=" + searchText + "&SortByTitle=" + sortByTitle), + success: function(html) + { + searchResults.innerHTML = html; + } + }); + + return; + } + + // Parse the keywords + var keywords = ParseKeywords(searchText); + + // Get the list of files. We'll be getting multiple files so we need to do this synchronously. + var fileList = []; + + $.ajax({ + type: "GET", + url: "fti/FTI_Files.json", + dataType: "json", + async: false, + success: function(data) + { + $.each(data, function(key, val) + { + fileList[key] = val; + }); + } + }); + + var letters = []; + var wordDictionary = []; + var wordNotFound = false; + + // Load the keyword files for each keyword starting letter + for(var idx = 0; idx < keywords.length && !wordNotFound; idx++) + { + var letter = keywords[idx].substring(0, 1); + + if($.inArray(letter, letters) == -1) + { + letters.push(letter); + + $.ajax({ + type: "GET", + url: "fti/FTI_" + letter.charCodeAt(0) + ".json", + dataType: "json", + async: false, + success: function(data) + { + var wordCount = 0; + + $.each(data, function(key, val) + { + wordDictionary[key] = val; + wordCount++; + }); + + if(wordCount == 0) + wordNotFound = true; + } + }); + } + } + + if(wordNotFound) + searchResults.innerHTML = "Nothing found"; + else + searchResults.innerHTML = SearchForKeywords(keywords, fileList, wordDictionary, sortByTitle); +} + +// Determine the search method by seeing if the ASPX or PHP search pages are present and working +function DetermineSearchMethod() +{ + var method = 3; + + try + { + $.ajax({ + type: "GET", + url: "SearchHelp.aspx", + async: false, + success: function(html) + { + if(html.substring(0, 8) == "") + method = 1; + } + }); + + if(method == 3) + $.ajax({ + type: "GET", + url: "SearchHelp.php", + async: false, + success: function(html) + { + if(html.substring(0, 8) == "") + method = 2; + } + }); + } + catch(e) + { + } + + return method; +} + +// Split the search text up into keywords +function ParseKeywords(keywords) +{ + var keywordList = []; + var checkWord; + var words = keywords.split(/\W+/); + + for(var idx = 0; idx < words.length; idx++) + { + checkWord = words[idx].toLowerCase(); + + if(checkWord.length > 2) + { + var charCode = checkWord.charCodeAt(0); + + if((charCode < 48 || charCode > 57) && $.inArray(checkWord, keywordList) == -1) + keywordList.push(checkWord); + } + } + + return keywordList; +} + +// Search for keywords and generate a block of HTML containing the results +function SearchForKeywords(keywords, fileInfo, wordDictionary, sortByTitle) +{ + var matches = [], matchingFileIndices = [], rankings = []; + var isFirst = true; + + for(var idx = 0; idx < keywords.length; idx++) + { + var word = keywords[idx]; + var occurrences = wordDictionary[word]; + + // All keywords must be found + if(occurrences == null) + return "Nothing found"; + + matches[word] = occurrences; + var occurrenceIndices = []; + + // Get a list of the file indices for this match + for(var ind in occurrences) + occurrenceIndices.push(occurrences[ind] >> 16); + + if(isFirst) + { + isFirst = false; + + for(var matchInd in occurrenceIndices) + matchingFileIndices.push(occurrenceIndices[matchInd]); + } + else + { + // After the first match, remove files that do not appear for all found keywords + for(var checkIdx = 0; checkIdx < matchingFileIndices.length; checkIdx++) + if($.inArray(matchingFileIndices[checkIdx], occurrenceIndices) == -1) + { + matchingFileIndices.splice(checkIdx, 1); + checkIdx--; + } + } + } + + if(matchingFileIndices.length == 0) + return "Nothing found"; + + // Rank the files based on the number of times the words occurs + for(var fileIdx = 0; fileIdx < matchingFileIndices.length; fileIdx++) + { + // Split out the title, filename, and word count + var matchingIdx = matchingFileIndices[fileIdx]; + var fileIndex = fileInfo[matchingIdx].split(/\0/); + + var title = fileIndex[0]; + var filename = fileIndex[1]; + var wordCount = parseInt(fileIndex[2]); + var matchCount = 0; + + for(var idx = 0; idx < keywords.length; idx++) + { + occurrences = matches[keywords[idx]]; + + for(var ind in occurrences) + { + var entry = occurrences[ind]; + + if((entry >> 16) == matchingIdx) + matchCount += (entry & 0xFFFF); + } + } + + rankings.push({ Filename: filename, PageTitle: title, Rank: matchCount * 1000 / wordCount }); + + if(rankings.length > 99) + break; + } + + rankings.sort(function(x, y) + { + if(!sortByTitle) + return y.Rank - x.Rank; + + return x.PageTitle.localeCompare(y.PageTitle); + }); + + // Format and return the results + var content = "
      "; + + for(var r in rankings) + content += "
    1. " + + rankings[r].PageTitle + "
    2. "; + + content += "
    "; + + if(rankings.length < matchingFileIndices.length) + content += "

    Omitted " + (matchingFileIndices.length - rankings.length) + " more results

    "; + + return content; +} diff --git a/doc/JSONAPI.EntityFramework/scripts/branding.js b/doc/JSONAPI.EntityFramework/scripts/branding.js new file mode 100644 index 00000000..9be90f3d --- /dev/null +++ b/doc/JSONAPI.EntityFramework/scripts/branding.js @@ -0,0 +1,528 @@ +//=============================================================================================================== +// System : Sandcastle Help File Builder +// File : branding.js +// Author : Eric Woodruff (Eric@EWoodruff.us) +// Updated : 05/15/2014 +// Note : Copyright 2014, Eric Woodruff, All rights reserved +// Portions Copyright 2010-2014 Microsoft, All rights reserved +// +// This file contains the methods necessary to implement the language filtering, collapsible section, and +// copy to clipboard options. +// +// This code is published under the Microsoft Public License (Ms-PL). A copy of the license should be +// distributed with the code. It can also be found at the project website: https://GitHub.com/EWSoftware/SHFB. This +// notice, the author's name, and all copyright notices must remain intact in all applications, documentation, +// and source files. +// +// Date Who Comments +// ============================================================================================================== +// 05/04/2014 EFW Created the code based on the MS Help Viewer script +//=============================================================================================================== + +// The IDs of all code snippet sets on the same page are stored so that we can keep them in synch when a tab is +// selected. +var allTabSetIds = new Array(); + +// The IDs of language-specific text (LST) spans are used as dictionary keys so that we can get access to the +// spans and update them when the user changes to a different language tab. The values of the dictionary +// objects are pipe separated language-specific attributes (lang1=value|lang2=value|lang3=value). The language +// ID can be specific (cs, vb, cpp, etc.) or may be a neutral entry (nu) which specifies text common to multiple +// languages. If a language is not present and there is no neutral entry, the span is hidden for all languages +// to which it does not apply. +var allLSTSetIds = new Object(); + +// Help 1 persistence support. This code must appear inline. +var isHelp1; + +var curLoc = document.location + "."; + +if(curLoc.indexOf("mk:@MSITStore") == 0) +{ + isHelp1 = true; + curLoc = "ms-its:" + curLoc.substring(14, curLoc.length - 1); + document.location.replace(curLoc); +} +else + if(curLoc.indexOf("ms-its:") == 0) + isHelp1 = true; + else + isHelp1 = false; + +// The OnLoad method +function OnLoad(defaultLanguage) +{ + var defLang; + + if(typeof (defaultLanguage) == "undefined" || defaultLanguage == null || defaultLanguage == "") + defLang = "vb"; + else + defLang = defaultLanguage; + + // In MS Help Viewer, the transform the topic is ran through can move the footer. Move it back where it + // belongs if necessary. + try + { + var footer = document.getElementById("pageFooter") + + if(footer) + { + var footerParent = document.body; + + if(footer.parentElement != footerParent) + { + footer.parentElement.removeChild(footer); + footerParent.appendChild(footer); + } + } + } + catch(e) + { + } + + var language = GetCookie("CodeSnippetContainerLanguage", defLang); + + // If LST exists on the page, set the LST to show the user selected programming language + UpdateLST(language); + + // If code snippet groups exist, set the current language for them + if(allTabSetIds.length > 0) + { + var i = 0; + + while(i < allTabSetIds.length) + { + var tabCount = 1; + + // The tab count may vary so find the last one in this set + while(document.getElementById(allTabSetIds[i] + "_tab" + tabCount) != null) + tabCount++; + + tabCount--; + + // If not grouped, skip it + if(tabCount < 2) + { + // Disable the Copy Code link if in Chrome + if(navigator.userAgent.toLowerCase().indexOf("chrome") != -1) + document.getElementById(allTabSetIds[i] + "_copyCode").style.display = "none"; + } + else + SetCurrentLanguage(allTabSetIds[i], language, tabCount); + + i++; + } + } + + InitializeToc(); +} + +// This is just a place holder. The website script implements this function to initialize it's in-page TOC pane +function InitializeToc() +{ +} + +// This function executes in the OnLoad event and ChangeTab action on code snippets. The function parameter +// is the user chosen programming language. This function iterates through the "allLSTSetIds" dictionary object +// to update the node value of the LST span tag per the user's chosen programming language. +function UpdateLST(language) +{ + for(var lstMember in allLSTSetIds) + { + var devLangSpan = document.getElementById(lstMember); + + if(devLangSpan != null) + { + // There may be a carriage return before the LST span in the content so the replace function below + // is used to trim the whitespace at the end of the previous node of the current LST node. + if(devLangSpan.previousSibling != null && devLangSpan.previousSibling.nodeValue != null) + devLangSpan.previousSibling.nodeValue = devLangSpan.previousSibling.nodeValue.replace(/\s+$/, ""); + + var langs = allLSTSetIds[lstMember].split("|"); + var k = 0; + var keyValue; + + while(k < langs.length) + { + keyValue = langs[k].split("="); + + if(keyValue[0] == language) + { + devLangSpan.innerHTML = keyValue[1]; + + // Help 1 and MS Help Viewer workaround. Add a space if the following text element starts + // with a space to prevent things running together. + if(devLangSpan.parentNode != null && devLangSpan.parentNode.nextSibling != null) + { + if (devLangSpan.parentNode.nextSibling.nodeValue != null && + !devLangSpan.parentNode.nextSibling.nodeValue.substring(0, 1).match(/[.,);:!/?]/)) + { + devLangSpan.innerHTML = keyValue[1] + " "; + } + } + break; + } + + k++; + } + + // If not found, default to the neutral language. If there is no neutral language entry, clear the + // content to hide it. + if(k >= langs.length) + { + if(language != "nu") + { + k = 0; + + while(k < langs.length) + { + keyValue = langs[k].split("="); + + if(keyValue[0] == "nu") + { + devLangSpan.innerHTML = keyValue[1]; + + // Help 1 and MS Help Viewer workaround. Add a space if the following text element + // starts with a space to prevent things running together. + if(devLangSpan.parentNode != null && devLangSpan.parentNode.nextSibling != null) + { + if(devLangSpan.parentNode.nextSibling.nodeValue != null && + !devLangSpan.parentNode.nextSibling.nodeValue.substring(0, 1).match(/[.,);:!/?]/)) + { + devLangSpan.innerHTML = keyValue[1] + " "; + } + } + break; + } + + k++; + } + } + + if(k >= langs.length) + devLangSpan.innerHTML = ""; + } + } + } +} + +// Get the specified cookie. If not found, return the specified default value. +function GetCookie(cookieName, defaultValue) +{ + if(isHelp1) + { + try + { + var globals = Help1Globals; + + var value = globals.Load(cookieName); + + if(value == null) + value = defaultValue; + + return value; + } + catch(e) + { + return defaultValue; + } + } + + var cookie = document.cookie.split("; "); + + for(var i = 0; i < cookie.length; i++) + { + var crumb = cookie[i].split("="); + + if(cookieName == crumb[0]) + return unescape(crumb[1]) + } + + return defaultValue; +} + +// Set the specified cookie to the specified value +function SetCookie(name, value) +{ + if(isHelp1) + { + try + { + var globals = Help1Globals; + + globals.Save(name, value); + } + catch(e) + { + } + + return; + } + + var today = new Date(); + + today.setTime(today.getTime()); + + // Set the expiration time to be 60 days from now (in milliseconds) + var expires_date = new Date(today.getTime() + (60 * 1000 * 60 * 60 * 24)); + + document.cookie = name + "=" + escape(value) + ";expires=" + expires_date.toGMTString() + ";path=/"; +} + +// Add a language-specific text ID +function AddLanguageSpecificTextSet(lstId) +{ + var keyValue = lstId.split("?") + + allLSTSetIds[keyValue[0]] = keyValue[1]; +} + +// Add a language tab set ID +function AddLanguageTabSet(tabSetId) +{ + allTabSetIds.push(tabSetId); +} + +// Switch the active tab for all of other code snippets +function ChangeTab(tabSetId, language, snippetIdx, snippetCount) +{ + SetCookie("CodeSnippetContainerLanguage", language); + + SetActiveTab(tabSetId, snippetIdx, snippetCount); + + // If LST exists on the page, set the LST to show the user selected programming language + UpdateLST(language); + + var i = 0; + + while(i < allTabSetIds.length) + { + // We just care about other snippets + if(allTabSetIds[i] != tabSetId) + { + // Other tab sets may not have the same number of tabs + var tabCount = 1; + + while(document.getElementById(allTabSetIds[i] + "_tab" + tabCount) != null) + tabCount++; + + tabCount--; + + // If not grouped, skip it + if(tabCount > 1) + SetCurrentLanguage(allTabSetIds[i], language, tabCount); + } + + i++; + } +} + +// Sets the current language in the specified tab set +function SetCurrentLanguage(tabSetId, language, tabCount) +{ + var tabIndex = 1; + + while(tabIndex <= tabCount) + { + var tabTemp = document.getElementById(tabSetId + "_tab" + tabIndex); + + if(tabTemp != null && tabTemp.innerHTML.indexOf("'" + language + "'") != -1) + break; + + tabIndex++; + } + + if(tabIndex > tabCount) + { + // Select the first non-disabled tab + tabIndex = 1; + + if(document.getElementById(tabSetId + "_tab1").className == "codeSnippetContainerTabPhantom") + { + tabIndex++; + + while(tabIndex <= tabCount) + { + var tab = document.getElementById(tabSetId + "_tab" + tabIndex); + + if(tab.className != "codeSnippetContainerTabPhantom") + { + tab.className = "codeSnippetContainerTabActive"; + document.getElementById(tabSetId + "_code_Div" + j).style.display = "block"; + break; + } + + tabIndex++; + } + } + } + + SetActiveTab(tabSetId, tabIndex, tabCount); +} + +// Set the active tab within a tab set +function SetActiveTab(tabSetId, tabIndex, tabCount) +{ + var i = 1; + + while(i <= tabCount) + { + var tabTemp = document.getElementById(tabSetId + "_tab" + i); + + if(tabTemp.className == "codeSnippetContainerTabActive") + tabTemp.className = "codeSnippetContainerTab"; + else + if(tabTemp.className == "codeSnippetContainerTabPhantom") + tabTemp.style.display = "none"; + + var codeTemp = document.getElementById(tabSetId + "_code_Div" + i); + + if(codeTemp.style.display != "none") + codeTemp.style.display = "none"; + + i++; + } + + // Phantom tabs are shown or hidden as needed + if(document.getElementById(tabSetId + "_tab" + tabIndex).className != "codeSnippetContainerTabPhantom") + document.getElementById(tabSetId + "_tab" + tabIndex).className = "codeSnippetContainerTabActive"; + else + document.getElementById(tabSetId + "_tab" + tabIndex).style.display = "block"; + + document.getElementById(tabSetId + "_code_Div" + tabIndex).style.display = "block"; + + // Show copy code button if not in Chrome + if(navigator.userAgent.toLowerCase().indexOf("chrome") == -1) + document.getElementById(tabSetId + "_copyCode").style.display = "inline"; + else + document.getElementById(tabSetId + "_copyCode").style.display = "none"; +} + +// Copy the code from the active tab of the given tab set to the clipboard +function CopyToClipboard(tabSetId) +{ + var tabTemp, contentId; + var i = 1; + + do + { + contentId = tabSetId + "_code_Div" + i; + tabTemp = document.getElementById(contentId); + + if(tabTemp != null && tabTemp.style.display != "none") + break; + + i++; + + } while(tabTemp != null); + + if(tabTemp == null) + return; + + if(window.clipboardData) + { + try + { + window.clipboardData.setData("Text", document.getElementById(contentId).innerText); + } + catch(e) + { + alert("Permission denied. Enable copying to the clipboard."); + } + } + else if(window.netscape) + { + try + { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + + var clip = Components.classes["@mozilla.org/widget/clipboard;1"].createInstance( + Components.interfaces.nsIClipboard); + + if(!clip) + return; + + var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance( + Components.interfaces.nsITransferable); + + if(!trans) + return; + + trans.addDataFlavor("text/unicode"); + + var str = new Object(); + var len = new Object(); + var str = Components.classes["@mozilla.org/supports-string;1"].createInstance( + Components.interfaces.nsISupportsString); + + var copytext = document.getElementById(contentId).textContent; + + str.data = copytext; + trans.setTransferData("text/unicode", str, copytext.length * 2); + + var clipid = Components.interfaces.nsIClipboard; + + clip.setData(trans, null, clipid.kGlobalClipboard); + } + catch(e) + { + alert("Permission denied. Enter \"about:config\" in the address bar and double-click the \"signed.applets.codebase_principal_support\" setting to enable copying to the clipboard."); + } + } +} + +// Expand or collapse a section +function SectionExpandCollapse(togglePrefix) +{ + var image = document.getElementById(togglePrefix + "Toggle"); + var section = document.getElementById(togglePrefix + "Section"); + + if(image != null && section != null) + if(section.style.display == "") + { + image.src = image.src.replace("SectionExpanded.png", "SectionCollapsed.png"); + section.style.display = "none"; + } + else + { + image.src = image.src.replace("SectionCollapsed.png", "SectionExpanded.png"); + section.style.display = ""; + } +} + +// Expand or collapse a section when it has the focus and Enter is hit +function SectionExpandCollapse_CheckKey(togglePrefix, eventArgs) +{ + if(eventArgs.keyCode == 13) + SectionExpandCollapse(togglePrefix); +} + +// Help 1 persistence object. This requires a hidden input element on the page with a class of "userDataStyle" +// defined in the style sheet that implements the user data binary behavior: +// +var Help1Globals = +{ + UserDataCache: function() + { + var userData = document.getElementById("userDataCache"); + + return userData; + }, + + Load: function(key) + { + var userData = this.UserDataCache(); + + userData.load("userDataSettings"); + + var value = userData.getAttribute(key); + + return value; + }, + + Save: function(key, value) + { + var userData = this.UserDataCache(); + userData.setAttribute(key, value); + userData.save("userDataSettings"); + } +}; diff --git a/doc/JSONAPI.EntityFramework/scripts/jquery-1.11.0.min.js b/doc/JSONAPI.EntityFramework/scripts/jquery-1.11.0.min.js new file mode 100644 index 00000000..73f33fb3 --- /dev/null +++ b/doc/JSONAPI.EntityFramework/scripts/jquery-1.11.0.min.js @@ -0,0 +1,4 @@ +/*! jQuery v1.11.0 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ +!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k="".trim,l={},m="1.11.0",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(n.isPlainObject(c)||(b=n.isArray(c)))?(b?(b=!1,f=a&&n.isArray(a)?a:[]):f=a&&n.isPlainObject(a)?a:{},g[d]=n.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray||function(a){return"array"===n.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==n.type(a)||a.nodeType||n.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(l.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&n.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:k&&!k.call("\ufeff\xa0")?function(a){return null==a?"":k.call(a)}:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),n.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||n.guid++,e):void 0},now:function(){return+new Date},support:l}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s="sizzle"+-new Date,t=a.document,u=0,v=0,w=eb(),x=eb(),y=eb(),z=function(a,b){return a===b&&(j=!0),0},A="undefined",B=1<<31,C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=D.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",M=L.replace("w","w#"),N="\\["+K+"*("+L+")"+K+"*(?:([*^$|!~]?=)"+K+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+M+")|)|)"+K+"*\\]",O=":("+L+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+N.replace(3,8)+")*)|.*)\\)|)",P=new RegExp("^"+K+"+|((?:^|[^\\\\])(?:\\\\.)*)"+K+"+$","g"),Q=new RegExp("^"+K+"*,"+K+"*"),R=new RegExp("^"+K+"*([>+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(O),U=new RegExp("^"+M+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L.replace("w","w*")+")"),ATTR:new RegExp("^"+N),PSEUDO:new RegExp("^"+O),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=/'|\\/g,ab=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),bb=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{G.apply(D=H.call(t.childNodes),t.childNodes),D[t.childNodes.length].nodeType}catch(cb){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function db(a,b,d,e){var f,g,h,i,j,m,p,q,u,v;if((b?b.ownerDocument||b:t)!==l&&k(b),b=b||l,d=d||[],!a||"string"!=typeof a)return d;if(1!==(i=b.nodeType)&&9!==i)return[];if(n&&!e){if(f=Z.exec(a))if(h=f[1]){if(9===i){if(g=b.getElementById(h),!g||!g.parentNode)return d;if(g.id===h)return d.push(g),d}else if(b.ownerDocument&&(g=b.ownerDocument.getElementById(h))&&r(b,g)&&g.id===h)return d.push(g),d}else{if(f[2])return G.apply(d,b.getElementsByTagName(a)),d;if((h=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(h)),d}if(c.qsa&&(!o||!o.test(a))){if(q=p=s,u=b,v=9===i&&a,1===i&&"object"!==b.nodeName.toLowerCase()){m=ob(a),(p=b.getAttribute("id"))?q=p.replace(_,"\\$&"):b.setAttribute("id",q),q="[id='"+q+"'] ",j=m.length;while(j--)m[j]=q+pb(m[j]);u=$.test(a)&&mb(b.parentNode)||b,v=m.join(",")}if(v)try{return G.apply(d,u.querySelectorAll(v)),d}catch(w){}finally{p||b.removeAttribute("id")}}}return xb(a.replace(P,"$1"),b,d,e)}function eb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function fb(a){return a[s]=!0,a}function gb(a){var b=l.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function hb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function ib(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||B)-(~a.sourceIndex||B);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function jb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function kb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function lb(a){return fb(function(b){return b=+b,fb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function mb(a){return a&&typeof a.getElementsByTagName!==A&&a}c=db.support={},f=db.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},k=db.setDocument=function(a){var b,e=a?a.ownerDocument||a:t,g=e.defaultView;return e!==l&&9===e.nodeType&&e.documentElement?(l=e,m=e.documentElement,n=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){k()},!1):g.attachEvent&&g.attachEvent("onunload",function(){k()})),c.attributes=gb(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=gb(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(e.getElementsByClassName)&&gb(function(a){return a.innerHTML="
    ",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=gb(function(a){return m.appendChild(a).id=s,!e.getElementsByName||!e.getElementsByName(s).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==A&&n){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){var c=typeof a.getAttributeNode!==A&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==A?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==A&&n?b.getElementsByClassName(a):void 0},p=[],o=[],(c.qsa=Y.test(e.querySelectorAll))&&(gb(function(a){a.innerHTML="",a.querySelectorAll("[t^='']").length&&o.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||o.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll(":checked").length||o.push(":checked")}),gb(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&o.push("name"+K+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||o.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),o.push(",.*:")})),(c.matchesSelector=Y.test(q=m.webkitMatchesSelector||m.mozMatchesSelector||m.oMatchesSelector||m.msMatchesSelector))&&gb(function(a){c.disconnectedMatch=q.call(a,"div"),q.call(a,"[s!='']:x"),p.push("!=",O)}),o=o.length&&new RegExp(o.join("|")),p=p.length&&new RegExp(p.join("|")),b=Y.test(m.compareDocumentPosition),r=b||Y.test(m.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},z=b?function(a,b){if(a===b)return j=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===t&&r(t,a)?-1:b===e||b.ownerDocument===t&&r(t,b)?1:i?I.call(i,a)-I.call(i,b):0:4&d?-1:1)}:function(a,b){if(a===b)return j=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],k=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:i?I.call(i,a)-I.call(i,b):0;if(f===g)return ib(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)k.unshift(c);while(h[d]===k[d])d++;return d?ib(h[d],k[d]):h[d]===t?-1:k[d]===t?1:0},e):l},db.matches=function(a,b){return db(a,null,null,b)},db.matchesSelector=function(a,b){if((a.ownerDocument||a)!==l&&k(a),b=b.replace(S,"='$1']"),!(!c.matchesSelector||!n||p&&p.test(b)||o&&o.test(b)))try{var d=q.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return db(b,l,null,[a]).length>0},db.contains=function(a,b){return(a.ownerDocument||a)!==l&&k(a),r(a,b)},db.attr=function(a,b){(a.ownerDocument||a)!==l&&k(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!n):void 0;return void 0!==f?f:c.attributes||!n?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},db.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},db.uniqueSort=function(a){var b,d=[],e=0,f=0;if(j=!c.detectDuplicates,i=!c.sortStable&&a.slice(0),a.sort(z),j){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return i=null,a},e=db.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=db.selectors={cacheLength:50,createPseudo:fb,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ab,bb),a[3]=(a[4]||a[5]||"").replace(ab,bb),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||db.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&db.error(a[0]),a},PSEUDO:function(a){var b,c=!a[5]&&a[2];return V.CHILD.test(a[0])?null:(a[3]&&void 0!==a[4]?a[2]=a[4]:c&&T.test(c)&&(b=ob(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ab,bb).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=w[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&w(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==A&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=db.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),t=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&t){k=q[s]||(q[s]={}),j=k[a]||[],n=j[0]===u&&j[1],m=j[0]===u&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[u,n,m];break}}else if(t&&(j=(b[s]||(b[s]={}))[a])&&j[0]===u)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(t&&((l[s]||(l[s]={}))[a]=[u,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||db.error("unsupported pseudo: "+a);return e[s]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?fb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:fb(function(a){var b=[],c=[],d=g(a.replace(P,"$1"));return d[s]?fb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:fb(function(a){return function(b){return db(a,b).length>0}}),contains:fb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:fb(function(a){return U.test(a||"")||db.error("unsupported lang: "+a),a=a.replace(ab,bb).toLowerCase(),function(b){var c;do if(c=n?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===m},focus:function(a){return a===l.activeElement&&(!l.hasFocus||l.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:lb(function(){return[0]}),last:lb(function(a,b){return[b-1]}),eq:lb(function(a,b,c){return[0>c?c+b:c]}),even:lb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:lb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:lb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:lb(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function qb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=v++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[u,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[s]||(b[s]={}),(h=i[d])&&h[0]===u&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function rb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function sb(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function tb(a,b,c,d,e,f){return d&&!d[s]&&(d=tb(d)),e&&!e[s]&&(e=tb(e,f)),fb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||wb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:sb(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=sb(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?I.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=sb(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ub(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],i=g||d.relative[" "],j=g?1:0,k=qb(function(a){return a===b},i,!0),l=qb(function(a){return I.call(b,a)>-1},i,!0),m=[function(a,c,d){return!g&&(d||c!==h)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>j;j++)if(c=d.relative[a[j].type])m=[qb(rb(m),c)];else{if(c=d.filter[a[j].type].apply(null,a[j].matches),c[s]){for(e=++j;f>e;e++)if(d.relative[a[e].type])break;return tb(j>1&&rb(m),j>1&&pb(a.slice(0,j-1).concat({value:" "===a[j-2].type?"*":""})).replace(P,"$1"),c,e>j&&ub(a.slice(j,e)),f>e&&ub(a=a.slice(e)),f>e&&pb(a))}m.push(c)}return rb(m)}function vb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,i,j,k){var m,n,o,p=0,q="0",r=f&&[],s=[],t=h,v=f||e&&d.find.TAG("*",k),w=u+=null==t?1:Math.random()||.1,x=v.length;for(k&&(h=g!==l&&g);q!==x&&null!=(m=v[q]);q++){if(e&&m){n=0;while(o=a[n++])if(o(m,g,i)){j.push(m);break}k&&(u=w)}c&&((m=!o&&m)&&p--,f&&r.push(m))}if(p+=q,c&&q!==p){n=0;while(o=b[n++])o(r,s,g,i);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=E.call(j));s=sb(s)}G.apply(j,s),k&&!f&&s.length>0&&p+b.length>1&&db.uniqueSort(j)}return k&&(u=w,h=t),r};return c?fb(f):f}g=db.compile=function(a,b){var c,d=[],e=[],f=y[a+" "];if(!f){b||(b=ob(a)),c=b.length;while(c--)f=ub(b[c]),f[s]?d.push(f):e.push(f);f=y(a,vb(e,d))}return f};function wb(a,b,c){for(var d=0,e=b.length;e>d;d++)db(a,b[d],c);return c}function xb(a,b,e,f){var h,i,j,k,l,m=ob(a);if(!f&&1===m.length){if(i=m[0]=m[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&c.getById&&9===b.nodeType&&n&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(ab,bb),b)||[])[0],!b)return e;a=a.slice(i.shift().value.length)}h=V.needsContext.test(a)?0:i.length;while(h--){if(j=i[h],d.relative[k=j.type])break;if((l=d.find[k])&&(f=l(j.matches[0].replace(ab,bb),$.test(i[0].type)&&mb(b.parentNode)||b))){if(i.splice(h,1),a=f.length&&pb(i),!a)return G.apply(e,f),e;break}}}return g(a,m)(f,b,!n,e,$.test(a)&&mb(b.parentNode)||b),e}return c.sortStable=s.split("").sort(z).join("")===s,c.detectDuplicates=!!j,k(),c.sortDetached=gb(function(a){return 1&a.compareDocumentPosition(l.createElement("div"))}),gb(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||hb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&gb(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||hb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),gb(function(a){return null==a.getAttribute("disabled")})||hb(J,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),db}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return n.inArray(a,b)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;e>b;b++)if(n.contains(d[b],this))return!0}));for(b=0;e>b;b++)n.find(a,d[b],c);return c=this.pushStack(e>1?n.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=a.document,A=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,B=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:A.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:z,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=z.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return y.find(a);this.length=1,this[0]=d}return this.context=z,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};B.prototype=n.fn,y=n(z);var C=/^(?:parents|prev(?:Until|All))/,D={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!n(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b,c=n(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(n.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?n.inArray(this[0],n(a)):n.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function E(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return E(a,"nextSibling")},prev:function(a){return E(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return n.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(D[a]||(e=n.unique(e)),C.test(a)&&(e=e.reverse())),this.pushStack(e)}});var F=/\S+/g,G={};function H(a){var b=G[a]={};return n.each(a.match(F)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?G[a]||H(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&n.each(arguments,function(a,c){var d;while((d=n.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var I;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){if(a===!0?!--n.readyWait:!n.isReady){if(!z.body)return setTimeout(n.ready);n.isReady=!0,a!==!0&&--n.readyWait>0||(I.resolveWith(z,[n]),n.fn.trigger&&n(z).trigger("ready").off("ready"))}}});function J(){z.addEventListener?(z.removeEventListener("DOMContentLoaded",K,!1),a.removeEventListener("load",K,!1)):(z.detachEvent("onreadystatechange",K),a.detachEvent("onload",K))}function K(){(z.addEventListener||"load"===event.type||"complete"===z.readyState)&&(J(),n.ready())}n.ready.promise=function(b){if(!I)if(I=n.Deferred(),"complete"===z.readyState)setTimeout(n.ready);else if(z.addEventListener)z.addEventListener("DOMContentLoaded",K,!1),a.addEventListener("load",K,!1);else{z.attachEvent("onreadystatechange",K),a.attachEvent("onload",K);var c=!1;try{c=null==a.frameElement&&z.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!n.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}J(),n.ready()}}()}return I.promise(b)};var L="undefined",M;for(M in n(l))break;l.ownLast="0"!==M,l.inlineBlockNeedsLayout=!1,n(function(){var a,b,c=z.getElementsByTagName("body")[0];c&&(a=z.createElement("div"),a.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",b=z.createElement("div"),c.appendChild(a).appendChild(b),typeof b.style.zoom!==L&&(b.style.cssText="border:0;margin:0;width:1px;padding:1px;display:inline;zoom:1",(l.inlineBlockNeedsLayout=3===b.offsetWidth)&&(c.style.zoom=1)),c.removeChild(a),a=b=null)}),function(){var a=z.createElement("div");if(null==l.deleteExpando){l.deleteExpando=!0;try{delete a.test}catch(b){l.deleteExpando=!1}}a=null}(),n.acceptData=function(a){var b=n.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(O,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}n.data(a,b,c)}else c=void 0}return c}function Q(a){var b;for(b in a)if(("data"!==b||!n.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function R(a,b,d,e){if(n.acceptData(a)){var f,g,h=n.expando,i=a.nodeType,j=i?n.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||n.guid++:h),j[k]||(j[k]=i?{}:{toJSON:n.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=n.extend(j[k],b):j[k].data=n.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[n.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[n.camelCase(b)])):f=g,f +}}function S(a,b,c){if(n.acceptData(a)){var d,e,f=a.nodeType,g=f?n.cache:a,h=f?a[n.expando]:n.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){n.isArray(b)?b=b.concat(n.map(b,n.camelCase)):b in d?b=[b]:(b=n.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!Q(d):!n.isEmptyObject(d))return}(c||(delete g[h].data,Q(g[h])))&&(f?n.cleanData([a],!0):l.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}n.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?n.cache[a[n.expando]]:a[n.expando],!!a&&!Q(a)},data:function(a,b,c){return R(a,b,c)},removeData:function(a,b){return S(a,b)},_data:function(a,b,c){return R(a,b,c,!0)},_removeData:function(a,b){return S(a,b,!0)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=n.data(f),1===f.nodeType&&!n._data(f,"parsedAttrs"))){c=g.length;while(c--)d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d]));n._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){n.data(this,a)}):arguments.length>1?this.each(function(){n.data(this,a,b)}):f?P(f,a,n.data(f,a)):void 0},removeData:function(a){return this.each(function(){n.removeData(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=n._data(a,b),c&&(!d||n.isArray(c)?d=n._data(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return n._data(a,c)||n._data(a,c,{empty:n.Callbacks("once memory").add(function(){n._removeData(a,b+"queue"),n._removeData(a,c)})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthh;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},X=/^(?:checkbox|radio)$/i;!function(){var a=z.createDocumentFragment(),b=z.createElement("div"),c=z.createElement("input");if(b.setAttribute("className","t"),b.innerHTML="
    a",l.leadingWhitespace=3===b.firstChild.nodeType,l.tbody=!b.getElementsByTagName("tbody").length,l.htmlSerialize=!!b.getElementsByTagName("link").length,l.html5Clone="<:nav>"!==z.createElement("nav").cloneNode(!0).outerHTML,c.type="checkbox",c.checked=!0,a.appendChild(c),l.appendChecked=c.checked,b.innerHTML="",l.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,a.appendChild(b),b.innerHTML="",l.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,l.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){l.noCloneEvent=!1}),b.cloneNode(!0).click()),null==l.deleteExpando){l.deleteExpando=!0;try{delete b.test}catch(d){l.deleteExpando=!1}}a=b=c=null}(),function(){var b,c,d=z.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(l[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),l[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var Y=/^(?:input|select|textarea)$/i,Z=/^key/,$=/^(?:mouse|contextmenu)|click/,_=/^(?:focusinfocus|focusoutblur)$/,ab=/^([^.]*)(?:\.(.+)|)$/;function bb(){return!0}function cb(){return!1}function db(){try{return z.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=n._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=n.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof n===L||a&&n.event.triggered===a.type?void 0:n.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(F)||[""],h=b.length;while(h--)f=ab.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=n.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=n.event.special[o]||{},l=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},i),(m=g[o])||(m=g[o]=[],m.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,l):m.push(l),n.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=n.hasData(a)&&n._data(a);if(r&&(k=r.events)){b=(b||"").match(F)||[""],j=b.length;while(j--)if(h=ab.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=m.length;while(f--)g=m[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(m.splice(f,1),g.selector&&m.delegateCount--,l.remove&&l.remove.call(a,g));i&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(k)&&(delete r.handle,n._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,m,o=[d||z],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||z,3!==d.nodeType&&8!==d.nodeType&&!_.test(p+n.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[n.expando]?b:new n.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),k=n.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!n.isWindow(d)){for(i=k.delegateType||p,_.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||z)&&o.push(l.defaultView||l.parentWindow||a)}m=0;while((h=o[m++])&&!b.isPropagationStopped())b.type=m>1?i:k.bindType||p,f=(n._data(h,"events")||{})[b.type]&&n._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&n.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&n.acceptData(d)&&g&&d[p]&&!n.isWindow(d)){l=d[g],l&&(d[g]=null),n.event.triggered=p;try{d[p]()}catch(r){}n.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(n._data(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((n.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?n(c,this).index(i)>=0:n.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h]","i"),ib=/^\s+/,jb=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,kb=/<([\w:]+)/,lb=/\s*$/g,sb={option:[1,""],legend:[1,"
    ","
    "],area:[1,"",""],param:[1,"",""],thead:[1,"","
    "],tr:[2,"","
    "],col:[2,"","
    "],td:[3,"","
    "],_default:l.htmlSerialize?[0,"",""]:[1,"X
    ","
    "]},tb=eb(z),ub=tb.appendChild(z.createElement("div"));sb.optgroup=sb.option,sb.tbody=sb.tfoot=sb.colgroup=sb.caption=sb.thead,sb.th=sb.td;function vb(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==L?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==L?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||n.nodeName(d,b)?f.push(d):n.merge(f,vb(d,b));return void 0===b||b&&n.nodeName(a,b)?n.merge([a],f):f}function wb(a){X.test(a.type)&&(a.defaultChecked=a.checked)}function xb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function yb(a){return a.type=(null!==n.find.attr(a,"type"))+"/"+a.type,a}function zb(a){var b=qb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Ab(a,b){for(var c,d=0;null!=(c=a[d]);d++)n._data(c,"globalEval",!b||n._data(b[d],"globalEval"))}function Bb(a,b){if(1===b.nodeType&&n.hasData(a)){var c,d,e,f=n._data(a),g=n._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)n.event.add(b,c,h[c][d])}g.data&&(g.data=n.extend({},g.data))}}function Cb(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!l.noCloneEvent&&b[n.expando]){e=n._data(b);for(d in e.events)n.removeEvent(b,d,e.handle);b.removeAttribute(n.expando)}"script"===c&&b.text!==a.text?(yb(b).text=a.text,zb(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),l.html5Clone&&a.innerHTML&&!n.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&X.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}n.extend({clone:function(a,b,c){var d,e,f,g,h,i=n.contains(a.ownerDocument,a);if(l.html5Clone||n.isXMLDoc(a)||!hb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(ub.innerHTML=a.outerHTML,ub.removeChild(f=ub.firstChild)),!(l.noCloneEvent&&l.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(d=vb(f),h=vb(a),g=0;null!=(e=h[g]);++g)d[g]&&Cb(e,d[g]);if(b)if(c)for(h=h||vb(a),d=d||vb(f),g=0;null!=(e=h[g]);g++)Bb(e,d[g]);else Bb(a,f);return d=vb(f,"script"),d.length>0&&Ab(d,!i&&vb(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k,m=a.length,o=eb(b),p=[],q=0;m>q;q++)if(f=a[q],f||0===f)if("object"===n.type(f))n.merge(p,f.nodeType?[f]:f);else if(mb.test(f)){h=h||o.appendChild(b.createElement("div")),i=(kb.exec(f)||["",""])[1].toLowerCase(),k=sb[i]||sb._default,h.innerHTML=k[1]+f.replace(jb,"<$1>")+k[2],e=k[0];while(e--)h=h.lastChild;if(!l.leadingWhitespace&&ib.test(f)&&p.push(b.createTextNode(ib.exec(f)[0])),!l.tbody){f="table"!==i||lb.test(f)?""!==k[1]||lb.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)n.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}n.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),l.appendChecked||n.grep(vb(p,"input"),wb),q=0;while(f=p[q++])if((!d||-1===n.inArray(f,d))&&(g=n.contains(f.ownerDocument,f),h=vb(o.appendChild(f),"script"),g&&Ab(h),c)){e=0;while(f=h[e++])pb.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=n.expando,j=n.cache,k=l.deleteExpando,m=n.event.special;null!=(d=a[h]);h++)if((b||n.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)m[e]?n.event.remove(d,e):n.removeEvent(d,e,g.handle);j[f]&&(delete j[f],k?delete d[i]:typeof d.removeAttribute!==L?d.removeAttribute(i):d[i]=null,c.push(f))}}}),n.fn.extend({text:function(a){return W(this,function(a){return void 0===a?n.text(this):this.empty().append((this[0]&&this[0].ownerDocument||z).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=xb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=xb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(vb(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&Ab(vb(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&n.cleanData(vb(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&n.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return W(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(gb,""):void 0;if(!("string"!=typeof a||nb.test(a)||!l.htmlSerialize&&hb.test(a)||!l.leadingWhitespace&&ib.test(a)||sb[(kb.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(jb,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(vb(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(vb(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,k=this.length,m=this,o=k-1,p=a[0],q=n.isFunction(p);if(q||k>1&&"string"==typeof p&&!l.checkClone&&ob.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(k&&(i=n.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=n.map(vb(i,"script"),yb),f=g.length;k>j;j++)d=i,j!==o&&(d=n.clone(d,!0,!0),f&&n.merge(g,vb(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,n.map(g,zb),j=0;f>j;j++)d=g[j],pb.test(d.type||"")&&!n._data(d,"globalEval")&&n.contains(h,d)&&(d.src?n._evalUrl&&n._evalUrl(d.src):n.globalEval((d.text||d.textContent||d.innerHTML||"").replace(rb,"")));i=c=null}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=0,e=[],g=n(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),n(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Db,Eb={};function Fb(b,c){var d=n(c.createElement(b)).appendTo(c.body),e=a.getDefaultComputedStyle?a.getDefaultComputedStyle(d[0]).display:n.css(d[0],"display");return d.detach(),e}function Gb(a){var b=z,c=Eb[a];return c||(c=Fb(a,b),"none"!==c&&c||(Db=(Db||n("