Skip to content

Commit

Permalink
Merge pull request #16 from cake-contrib/cake-recipe
Browse files Browse the repository at this point in the history
Migrate to Cake.Recipe
  • Loading branch information
Redth authored Jan 8, 2018
2 parents b690e97 + d0bd83f commit a83a935
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 198 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ xtc-email
*.user

#Cake
[Tt]ools/
[Tt]ools/
BuildArtifacts/
71 changes: 15 additions & 56 deletions Cake.FileHelpers.Tests/Cake.FileHelpers.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,64 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{19A394EA-534B-4426-BAF4-F18DEE9C88EC}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Cake.FileHelpers.Tests</RootNamespace>
<AssemblyName>Cake.FileHelpers.Tests</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFramework>netcoreapp1.1</TargetFramework>
</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.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Fakes\FakeCakeArguments.cs" />
<Compile Include="Fakes\FakeCakeContext.cs" />
<Compile Include="Fakes\FakeLog.cs" />
<Compile Include="FileHelperTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Cake.FileHelpers\Cake.FileHelpers.csproj">
<Project>{a5cf4e50-0bf9-4fd6-8c2a-46e481b39c9f}</Project>
<Name>Cake.FileHelpers</Name>
</ProjectReference>
<PackageReference Include="Cake.Core" Version="0.22.0" />
<PackageReference Include="Cake.Testing" Version="0.22.0" />
<PackageReference Include="xunit" Version="2.3.0-beta5-build3769" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0-beta5-build3769" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
</ItemGroup>

<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
<ProjectReference Include="..\Cake.FileHelpers\Cake.FileHelpers.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="0.22.0" />
<PackageReference Include="Cake.Testing" Version="0.22.0" />
<PackageReference Include="NUnit" Version="3.8.1" />
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

</Project>
97 changes: 44 additions & 53 deletions Cake.FileHelpers.Tests/FileHelperTests.cs
Original file line number Diff line number Diff line change
@@ -1,43 +1,34 @@
using NUnit.Framework;
using System;
using System;
using System.Text.RegularExpressions;
using Cake.Xamarin.Tests.Fakes;
using Cake.Core.IO;

using Xunit;

