Last active
October 18, 2015 07:11
-
-
Save wellwind/a8aed96b88d634caf78e to your computer and use it in GitHub Desktop.
SkillTree TDD Homework - Day1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
寫得很好,又快又準!