Skip to content

Instantly share code, notes, and snippets.

$LinksCopy = Import-Clixml $Filename
public class Gnabber
{
public bool IsEvenNumber(int number)
{
return number % 2 == 0;
}
}
public class Tests
{
[Fact]
public void IsEvenNumber_WhenGivenAnEvenNumber_ItReturnsTrue()
{
var gna = new Gnabber();
Assert.True(gna.IsEvenNumber(42));
}
[Fact]
function IsEvenNumber($number) {
return $number % 2 -eq 0
}
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"
Describe "IsEvenNumber" {
Context "When an even number is passed to the function" {
$result = IsEvenNumber(42)
It "Returns true" {
using System;
using System.IO;
using System.Linq;
using Moq;
using Xunit;
namespace CSharpSample
{
public interface IDirectory
{
function HasEntryInDirectory($filename, $path) {
$entries = Get-ChildItem -Path $path
$entries -contains $filename
}
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"
$mockReply = @("Monday.txt", "Tuesday.txt", "Wednesday.txt")
Describe "HasEntryInDirectory" {
Context "If the filename exists in the directory" {
Mock Get-ChildItem {return $mockReply}
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"
$mockReply = @("Monday.txt", "Tuesday.txt", "Wednesday.txt")
Describe "HasEntryInDirectory" {
Context "If the filename exists in the directory" {
Mock Get-ChildItem {return $mockReply}
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"
$mockReply = @("Monday.txt", "Tuesday.txt", "Wednesday.txt")
Describe "HasEntryInDirectory" {
Context "If the filename exists in the directory" {
Mock Get-ChildItem {return $mockReply}