/*Program.cs*/
using System;
using System.Collections.Generic;
using System.Text;
namespace CalcApplication
{
class Program
{
static void Main( string[] args )
{
}
}
}
/*Calc.cs*/
namespace CalcApplication
{
// 四則演算クラス
public class Calc
{
// 足し算
public int Add( int v1, int v2 )
{
return v1 + v2;
}
// 引き算
public int Subtract( int v1, int v2 )
{
return v1 - v2;
}
// 掛け算
public int Multipty( int v1, int v2 )
{
return v1 * v2;
}
// 割り算
public int Divide( int v1, int v2 )
{
return ( ( v2 == 0 ) ? 0 : ( v1 / v2 ) );
}
}
}
/*TestCalc.cs*/
using System;
using CalcApplication;
using NUnit.Framework;
namespace TestFirst
{
[TestFixture]
public class TestCalc
{
[SetUp]
protected void SetUp()
{
}
[Test]
public void TestAdd()
{
Calc calc = new Calc();
Assert.AreEqual( calc.Add( 2, 3 ), 5 );
}
[Test]
public void TestSub()
{
Calc calc = new Calc();
Assert.AreEqual( calc.Subtract( 2, 3 ), -1 );
}
[Test]
public void TestMul()
{
Calc calc = new Calc();
Assert.AreEqual( calc.Multipty( 2, 3 ), 6 );
}
[Test]
public void TestDiv()
{
Calc calc = new Calc();
Assert.AreEqual( calc.Divide( 6, 3 ), 2 );
}
}
}
最終更新:2008年09月21日 21:27