Skip to content

Commit

Permalink
CSharp friendly wrapper part 1 #327
Browse files Browse the repository at this point in the history
  • Loading branch information
lefthandedgoat committed Jan 12, 2017
1 parent 4852151 commit 3af60d9
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 1 deletion.
15 changes: 15 additions & 0 deletions canopy.sln
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{3C3590B5
docs\tools\templates\template.cshtml = docs\tools\templates\template.cshtml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharptests", "csharptests\csharptests.csproj", "{8FD011AE-ACEC-4B55-810B-736DAE312D32}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -84,6 +86,18 @@ Global
{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
{8FD011AE-ACEC-4B55-810B-736DAE312D32}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{8FD011AE-ACEC-4B55-810B-736DAE312D32}.Debug|x86.ActiveCfg = Debug|Any CPU
{8FD011AE-ACEC-4B55-810B-736DAE312D32}.Debug|x86.Build.0 = Debug|Any CPU
{8FD011AE-ACEC-4B55-810B-736DAE312D32}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8FD011AE-ACEC-4B55-810B-736DAE312D32}.Release|Any CPU.Build.0 = Release|Any CPU
{8FD011AE-ACEC-4B55-810B-736DAE312D32}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -92,5 +106,6 @@ Global
{D4610DE2-BFD2-491D-AD72-BBBB206E11C7} = {0391DED2-DF91-4A61-959E-EEA250356DA0}
{A94D736A-68EB-4D7B-A761-DF6B1EEAE24C} = {12E9007C-8265-43D8-86B0-C9182921A9E5}
{3C3590B5-4CC8-49D1-A2CE-4FDFA73ADB53} = {12E9007C-8265-43D8-86B0-C9182921A9E5}
{8FD011AE-ACEC-4B55-810B-736DAE312D32} = {0391DED2-DF91-4A61-959E-EEA250356DA0}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions csharptests/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
49 changes: 49 additions & 0 deletions csharptests/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using canopy;
using _ = canopy.csharp.canopy;

namespace csharptests
{
class Program
{
static void Main(string[] args)
{
configuration.elementTimeout = 3.0;
configuration.compareTimeout = 3.0;
configuration.pageTimeout = 3.0;
configuration.reporter = new reporters.LiveHtmlReporter(types.BrowserStartMode.Chrome, configuration.chromeDir);

var testpage = "http://lefthandedgoat.github.io/canopy/testpages/";

_.start(types.BrowserStartMode.Chrome);

_.context("context1");
_.once(() => Console.WriteLine("once"));
_.before(() => Console.WriteLine("before"));
_.after(() => Console.WriteLine("after"));
_.lastly(() => Console.WriteLine("lastly"));

_.skip("intentionally skipped shows blue in LiveHtmlReport", () =>
{
_.url("http://www.skipped.com");
});

_.test("Apostrophes don't break anything", () =>
{
_.url(testpage);
_.count("I've got an apostrophe", 1);
});

_.test("#firstName should have John (using == infix operator)", () =>
{
_.url(testpage);
_.equals("#firstName", "John");
});

_.run();

System.Console.ReadKey();
_.quit();
}
}
}
36 changes: 36 additions & 0 deletions csharptests/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("csharptests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("csharptests")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[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("8fd011ae-acec-4b55-810b-736dae312d32")]

// 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")]
66 changes: 66 additions & 0 deletions csharptests/csharptests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.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>{8FD011AE-ACEC-4B55-810B-736DAE312D32}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>csharptests</RootNamespace>
<AssemblyName>csharptests</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\src\canopy\canopy.fsproj">
<Project>{63135cf6-70a9-4382-851d-4b679ee0cbf8}</Project>
<Name>canopy</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>
-->
</Project>
1 change: 1 addition & 0 deletions src/canopy/canopy.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<None Include="paket.references" />
<Compile Include="screenSizes.fs" />
<Compile Include="userAgents.fs" />
<Compile Include="csharp.fs" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib" />
Expand Down
42 changes: 42 additions & 0 deletions src/canopy/csharp.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
namespace canopy.csharp

open canopy.runner
open canopy

type canopy () =

static member browsers = canopy.core.browsers

static member browser = canopy.types.browser

//runner stuff
static member context description = context description

static member once (f : System.Action) = once (fun _ -> f.Invoke())

static member before (f : System.Action) = before (fun _ -> f.Invoke())

static member after (f : System.Action) = after (fun _ -> f.Invoke())

static member lastly (f : System.Action) = lastly (fun _ -> f.Invoke())

static member test description (f : System.Action) = description &&& fun _ -> f.Invoke()

static member wip description (f : System.Action) = description &&&& fun _ -> f.Invoke()

static member skip description (f : System.Action) = description &&! canopy.runner.skipped

static member run () = canopy.runner.run ()


//core stuff
static member start b = canopy.core.start b

static member url url = canopy.core.url url

static member quit () = canopy.core.quit ()

//assertions
static member equals selector value = selector == value

static member count selector value = count selector value
3 changes: 2 additions & 1 deletion src/canopy/reporters.fs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ type TeamCityReporter(?logImagesToConsole: bool) =
member this.setEnvironment env = ()
type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string, ?pinBrowserRight0: bool) =
type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string, ?pinBrowserRight0: bool) =
let pinBrowserRight = defaultArg pinBrowserRight0 true
let consoleReporter : IReporter = new ConsoleReporter() :> IReporter
Expand Down Expand Up @@ -242,6 +242,7 @@ type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string, ?pinBrows
new() = LiveHtmlReporter(Firefox, String.Empty)
new(browser : BrowserStartMode) = LiveHtmlReporter(browser, String.Empty)
new (browser : BrowserStartMode, driverPath : string) = LiveHtmlReporter(browser, driverPath, true)
member this.browser
with get () = _browser
Expand Down

0 comments on commit 3af60d9

Please sign in to comment.