Skip to content

Commit

Permalink
Added dependency on FSharp.Core nuget package and create a C# test
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Mar 4, 2015
1 parent 8fb861c commit 1d121a8
Show file tree
Hide file tree
Showing 12 changed files with 235 additions and 7 deletions.
7 changes: 7 additions & 0 deletions Chessie.sln
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{ED8079DD
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Chessie.Tests", "tests\Chessie.Tests\Chessie.Tests.fsproj", "{5D8D2601-26EF-42C7-9703-8BDDDA015CB8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chessie.CSharp.Test", "tests\Chessie.CSharp.Test\Chessie.CSharp.Test.csproj", "{FC460F0A-F3C6-4314-BD2C-9F4218B902BC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -49,6 +51,10 @@ Global
{5D8D2601-26EF-42C7-9703-8BDDDA015CB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5D8D2601-26EF-42C7-9703-8BDDDA015CB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5D8D2601-26EF-42C7-9703-8BDDDA015CB8}.Release|Any CPU.Build.0 = Release|Any CPU
{FC460F0A-F3C6-4314-BD2C-9F4218B902BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC460F0A-F3C6-4314-BD2C-9F4218B902BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC460F0A-F3C6-4314-BD2C-9F4218B902BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC460F0A-F3C6-4314-BD2C-9F4218B902BC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -57,5 +63,6 @@ Global
{83F16175-43B1-4C90-A1EE-8E351C33435D} = {A6A6AF7D-D6E3-442D-9B1E-58CC91879BE1}
{8E6D5255-776D-4B61-85F9-73C37AA1FB9A} = {A6A6AF7D-D6E3-442D-9B1E-58CC91879BE1}
{5D8D2601-26EF-42C7-9703-8BDDDA015CB8} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4}
{FC460F0A-F3C6-4314-BD2C-9F4218B902BC} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4}
EndGlobalSection
EndGlobal
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 0.0.8 - 04.04.2015
* Added dependency on FSharp.Core nuget package

#### 0.0.7 - 28.02.2015
* Added eitherTee - https://github.com/fsprojects/Chessie/pull/7

Expand Down
1 change: 1 addition & 0 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ nuget NUnit
nuget NUnit.Runners
nuget FAKE
nuget SourceLink.Fake
nuget FSharp.Core

github fsharp/FAKE modules/Octokit/Octokit.fsx
github forki/FsUnit FsUnit.fs
11 changes: 6 additions & 5 deletions paket.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
NUGET
remote: https://nuget.org/api/v2
specs:
FAKE (3.17.13)
FSharp.Compiler.Service (0.0.84)
FAKE (3.17.14)
FSharp.Compiler.Service (0.0.85)
FSharp.Core (3.1.2.1)
FSharp.Formatting (2.7.4)
FSharp.Compiler.Service (>= 0.0.82)
FSharpVSPowerTools.Core (>= 1.7.0)
Expand All @@ -16,14 +17,14 @@ NUGET
Microsoft.Bcl.Build (>= 1.0.14)
NUnit (2.6.4)
NUnit.Runners (2.6.4)
Octokit (0.7.1)
Octokit (0.7.2)
Microsoft.Net.Http
SourceLink.Fake (0.4.2)
GITHUB
remote: fsharp/FAKE
specs:
modules/Octokit/Octokit.fsx (99bf805630805455031684c9369b1872d14a4fdd)
modules/Octokit/Octokit.fsx (585c008b4cfce177b0114f6749904e05a471508f)
Octokit
remote: forki/FsUnit
specs:
FsUnit.fs (a8830b5a70e72a1948592cfa1e43e3c5b0a31b92)
FsUnit.fs (81d27fd09575a32c4ed52eadb2eeac5f365b8348)
1 change: 1 addition & 0 deletions src/Chessie/Chessie.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<ItemGroup>
<Compile Include="ErrorHandling.fs" />
<None Include="paket.template" />
<None Include="paket.references" />
</ItemGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
Expand Down
4 changes: 2 additions & 2 deletions src/Chessie/ErrorHandling.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ type Result<'TSuccess, 'TMessage> =
| Fail of 'TMessage list

/// Wraps a value in a Success
let inline ok x = Ok(x, [])
let inline ok<'a,'b> (x:'a) : Result<'a,'b> = Ok(x, [])

/// Wraps a message in a Failure
let inline fail msg = Fail([ msg ])
let inline fail<'a,'b> (msg:'b) : Result<'a,'b> = Fail([ msg ])

/// Returns true if the result was not successful.
let inline failed result =
Expand Down
1 change: 1 addition & 0 deletions src/Chessie/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FSharp.Core
134 changes: 134 additions & 0 deletions tests/Chessie.CSharp.Test/Chessie.CSharp.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FC460F0A-F3C6-4314-BD2C-9F4218B902BC}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Chessie.CSharp.Test</RootNamespace>
<AssemblyName>Chessie.CSharp.Test</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="SimpleValidation.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="paket.references" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Chessie\Chessie.fsproj">
<Project>{5c095a65-1bf4-4c24-82d2-a07e8c258789}</Project>
<Name>Chessie</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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>
-->
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3')">
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\..\packages\FSharp.Core\lib\net40\FSharp.Core.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == 'MonoAndroid'">
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\..\packages\FSharp.Core\lib\MonoAndroid\FSharp.Core.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == 'MonoTouch'">
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\..\packages\FSharp.Core\lib\MonoTouch\FSharp.Core.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="($(TargetFrameworkIdentifier) == '.NETCore') Or ($(TargetFrameworkProfile) == 'Profile7') Or ($(TargetFrameworkProfile) == 'Profile44')">
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\..\packages\FSharp.Core\lib\portable-net45+netcore45+MonoAndroid1+MonoTouch1\FSharp.Core.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="($(TargetFrameworkIdentifier) == 'Silverlight' And $(TargetFrameworkVersion) == 'v5.0') Or ($(TargetFrameworkProfile) == 'Profile24') Or ($(TargetFrameworkProfile) == 'Profile47')">
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\..\packages\FSharp.Core\lib\portable-net45+sl5+netcore45+MonoAndroid1+MonoTouch1\FSharp.Core.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="($(TargetFrameworkIdentifier) == 'WindowsPhone' And ($(TargetFrameworkVersion) == 'v8.0' Or $(TargetFrameworkVersion) == 'v8.1')) Or ($(TargetFrameworkProfile) == 'Profile31') Or ($(TargetFrameworkProfile) == 'Profile49') Or ($(TargetFrameworkProfile) == 'Profile78')">
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\..\packages\FSharp.Core\lib\portable-net45+netcore45+wp8+MonoAndroid1+MonoTouch1\FSharp.Core.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="($(TargetFrameworkIdentifier) == 'WindowsPhoneApp') Or ($(TargetFrameworkProfile) == 'Profile32') Or ($(TargetFrameworkProfile) == 'Profile84') Or ($(TargetFrameworkProfile) == 'Profile111') Or ($(TargetFrameworkProfile) == 'Profile151') Or ($(TargetFrameworkProfile) == 'Profile157') Or ($(TargetFrameworkProfile) == 'Profile259')">
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\..\packages\FSharp.Core\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1\FSharp.Core.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>..\..\packages\NUnit\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</Project>
36 changes: 36 additions & 0 deletions tests/Chessie.CSharp.Test/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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("Chessie.CSharp.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Chessie.CSharp.Test")]
[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("98b876ac-91ea-4e81-83cc-77b6f56ef9b1")]

// 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")]
40 changes: 40 additions & 0 deletions tests/Chessie.CSharp.Test/SimpleValidation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;

namespace Chessie.CSharp.Test
{
public class Request
{
public string Name { get; set; }
public string EMail { get; set; }
}

public class Validation
{
public static Chessie.ErrorHandling.Result<Request, string> ValidateInput(Request input)
{
if (input.Name == "")
return Chessie.ErrorHandling.fail<Request, string>("Name must not be blank");
if (input.EMail == "")
return Chessie.ErrorHandling.fail<Request, string>("Email must not be blank");
return Chessie.ErrorHandling.ok<Request, string>(input);

}
}

[TestFixture]
public class SimpleValidation
{
[Test]
public void CanCreateSuccess()
{
var request = new Request { Name = "", EMail = "" };
var result = Validation.ValidateInput(request);
Assert.AreEqual(Chessie.ErrorHandling.fail<Request, string>("Name must not be blank"), result);
}
}
}
3 changes: 3 additions & 0 deletions tests/Chessie.CSharp.Test/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FSharp.Core
NUnit
NUnit.Runners
1 change: 1 addition & 0 deletions tests/Chessie.Tests/paket.references
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
FSharp.Core
NUnit
NUnit.Runners
File:FsUnit.fs .

0 comments on commit 1d121a8

Please sign in to comment.