Skip to content

Commit

Permalink
Added Numbers Kihon
Browse files Browse the repository at this point in the history
  • Loading branch information
trayburn committed Jan 22, 2011
1 parent 410c169 commit 1bc14b8
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/Squire/ControlStructureKihon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ namespace Squire
[TestClass]
public class ControlStructureKihon : ControlStructuresKihonStructure
{

/*
* This Kihon uses ITarget extensively. It has a method called Hit() and
* a property called IsValid. So "Call_Hit_On_a" means "a.Hit();"
*/
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();
Expand All @@ -29,7 +32,7 @@ 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)
protected override void Call_Hit_On_a_Once_And_Loop_Until_IsValid_Is_False(ITarget a)
{
throw new NotImplementedException();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Squire/Framework/ControlStructuresKihonStructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void Call_Hit_On_a_Once_And_Continue_Until_IsValid_Is_False()
a.Stub(m => m.IsValid).Return(false).Repeat.Times(1);

// Act
Call_Hit_On_a_Once_And_Continue_Until_IsValid_Is_False(a);
Call_Hit_On_a_Once_And_Loop_Until_IsValid_Is_False(a);

// Assert
a.AssertWasCalled(m => m.Hit(), mo => mo.Repeat.Times(5));
Expand All @@ -108,7 +108,7 @@ public void Call_Hit_On_a_Once_And_Continue_Until_IsValid_Is_False()
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);
protected abstract void Call_Hit_On_a_Once_And_Loop_Until_IsValid_Is_False(ITarget a);

}
}
161 changes: 161 additions & 0 deletions src/Squire/Framework/NumbersKihonStructure.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Squire.Framework
{
[TestClass]
public abstract class NumbersKihonStructure : BaseKihon
{
[TestMethod]
public void Return_The_Maximum_Value_Of_Int32_Test()
{
// Arrange


// Act
int result = Return_The_Maximum_Value_Of_Int32();

// Assert
Assert.AreEqual(Int32.MaxValue, result);
}

[TestMethod]
public void Return_The_Minimum_Value_Of_Int32_Test()
{
// Arrange


// Act
int result = Return_The_Minimum_Value_Of_Int32();

// Assert
Assert.AreEqual(int.MinValue, result);
}

[TestMethod]
public void Return_The_Remainder_Of_a_Divided_By_b()
{
// Arrange
int a = 251;
int b = 25;

// Act
int remainder = Return_The_Remainder_Of_a_Divided_By_b(a, b);

// Assert
Assert.AreEqual(a % b, remainder);
}

[TestMethod]
public void Return_The_Maximum_Value_Of_Double_Test()
{
// Arrange


// Act
double actual = Return_The_Maximum_Value_Of_Double();

// Assert
Assert.AreEqual(double.MaxValue, actual);
}

[TestMethod]
public void Return_The_Minimum_Value_Of_Double_Test()
{
// Arrange


// Act
double actual = Return_The_Minimum_Value_Of_Double();

// Assert
Assert.AreEqual(double.MinValue, actual);
}

[TestMethod]
public void Return_True_If_a_Is_Not_A_Number_Test1()
{
// Arrange
double a = 1.24;

// Act
var result = Return_True_If_a_Is_Not_A_Number(a);

// Assert
Assert.AreEqual(double.IsNaN(a), result);
}

[TestMethod]
public void Return_True_If_a_Is_Not_A_Number_Test2()
{
// Arrange
double a = double.NegativeInfinity;

// Act
var result = Return_True_If_a_Is_Not_A_Number(a);

// Assert
Assert.AreEqual(double.IsNaN(a), result);
}

[TestMethod]
public void Return_True_If_a_Is_Not_A_Number_Test3()
{
// Arrange
double a = double.NaN;

// Act
var result = Return_True_If_a_Is_Not_A_Number(a);

// Assert
Assert.AreEqual(double.IsNaN(a), result);
}

[TestMethod]
public void Return_True_If_a_Is_An_Infinity_Test1()
{
// Arrange
double a = 1.24;

// Act
var actual = Return_True_If_a_Is_An_Infinity(a);

// Assert
Assert.AreEqual(double.IsInfinity(a), actual);
}

[TestMethod]
public void Return_True_If_a_Is_An_Infinity_Test2()
{
// Arrange
double a = double.NegativeInfinity;

// Act
var actual = Return_True_If_a_Is_An_Infinity(a);

// Assert
Assert.AreEqual(double.IsInfinity(a), actual);
}

[TestMethod]
public void Return_True_If_a_Is_An_Infinity_Test3()
{
// Arrange
double a = double.PositiveInfinity;

// Act
var actual = Return_True_If_a_Is_An_Infinity(a);

// Assert
Assert.AreEqual(double.IsInfinity(a), actual);
}

protected abstract int Return_The_Maximum_Value_Of_Int32();
protected abstract int Return_The_Minimum_Value_Of_Int32();
protected abstract int Return_The_Remainder_Of_a_Divided_By_b(int a, int b);
protected abstract double Return_The_Maximum_Value_Of_Double();
protected abstract double Return_The_Minimum_Value_Of_Double();
protected abstract bool Return_True_If_a_Is_Not_A_Number(double a);
protected abstract bool Return_True_If_a_Is_An_Infinity(double a);
}
}
45 changes: 45 additions & 0 deletions src/Squire/NumbersKihon.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Squire.Framework;

namespace Squire
{
[TestClass]
public class NumbersKihon : NumbersKihonStructure
{
protected override int Return_The_Maximum_Value_Of_Int32()
{
throw new NotImplementedException();
}

protected override int Return_The_Minimum_Value_Of_Int32()
{
throw new NotImplementedException();
}

protected override int Return_The_Remainder_Of_a_Divided_By_b(int a, int b)
{
throw new NotImplementedException();
}

protected override double Return_The_Maximum_Value_Of_Double()
{
throw new NotImplementedException();
}

protected override double Return_The_Minimum_Value_Of_Double()
{
throw new NotImplementedException();
}

protected override bool Return_True_If_a_Is_Not_A_Number(double a)
{
throw new NotImplementedException();
}

protected override bool Return_True_If_a_Is_An_Infinity(double a)
{
throw new NotImplementedException();
}
}
}
2 changes: 2 additions & 0 deletions src/Squire/Squire.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
<Compile Include="Framework\BaseKihon.cs" />
<Compile Include="Framework\ConsoleKihonStructure.cs" />
<Compile Include="Framework\ControlStructuresKihonStructure.cs" />
<Compile Include="Framework\NumbersKihonStructure.cs" />
<Compile Include="Framework\StringKihonStructure.cs" />
<Compile Include="NumbersKihon.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StringKihon.cs" />
</ItemGroup>
Expand Down

0 comments on commit 1bc14b8

Please sign in to comment.