The refactoring is now published as Slice on sammancoaching.org: https://sammancoaching.org/refactorings/slice.html - git mv ideas/split-loop-with-lambda -> ideas/slice-with-lambda - rename learning-hour file and update frontmatter name - update paths in tools/rehearse scripts and report title - update prose: 'Split Loop with Lambda' -> 'Slice with Lambda' in learning hour, exercise READMEs, storyboard, solution comments - link the published Slice refactoring from the pattern draft
21 lines
659 B
C#
21 lines
659 B
C#
using IceCreamBuyers;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using System.Collections.Generic;
|
|
|
|
namespace IceCreamBuyers.Tests
|
|
{
|
|
[TestClass]
|
|
public class BuyersTests
|
|
{
|
|
[TestMethod]
|
|
public void ShoppingListTotalUsesThePricingWePassIn()
|
|
{
|
|
// pure pricing function: everything costs 2.
|
|
// Anke: 2 flavours x 2 scoops x 2 = 8 — deterministic, glanceable.
|
|
var buyers = new Buyers();
|
|
var anke = new Buyer("Anke", new List<IceCream> { IceCream.Strawberry, IceCream.Vanilla });
|
|
Assert.AreEqual(8, buyers.ShoppingListTotal(anke, _ => 2));
|
|
}
|
|
}
|
|
}
|