Skip to content

Commit

Permalink
Issue #371 split out json validations
Browse files Browse the repository at this point in the history
  • Loading branch information
lefthandedgoat committed Jun 18, 2017
1 parent 5915f46 commit 14e1233
Show file tree
Hide file tree
Showing 19 changed files with 199 additions and 402 deletions.
26 changes: 14 additions & 12 deletions canopy.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "basictests", "tests\basicte
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "canopy", "src\canopy\canopy.fsproj", "{63135CF6-70A9-4382-851D-4B679EE0CBF8}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "sampleprojectstructure", "src\sampleprojectstructure\sampleprojectstructure.fsproj", "{9DE5614C-8D7F-4BBD-A6A0-24AABD76796C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{12E9007C-8265-43D8-86B0-C9182921A9E5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{C8531F58-5EAB-413F-BB2F-FE96AE0A55F2}"
Expand Down Expand Up @@ -46,6 +44,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{3C3590B5
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharptests", "csharptests\csharptests.csproj", "{8FD011AE-ACEC-4B55-810B-736DAE312D32}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "canopy.integration", "src\canopy.integration\canopy.integration.fsproj", "{4303FFAC-759E-4764-89AD-ED6A73E2E16D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -76,16 +76,6 @@ Global
{63135CF6-70A9-4382-851D-4B679EE0CBF8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{63135CF6-70A9-4382-851D-4B679EE0CBF8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{63135CF6-70A9-4382-851D-4B679EE0CBF8}.Release|x86.ActiveCfg = Release|Any CPU
{9DE5614C-8D7F-4BBD-A6A0-24AABD76796C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9DE5614C-8D7F-4BBD-A6A0-24AABD76796C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9DE5614C-8D7F-4BBD-A6A0-24AABD76796C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{9DE5614C-8D7F-4BBD-A6A0-24AABD76796C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{9DE5614C-8D7F-4BBD-A6A0-24AABD76796C}.Debug|x86.ActiveCfg = Debug|Any CPU
{9DE5614C-8D7F-4BBD-A6A0-24AABD76796C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9DE5614C-8D7F-4BBD-A6A0-24AABD76796C}.Release|Any CPU.Build.0 = Release|Any CPU
{9DE5614C-8D7F-4BBD-A6A0-24AABD76796C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{9DE5614C-8D7F-4BBD-A6A0-24AABD76796C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{9DE5614C-8D7F-4BBD-A6A0-24AABD76796C}.Release|x86.ActiveCfg = Release|Any CPU
{8FD011AE-ACEC-4B55-810B-736DAE312D32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8FD011AE-ACEC-4B55-810B-736DAE312D32}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8FD011AE-ACEC-4B55-810B-736DAE312D32}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
Expand All @@ -98,6 +88,18 @@ Global
{8FD011AE-ACEC-4B55-810B-736DAE312D32}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{8FD011AE-ACEC-4B55-810B-736DAE312D32}.Release|x86.ActiveCfg = Release|Any CPU
{8FD011AE-ACEC-4B55-810B-736DAE312D32}.Release|x86.Build.0 = Release|Any CPU
{4303FFAC-759E-4764-89AD-ED6A73E2E16D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4303FFAC-759E-4764-89AD-ED6A73E2E16D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4303FFAC-759E-4764-89AD-ED6A73E2E16D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{4303FFAC-759E-4764-89AD-ED6A73E2E16D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{4303FFAC-759E-4764-89AD-ED6A73E2E16D}.Debug|x86.ActiveCfg = Debug|Any CPU
{4303FFAC-759E-4764-89AD-ED6A73E2E16D}.Debug|x86.Build.0 = Debug|Any CPU
{4303FFAC-759E-4764-89AD-ED6A73E2E16D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4303FFAC-759E-4764-89AD-ED6A73E2E16D}.Release|Any CPU.Build.0 = Release|Any CPU
{4303FFAC-759E-4764-89AD-ED6A73E2E16D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{4303FFAC-759E-4764-89AD-ED6A73E2E16D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{4303FFAC-759E-4764-89AD-ED6A73E2E16D}.Release|x86.ActiveCfg = Release|Any CPU
{4303FFAC-759E-4764-89AD-ED6A73E2E16D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 4 additions & 0 deletions csharptests/csharptests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\src\canopy.integration\canopy.integration.fsproj">
<Project>{4303ffac-759e-4764-89ad-ed6a73e2e16d}</Project>
<Name>canopy.integration</Name>
</ProjectReference>
<ProjectReference Include="..\src\canopy\canopy.fsproj">
<Project>{63135cf6-70a9-4382-851d-4b679ee0cbf8}</Project>
<Name>canopy</Name>
Expand Down
25 changes: 13 additions & 12 deletions csharptests/jsonValidatorTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using _ = canopy.csharp.canopy;
using __ = canopy.csharp.integration;

namespace csharptests
{
Expand Down Expand Up @@ -31,56 +32,56 @@ public static void All()

_.test("two identical people have no differences", () =>
{
var diff = _.diffJson(person1, person1);
var diff = __.diffJson(person1, person1);
_.equality(diff.Count, empty.Count);
_.validateJson(person1, person1);
__.validateJson(person1, person1);
});

_.test("missing property is identified", () =>
{
var diff = _.diffJson(person1, person2);
var diff = __.diffJson(person1, person2);
_.equality(1, diff.Count);
_.equality(true, diff.Contains("Missing {root}.middle"));
});

_.test("extra property is identified", () =>
{
var diff = _.diffJson(person1, person3);
var diff = __.diffJson(person1, person3);
_.equality(1, diff.Count);
_.equality(true, diff.Contains("Extra {root}.phone"));
});

_.test("empty array is acceptable array of ints", () =>
{
var diff = _.diffJson(location1, location2);
var diff = __.diffJson(location1, location2);
_.equality(diff.Count, empty.Count);
_.validateJson(location1, location2);
__.validateJson(location1, location2);
});

_.test("empty array is acceptable array of records", () =>
{
var diff = _.diffJson(location3, location4);
var diff = __.diffJson(location3, location4);
_.equality(diff.Count, empty.Count);
_.validateJson(location3, location4);
__.validateJson(location3, location4);
});

_.test("missing fields on records in arrays recognized correctly", () =>
{
var diff = _.diffJson(location3, location5);
var diff = __.diffJson(location3, location5);
_.equality(1, diff.Count);
_.equality(true, diff.Contains("Missing {root}.[people].{}.middle"));
});

_.test("extra fields on records in arrays recognized correctly", () =>
{
var diff = _.diffJson(location3, location6);
var diff = __.diffJson(location3, location6);
_.equality(1, diff.Count);
_.equality(true, diff.Contains("Extra {root}.[people].{}.phone"));
});

_.test("renamed field with extra property shows", () =>
{
var diff = _.diffJson(location7, location8);
var diff = __.diffJson(location7, location8);
_.equality(7, diff.Count);
_.equality(true, diff.Contains("Missing {root}.[workers]"));

Expand All @@ -94,7 +95,7 @@ public static void All()

_.test("nested objects with arrays reocgnized correctly", () =>
{
var diff = _.diffJson(class1, class2);
var diff = __.diffJson(class1, class2);
_.equality(3, diff.Count);
_.equality(true, diff.Contains("Missing {root}.{location}.long"));
_.equality(true, diff.Contains("Missing {root}.{location}.[people].{}.middle"));
Expand Down
29 changes: 0 additions & 29 deletions nuget/canopy-edge.nuspec

This file was deleted.

20 changes: 20 additions & 0 deletions nuget/canopy.integration.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>canopy.integration</id>
<version>@build.number@</version>
<authors>@authors@</authors>
<owners>@authors@</owners>
<licenseUrl>https://github.com/lefthandedgoat/canopy/blob/master/license.txt</licenseUrl>
<iconUrl>http://lefthandedgoat.github.io/canopy/canopy_orig.jpg</iconUrl>
<projectUrl>http://lefthandedgoat.github.com/canopy</projectUrl>
<description>@description@</description>
<releaseNotes>@releaseNotes@</releaseNotes>
<tags>@tags@</tags>
<dependencies>
<dependency id="FSharp.Core" version="3.0.2" />
<dependency id="canopy" version="1.5.0" />
<dependency id="FSharp.Data" version="2.3.3" />
</dependencies>
</metadata>
</package>
1 change: 0 additions & 1 deletion nuget/canopy.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<dependencies>
<dependency id="FSharp.Core" version="3.0.2" />
<dependency id="Selenium.WebDriver" version="3.4.0" />
<dependency id="FSharp.Data" version="2.3.3" />
</dependencies>
</metadata>
</package>
2 changes: 2 additions & 0 deletions paket.dependencies
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
source https://www.nuget.org/api/v2/

framework: net4

nuget NuGet.CommandLine
nuget FSharp.Core >= 3.0.2 lowest_matching:true
nuget Selenium.WebDriver
Expand Down
7 changes: 3 additions & 4 deletions paket.lock
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
FRAMEWORK: NET40
NUGET
remote: https://www.nuget.org/api/v2
FAKE (4.52)
FAKE (4.61.3)
FSharp.Compiler.Service (2.0.0.6)
FSharp.Core (3.0.2)
FSharp.Data (2.3.3)
Zlib.Portable (>= 1.11) - framework: >= netstandard11, portable-net45+sl5+win8, portable-net45+win8, portable-net45+win8+wp8+wpa81
FSharp.Formatting (2.14.4)
FSharp.Compiler.Service (2.0.0.6)
FSharpVSPowerTools.Core (>= 2.3 < 2.4)
FSharpVSPowerTools.Core (2.3)
FSharp.Compiler.Service (>= 2.0.0.3)
NuGet.CommandLine (3.5)
NuGet.CommandLine (4.1)
Selenium.WebDriver (3.4)
Zlib.Portable (1.11) - framework: >= netstandard11, portable-net45+sl5+win8, portable-net45+win8, portable-net45+win8+wp8+wpa81
17 changes: 17 additions & 0 deletions src/canopy.integration/AssemblyInfo.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Auto-Generated by FAKE; do not edit
namespace System
open System.Reflection

[<assembly: AssemblyTitleAttribute("canopy.integration")>]
[<assembly: AssemblyProductAttribute("canopy.integration")>]
[<assembly: AssemblyDescriptionAttribute("F# web testing framework")>]
[<assembly: AssemblyVersionAttribute("1.4.5")>]
[<assembly: AssemblyFileVersionAttribute("1.4.5")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "canopy.integration"
let [<Literal>] AssemblyProduct = "canopy.integration"
let [<Literal>] AssemblyDescription = "F# web testing framework"
let [<Literal>] AssemblyVersion = "1.4.5"
let [<Literal>] AssemblyFileVersion = "1.4.5"
99 changes: 99 additions & 0 deletions src/canopy.integration/canopy.integration.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{4303ffac-759e-4764-89ad-ed6a73e2e16d}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>canopy.integration</RootNamespace>
<AssemblyName>canopy.integration</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<Name>canopy.integration</Name>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Debug\canopy.integration.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>..\..\bin</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>..\..\bin\canopy.integration.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
</PropertyGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '11.0'">
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</Otherwise>
</Choose>
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<None Include="paket.references" />
<Compile Include="jsonValidator.fs" />
<Compile Include="csharp.fs" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Numerics" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Import Project="..\..\.paket\paket.targets" />
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.0'">
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\..\packages\FSharp.Core\lib\net40\FSharp.Core.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.0'">
<ItemGroup>
<Reference Include="System.Xml.Linq">
<Paket>True</Paket>
</Reference>
<Reference Include="FSharp.Data">
<HintPath>..\..\packages\FSharp.Data\lib\net40\FSharp.Data.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
</Project>
12 changes: 12 additions & 0 deletions src/canopy.integration/csharp.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace canopy.csharp



type integration () =

static member diffJson example actual =
let diff = jsonValidator.diff example actual
let diffString = diff |> List.map (fun d -> match d with | jsonValidator.Missing s -> sprintf "Missing %s" s | jsonValidator.Extra s -> sprintf "Extra %s" s)
ResizeArray<string>(diffString)

static member validateJson example actual = jsonValidator.validate example actual
File renamed without changes.
2 changes: 2 additions & 0 deletions src/canopy.integration/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FSharp.Core
FSharp.Data
Loading

0 comments on commit 14e1233

Please sign in to comment.