Skip to content

Instantly share code, notes, and snippets.

@mahasak
Forked from pseudomuto/Feature.cs
Created March 16, 2017 17:20
Show Gist options
  • Save mahasak/eaf0b7dd7f2e23abfa1017880d776f9e to your computer and use it in GitHub Desktop.
Save mahasak/eaf0b7dd7f2e23abfa1017880d776f9e to your computer and use it in GitHub Desktop.
Blog Code: Continuous Integration for .NET with Travis and xUnit

Travis CI Demo

Build Status

A demonstration of using Travis CI with .NET

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CI.Demo
{
public class Feature
{
public string Name { get; private set; }
public Feature(string name)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException("name");
}
this.Name = name.ToLower();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using Should.Core;
using Should.Fluent;
namespace CI.Demo.Tests
{
public class Feature
{
public class Constructor
{
[Fact]
public void ValidatesNameIsNotNull()
{
Assert.Throws(() =>
{
new Demo.Feature(null);
});
}
[Fact]
public void ValidatesNameIsNotEmpty()
{
Assert.Throws(() =>
{
new Demo.Feature("");
});
}
[Fact]
public void StoresTheNameInLowercase()
{
var subject = new Demo.Feature("My UPPERcase Feature");
subject.Name.Should().Equal("my uppercase feature");
}
}
}
}
language: c
before_install:
- sudo apt-get update -qq > /dev/null
- sudo apt-get install -qq mono-devel mono-gmcs > /dev/null
- mozroots --import --sync
- mv -f src/.nuget/NuGet.mono.targets src/.nuget/NuGet.targets
- chmod +x lib/xunit/xunit.console.clr4.x86.exe
- export EnableNuGetPackageRestore=true
script:
- cd src/
- xbuild CI\ Demo.sln
- mono ../lib/xunit/xunit.console.clr4.x86.exe CI.Demo.Tests/bin/Debug/CI.Demo.Tests.dll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment