You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.4 KiB
61 lines
1.4 KiB
using System;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using SyncTaskStatus.Logger;
|
|
using Microsoft.QualityTools.Testing.Fakes;
|
|
|
|
namespace UnitTest
|
|
{
|
|
[TestClass]
|
|
public class UnitTestExample
|
|
{
|
|
[TestMethod]
|
|
public void TestMethod1()
|
|
{
|
|
Bank b = new Bank();
|
|
|
|
int y = b.Calculate(5, 6);
|
|
|
|
Assert.AreEqual(40, y, "sdfsdf");
|
|
}
|
|
|
|
[TestMethod]
|
|
[ExpectedException(typeof(Exception))]
|
|
public void TestMethod2()
|
|
{
|
|
Bank b = new Bank();
|
|
|
|
int y = b.Calculate(3, 6);
|
|
|
|
//Assert.AreEqual(100, y, "sdfsdf");
|
|
}
|
|
[TestMethod]
|
|
public void TestMethod3()
|
|
{
|
|
Bank b = new Bank();
|
|
|
|
IBank bk = new SyncTaskStatus.Logger.Fakes.StubIBank()
|
|
{
|
|
GetTotalMoney = () => { return 15000; }
|
|
};
|
|
int total = b.GetAllMoney(bk);
|
|
Assert.AreEqual(15000, total);
|
|
|
|
//Assert.AreEqual(100, y, "sdfsdf");
|
|
}
|
|
[TestMethod]
|
|
public void TestMethod4()
|
|
{
|
|
using (ShimsContext.Create())
|
|
{
|
|
System.Fakes.ShimDateTime.NowGet = () => { return new DateTime(2000, 1, 1); };
|
|
Bank b = new Bank();
|
|
Assert.AreEqual(1000, b.GetTheCurrentYear());
|
|
};
|
|
|
|
//Assert.AreEqual(100, y, "sdfsdf");
|
|
}
|
|
}
|
|
|
|
}
|
|
|