namespace Cake.FileHelpers.Tests
{
[TestFixture]
public class FileHelperTests
public class FileHelperTests : IDisposable
{
FakeCakeContext context;

[OneTimeSetUp]
public void RunBeforeAnyTests()
public FileHelperTests()
{
Environment.CurrentDirectory = System.IO.Path.GetDirectoryName(typeof(FileHelperTests).Assembly.Location);
}

[SetUp]
public void Setup ()
{
context = new FakeCakeContext ();

var dp = new DirectoryPath ("./testdata");
var d = context.CakeContext.FileSystem.GetDirectory (dp);
context = new FakeCakeContext();

var dp = new DirectoryPath("./testdata");
var d = context.CakeContext.FileSystem.GetDirectory(dp);

if (d.Exists)
d.Delete (true);
d.Delete(true);

d.Create ();
d.Create();
}

[TearDown]
public void Teardown ()

public void Dispose ()
{
context.DumpLogs ();
}

[Test]
[Fact]
public void TestWriteAndReadText ()
{
const string file = "./testdata/Text.txt";
Expand All @@ -47,10 +38,10 @@ public void TestWriteAndReadText ()

var read = context.CakeContext.FileReadText (file);

Assert.AreEqual (contents, read);
Assert.Equal (contents, read);
}

[Test]
[Fact]
public void TestWriteAndReadLines ()
{
const string file = "./testdata/Lines.txt";
Expand All @@ -60,108 +51,108 @@ public void TestWriteAndReadLines ()

var read = context.CakeContext.FileReadLines (file);

Assert.IsNotNull (read);
Assert.AreEqual (contents.Length, read.Length);
Assert.NotNull (read);
Assert.Equal (contents.Length, read.Length);

for (int i = 0; i < read.Length; i++)
Assert.AreEqual (contents[i], read[i]);
Assert.Equal (contents[i], read[i]);
}

[Test]
[Fact]
public void FindTextInFiles ()
{
SetupFiles ();

var files = context.CakeContext.FindTextInFiles ("./testdata/*.txt", "Monkey");

Assert.IsNotNull (files);
Assert.AreEqual (1, files.Length);
Assert.NotNull (files);
Assert.Single(files);
}

[Test]
[Fact]
public void FindRegexInFiles ()
{
SetupFiles ();

var files = context.CakeContext.FindRegexInFiles ("./testdata/*.txt", @"\s{1}Monkey\s{1,}");

Assert.IsNotNull (files);
Assert.AreEqual (1, files.Length);
Assert.NotNull (files);
Assert.Single(files);
}


[Test]
[Fact]
public void ReplaceTextInFiles ()
{
SetupFiles ();

var files = context.CakeContext.ReplaceTextInFiles ("./testdata/*.txt", "Monkey", "Tamarin");

Assert.IsNotNull (files);
Assert.AreEqual (1, files.Length);
Assert.NotNull (files);
Assert.Single (files);

foreach (var f in files) {
var contents = context.CakeContext.FileReadText (f);
Assert.AreEqual (string.Format (PATTERN_FILE_BASE_VALUE, "Tamarin"), contents);
Assert.Equal (string.Format (PATTERN_FILE_BASE_VALUE, "Tamarin"), contents);
}
}

[Test]
[Fact]
public void ReplaceRegexInFiles ()
{
SetupFiles ();

var files = context.CakeContext.ReplaceRegexInFiles ("./testdata/*.txt", @"\s{1}Monkey\s{1,}", " Tamarin ");

Assert.IsNotNull (files);
Assert.AreEqual (1, files.Length);
Assert.NotNull (files);
Assert.Single(files);

foreach (var f in files) {
var contents = context.CakeContext.FileReadText (f);
Assert.AreEqual (string.Format (PATTERN_FILE_BASE_VALUE, "Tamarin"), contents);
Assert.Equal (string.Format (PATTERN_FILE_BASE_VALUE, "Tamarin"), contents);
}
}

public const string GROUPS_FILE = "./testdata/Groups.txt";
public const string GROUPS_FILE_CONTENT = "Hello World! This is A quick Test to Capture multiple Groups.";
public const string GROUPS_PATTERN = "([A-Z])(\\w+)";

[Test]
[Fact]
public void FindRegexMatchesGroupsInFile ()
{
context.CakeContext.FileWriteText (GROUPS_FILE, GROUPS_FILE_CONTENT);

var matchesGroups = context.CakeContext.FindRegexMatchesGroupsInFile (GROUPS_FILE, GROUPS_PATTERN, RegexOptions.None);

Assert.IsNotNull (matchesGroups);
Assert.AreEqual (matchesGroups.Count, 6);
Assert.NotNull (matchesGroups);
Assert.Equal (6, matchesGroups.Count);

foreach (var g in matchesGroups)
Assert.AreEqual (g.Count, 3);
Assert.Equal (3, g.Count);
}

[Test]
[Fact]
public void FindRegexMatchGroupsInFile()
{
context.CakeContext.FileWriteText (GROUPS_FILE, GROUPS_FILE_CONTENT);

var matchGroups = context.CakeContext.FindRegexMatchGroupsInFile (GROUPS_FILE, GROUPS_PATTERN, RegexOptions.None);

Assert.IsNotNull (matchGroups);
Assert.AreEqual (matchGroups.Count, 3);
Assert.NotNull (matchGroups);
Assert.Equal (3, matchGroups.Count);
}

[Test]
[Fact]
public void FindRegexMatchGroupInFile ()
{
context.CakeContext.FileWriteText (GROUPS_FILE, GROUPS_FILE_CONTENT);

var matchGroup = context.CakeContext.FindRegexMatchGroupInFile (GROUPS_FILE, GROUPS_PATTERN, 2, RegexOptions.None);
var invalidMatchGroup = context.CakeContext.FindRegexMatchGroupInFile (GROUPS_FILE, GROUPS_PATTERN, 8, RegexOptions.None);

Assert.IsNotNull (matchGroup);
Assert.IsNull (invalidMatchGroup);
Assert.AreEqual (matchGroup.Value, "ello");
Assert.NotNull (matchGroup);
Assert.Null (invalidMatchGroup);
Assert.Equal ("ello", matchGroup.Value);
}

public const string PATTERN_FILE_BASE_VALUE = "The {0} makes great software.\nThis is not a surprise.";
Expand Down
36 changes: 0 additions & 36 deletions Cake.FileHelpers.Tests/Properties/AssemblyInfo.cs

This file was deleted.

13 changes: 13 additions & 0 deletions SolutionInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Cake.
// </auto-generated>
//------------------------------------------------------------------------------
using System.Reflection;

[assembly: AssemblyCompany("Cake Contributions")]
[assembly: AssemblyProduct("Cake.FileHelpers")]
[assembly: AssemblyVersion("0.0.0")]
[assembly: AssemblyFileVersion("0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0")]
[assembly: AssemblyCopyright("Copyright © Cake Contributions 2017 - Present")]
37 changes: 25 additions & 12 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
image: Visual Studio 2017
version: 2.0.{build}
configuration: Release
install:
- set NUGET_VERSION=%APPVEYOR_BUILD_VERSION%
#---------------------------------#
# Build Script #
#---------------------------------#
build_script:
- ps: .\build.ps1 -Target package
test:
assemblies:
- '**\*.Tests.dll'
artifacts:
- path: Cake.FileHelpers\bin\Release\*.nupkg
name: NuGet
- ps: .\build.ps1 -Script setup.cake -Target AppVeyor -Verbosity Diagnostic --settings_skipverification=true

# Tests
test: off

#---------------------------------#
# Branches to build #
#---------------------------------#
branches:
# Whitelist
only:
- develop
- master
- /release/.*/
- /hotfix/.*/

#---------------------------------#
# Build Cache #
#---------------------------------#
#cache:
#- packages -> Source\**\packages.config
#- tools -> setup.cake
Loading

0 comments on commit a83a935

Please sign in to comment.