Monday, April 23, 2007

test class for baseball program MyProject

// The following code was generated by Microsoft Visual Studio 2005.
// The test owner should check each test for validity.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Text;
using System.Collections.Generic;
using MyProject;
namespace TestMyProject
{
///
///This is a test class for MyProject.Form1 and is intended
///to contain all MyProject.Form1 Unit Tests
///

[TestClass()]
public class Form1Test
{


private TestContext testContextInstance;

///
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///

public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#region Additional test attributes
//
//You can use the following additional attributes as you write your tests:
//
//Use ClassInitialize to run code before running the first test in the class
//
//[ClassInitialize()]
//public static void MyClassInitialize(TestContext testContext)
//{
//}
//
//Use ClassCleanup to run code after all tests in a class have run
//
//[ClassCleanup()]
//public static void MyClassCleanup()
//{
//}
//
//Use TestInitialize to run code before running each test
//
//[TestInitialize()]
//public void MyTestInitialize()
//{
//}
//
//Use TestCleanup to run code after each test has run
//
//[TestCleanup()]
//public void MyTestCleanup()
//{
//}
//
#endregion


///
///A test for Form1 ()
///

[TestMethod()]
public void ConstructorTest()
{
Form1 target = new Form1();

// TODO: Implement code to verify target
Assert.AreEqual(target.Basepath.Count, 3);
}


///
///A test for oneBagger ()
///

[TestMethod()]
public void oneBaggerTest()
{
Form1 target = new Form1();

target.oneBagger();

Assert.AreEqual(target.Basepath.Pop(), 1);

Assert.AreEqual(target.Basepath.Pop(), 0);


}

///
///A test for twoBagger ()
///

[TestMethod()]
public void twoBaggerTest()
{
Form1 target = new Form1();

target.oneBagger();

target.twoBagger();

Assert.AreEqual(target.Basepath.Count, 8);
}

///
///A test for threeBagger ()
///

[TestMethod()]
public void threeBaggerTest()
{
Form1 target = new Form1();
target.oneBagger();
target.twoBagger();
target.threeBagger();


Assert.AreEqual(target.Basepath.Count, 11);

Assert.AreEqual(target.Basepath.Pop(), 0);

Assert.AreEqual(target.Basepath.Pop(), 0);

Assert.AreEqual(target.Basepath.Pop(), 1);




}

///
///A test for homer ()
///

[TestMethod()]
public void homerTest()
{
Form1 target = new Form1();

target.homer();

Assert.AreEqual(target.Basepath.Count, 7);

Assert.AreEqual(target.Basepath.Pop(), 0);

Assert.AreEqual(target.Basepath.Pop(), 0);

Assert.AreEqual(target.Basepath.Pop(), 0);


}

///
///A test for walk ()
///

[TestMethod()]
public void walkTest()
{
Form1 target = new Form1();

target.threeBagger();
target.walk();
Assert.AreEqual(target.Basepath.Count, 6);
target.walk();
Assert.AreEqual(target.Basepath.Count, 6);
target.walk();
Assert.AreEqual(target.Basepath.Count, 7);

}

///
///A test for addRuns ()
///

[TestMethod()]
public void addRunsTest()
{
Form1 target = new Form1();



target.threeBagger();
target.walk();
Assert.AreEqual(target.Basepath.Count, 6);
target.walk();
Assert.AreEqual(target.Basepath.Count, 6);
target.walk();
Assert.AreEqual(target.Basepath.Count, 7);

target.twoBagger();

target.addRuns();



Assert.AreEqual(target.Runs, 4);
}

///
///A test for strikeout ()
///

[TestMethod()]
public void strikeoutTest()
{
Form1 target = new Form1();

target.strikeout();
target.strikeout();
target.walk();
target.walk();
target.walk();
target.strikeout();
target.homer();
target.strikeout();
target.strikeout();



target.addRuns();



Assert.AreEqual(target.Runs, 1);




}

///
///A test for bat ()
///

[TestMethod()]
public void batTest()
{
Form1 target = new Form1();

for (int i = 0; i < 28; i++ )
target.bat();

target.addRuns();

Assert.IsTrue(target.Runs < 21);
Assert.IsTrue(target.Runs >= 0);


}
}


}

0 Comments:

Post a Comment

<< Home