Skip to content

Commit

Permalink
Added ControlStructureKihon to the project
Browse files Browse the repository at this point in the history
  • Loading branch information
trayburn committed Jan 22, 2011
1 parent fc04af1 commit 410c169
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/Squire/ControlStructureKihon.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Squire.Framework;
using System.Collections.Generic;

namespace Squire
{
[TestClass]
public class ControlStructureKihon : ControlStructuresKihonStructure
{

protected override void Call_Hit_On_a_If_val_Is_True_Else_Call_Hit_On_b(bool val, ITarget a, ITarget b)
{
throw new NotImplementedException();
}

protected override void Call_Hit_On_a_Once_For_Each_Member_Of_list(ITarget a, List<string> list)
{
throw new NotImplementedException();
}

protected override void Call_Hit_On_a_While_a_IsValid_Is_True(ITarget a)
{
throw new NotImplementedException();
}

protected override void n_Times_Call_Hit_On_a(int n, ITarget a)
{
throw new NotImplementedException();
}

protected override void Call_Hit_On_a_Once_And_Continue_Until_IsValid_Is_False(ITarget a)
{
throw new NotImplementedException();
}
}
}
47 changes: 47 additions & 0 deletions src/Squire/Framework/ControlStructuresKihonStructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,55 @@ public void Call_Hit_On_a_Once_For_Each_Member_Of_list()
a.AssertWasCalled(m => m.Hit(), mo => mo.Repeat.Times(4));
}

[TestMethod]
public void Call_Hit_On_a_While_a_IsValid_Is_True()
{
// Arrange
var a = MockRepository.GenerateMock<ITarget>();
a.Stub(m => m.IsValid).Return(true).Repeat.Times(4);
a.Stub(m => m.IsValid).Return(false).Repeat.Times(1);

// Act
Call_Hit_On_a_While_a_IsValid_Is_True(a);

// Assert
a.AssertWasCalled(m => m.Hit(), mo => mo.Repeat.Times(4));
}

[TestMethod]
public void n_Times_Call_Hit_On_a()
{
// Arrange
var a = MockRepository.GenerateMock<ITarget>();
var n = 132;

// Act
n_Times_Call_Hit_On_a(n, a);

// Assert
a.AssertWasCalled(m => m.Hit(), mo => mo.Repeat.Times(n));
}

[TestMethod]
public void Call_Hit_On_a_Once_And_Continue_Until_IsValid_Is_False()
{
// Arrange
var a = MockRepository.GenerateMock<ITarget>();
a.Stub(m => m.IsValid).Return(true).Repeat.Times(4);
a.Stub(m => m.IsValid).Return(false).Repeat.Times(1);

// Act
Call_Hit_On_a_Once_And_Continue_Until_IsValid_Is_False(a);

// Assert
a.AssertWasCalled(m => m.Hit(), mo => mo.Repeat.Times(5));
}

protected abstract void Call_Hit_On_a_If_val_Is_True_Else_Call_Hit_On_b(bool val, ITarget a, ITarget b);
protected abstract void Call_Hit_On_a_Once_For_Each_Member_Of_list(ITarget a, List<System.String> list);
protected abstract void Call_Hit_On_a_While_a_IsValid_Is_True(ITarget a);
protected abstract void n_Times_Call_Hit_On_a(int n, ITarget a);
protected abstract void Call_Hit_On_a_Once_And_Continue_Until_IsValid_Is_False(ITarget a);

}
}
1 change: 1 addition & 0 deletions src/Squire/Squire.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ConsoleKihon.cs" />
<Compile Include="ControlStructureKihon.cs" />
<Compile Include="Framework\Abstractions\IConsoleWrapper.cs" />
<Compile Include="Framework\BaseKihon.cs" />
<Compile Include="Framework\ConsoleKihonStructure.cs" />
Expand Down

0 comments on commit 410c169

Please sign in to comment.