Skip to content

Instantly share code, notes, and snippets.

@wellwind
Last active October 18, 2015 07:11
Show Gist options
  • Save wellwind/a8aed96b88d634caf78e to your computer and use it in GitHub Desktop.
Save wellwind/a8aed96b88d634caf78e to your computer and use it in GitHub Desktop.
SkillTree TDD Homework - Day1
[TestClass]
public class GroupPagingServiceTests
{
[TestMethod]
public void GroupPagingServiceTest_驗證以3筆資料為一組時的Cost總和()
{
// 1. arrange
var pageSize = 3;
var fieldToSum = "Cost";
// 用假資料的資料來源注入
IProductRepository productRepositoryStub = new ProductRepositoryStub();
var target = new GroupPagingService(productRepositoryStub);
var expected = new [] {6, 15, 24, 21};
// 2. act
var actual = target.GetFieldSumOfPaging(pageSize, fieldToSum);
// 3. assert
CollectionAssert.AreEqual(expected, actual);
}
[TestMethod]
public void GroupPagingServiceTest_驗證以4筆資料為一組時的Revenue總和()
{
// 1. arrange
var pageSize = 4;
var fieldToSum = "Revenue";
// 用假資料的資料來源注入
IProductRepository productRepositoryStub = new ProductRepositoryStub();
var target = new GroupPagingService(productRepositoryStub);
var expected = new [] {50, 66, 60};
// 2. act
var actual = target.GetFieldSumOfPaging(pageSize, fieldToSum);
// 3. assert
CollectionAssert.AreEqual(expected, actual);
}
}
@hatelove
Copy link

寫得很好,又快又準!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment