Files
learning-hour-maker/ideas/split-loop-with-lambda/exercise3/solution/test/BuyersTests.cs
T
Your Name 1189041d8e Add exercise 3 (Buyers, C#): the pure extract-lambda rep
New in-theme classes: Buyers computes a shopping-list total, PriceList
stands for the pricing service (random surge, flaky test). One loop, one
lambda-able expression — the third example teaches the move with nothing
else in the way. Pristine repo + reference solution (extract lambda,
slide, extract method with Func<IceCream,int> parameter, pure-lambda
test) + storyboard in the established style. Mirrors the kata's C#
setup (net7.0, MSTest); needs a build check on a machine with the SDK.
2026-09-28 21:48:30 +00:00

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));
}
}
}