mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 06:21:29 +00:00
Also updated unit tests: - Added unit tests for the new ItemBuilders classes - Refactored existing tests to use the new builders
24 lines
582 B
C#
24 lines
582 B
C#
using System;
|
|
|
|
namespace GildedRoseKata;
|
|
|
|
public class ItemBuilder(string name, int sellIn, int quality) : AbstractItemBuilder(name, sellIn, quality)
|
|
{
|
|
public override Item Build()
|
|
{
|
|
if (Quality < ItemQuality.MinQuality || Quality > ItemQuality.MaxQuality)
|
|
{
|
|
throw new ArgumentException("An item's quality must be >=0 and <=50");
|
|
}
|
|
|
|
if (ItemType.IsLegendaryItem(Name))
|
|
{
|
|
throw new ArgumentException("Legendary Items cannot be constructed using this builder");
|
|
}
|
|
|
|
return base.Build();
|
|
}
|
|
}
|
|
|
|
|