A demonstration of using Travis CI with .NET
-
-
Save mahasak/eaf0b7dd7f2e23abfa1017880d776f9e to your computer and use it in GitHub Desktop.
Blog Code: Continuous Integration for .NET with Travis and xUnit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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