mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 14:31:28 +00:00
Add new Conjured Items requirement and related tests
Also added some final notes on this solution and suggestions for further changes if we can change Item
This commit is contained in:
parent
ed1ef9153b
commit
bdf20e735c
@ -25,6 +25,11 @@ public class DailyUpdaterFactory
|
|||||||
return GetOrCreateDailyUpdater(ItemType.ItemKey.BackstagePasses, () => new DailyUpdaterForBackstagePassesItems());
|
return GetOrCreateDailyUpdater(ItemType.ItemKey.BackstagePasses, () => new DailyUpdaterForBackstagePassesItems());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ItemType.IsConjuredItem(item))
|
||||||
|
{
|
||||||
|
return GetOrCreateDailyUpdater(ItemType.ItemKey.Conjured, () => new DailyUpdaterForConjuredItems());
|
||||||
|
}
|
||||||
|
|
||||||
return GetOrCreateDailyUpdater(ItemType.ItemKey.Regular, () => new DailyUpdaterForRegularItems());
|
return GetOrCreateDailyUpdater(ItemType.ItemKey.Regular, () => new DailyUpdaterForRegularItems());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
9
csharpcore/GildedRose/DailyUpdaterForConjuredItems.cs
Normal file
9
csharpcore/GildedRose/DailyUpdaterForConjuredItems.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace GildedRoseKata;
|
||||||
|
|
||||||
|
public class DailyUpdaterForConjuredItems : DailyUpdater
|
||||||
|
{
|
||||||
|
public override void UpdateQuality(Item item)
|
||||||
|
{
|
||||||
|
DecreaseQuality(item, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -7,7 +7,8 @@ public static class ItemType
|
|||||||
Regular,
|
Regular,
|
||||||
Legendary,
|
Legendary,
|
||||||
BetterWithAge,
|
BetterWithAge,
|
||||||
BackstagePasses
|
BackstagePasses,
|
||||||
|
Conjured
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsLegendaryItem(Item item) => IsLegendaryItem(item.Name);
|
public static bool IsLegendaryItem(Item item) => IsLegendaryItem(item.Name);
|
||||||
@ -17,4 +18,5 @@ public static class ItemType
|
|||||||
|
|
||||||
public static bool IsBetterWithAgeItem(Item item) => item.Name.ToLower().Equals("aged brie");
|
public static bool IsBetterWithAgeItem(Item item) => item.Name.ToLower().Equals("aged brie");
|
||||||
|
|
||||||
|
public static bool IsConjuredItem(Item item) => item.Name.ToLower().Contains("conjured");
|
||||||
}
|
}
|
||||||
@ -14,7 +14,7 @@ I decorated these tests with `[Ignore]` until I get to a stage in the refactorin
|
|||||||
3. Extract Increasing/Decreasing Quality into a method.<br>
|
3. Extract Increasing/Decreasing Quality into a method.<br>
|
||||||
4. Separated the processing of the different types from each other.<br>
|
4. Separated the processing of the different types from each other.<br>
|
||||||
5. Used the `Template` design pattern to create DailyUpdater abstract class and derived classes to handle the DailyUpdate's steps for the different types of items.<br>
|
5. Used the `Template` design pattern to create DailyUpdater abstract class and derived classes to handle the DailyUpdate's steps for the different types of items.<br>
|
||||||
The different derived classes will be moved to their own files in the next PR. Left them together for now to show the steps.
|
The different derived classes will be moved to their own files in the future. Left them together for now to show the steps.
|
||||||
6. Created a `Simple Factory` method to return the appropriate DailyUpdater object for the item type.<br>
|
6. Created a `Simple Factory` method to return the appropriate DailyUpdater object for the item type.<br>
|
||||||
7. Moved DailyUpdaterFactory to its own class.
|
7. Moved DailyUpdaterFactory to its own class.
|
||||||
8. Moved the logic of "Once the sell by date has passed, Quality degrades twice as fast" into the DailyUpdater Template class since it's relevant to all types of items.
|
8. Moved the logic of "Once the sell by date has passed, Quality degrades twice as fast" into the DailyUpdater Template class since it's relevant to all types of items.
|
||||||
@ -27,16 +27,29 @@ However, I've chosen to use the factory itself to manually manage it using a sem
|
|||||||
Now, adding a new updater won't have to change the existing DailyUpdater file.
|
Now, adding a new updater won't have to change the existing DailyUpdater file.
|
||||||
13. Added a new ItemBuilders hierarchy to enforce building valid items (quality limits and special rules for Legendary items). Also added unit tests and refactored the existing tests to use the new builders.<br>
|
13. Added a new ItemBuilders hierarchy to enforce building valid items (quality limits and special rules for Legendary items). Also added unit tests and refactored the existing tests to use the new builders.<br>
|
||||||
note: if we could change Item, this could have been implemented in the Item's constructor itself and by using Quality TinyType. However, since we can't change Item, the builders gives us a nice decoupled way to validate the items are constructed consistently.
|
note: if we could change Item, this could have been implemented in the Item's constructor itself and by using Quality TinyType. However, since we can't change Item, the builders gives us a nice decoupled way to validate the items are constructed consistently.
|
||||||
|
14. Added the new Conjured items requirements. Due to the previous refactorings above, I only needed to change the following files/classes:
|
||||||
|
- `ItemType` to add the new type enum and definition
|
||||||
|
- Add a new `DailyUpdaterForConjuredItems` updater to handle the new type's requirements
|
||||||
|
- `DailyUpdaterFactory` to create and return the new updater<br>
|
||||||
|
Note that I didn't need to change the client's code (GildedRose) or any of the other items types code.
|
||||||
|
|
||||||
|
|
||||||
|
## Final solution
|
||||||
This is the state of the code now
|
- Used `Template` pattern in `DailyUpdater` hierarcy to support the general `DailyUpdate` template and allow each derived class (per item type) to implement their own `UpdateQuality` algorithm.
|
||||||
|
- _Why_: instead of using a lot of if-else statements, every item type implement its own unique processing and the shared processing exist in the base Template class. When adding new item types, we can just add a new updater class without having to change the Template or any of the other updaters' code
|
||||||
|
- Used a `Simple Factory` to rturn the correct Updater for a given item (type).
|
||||||
### Considered but dropped
|
- _Why_: Move the knowledge about the different types of items away from the client code (GildedRose.cs) so it only relies on the abstract factory to return the correct updater for every item. When adding new item types, the client code will not have to change.
|
||||||
This is all the design ideas/patterns I've considered but decided against
|
- Used `semi-Flyweight` pattern to re-use the existing updaters instead of creating new ones over and over again. Note: In this instance, we could have used a dependency injection framework instead.
|
||||||
- It feels like Quality should have been a `TinyType` that manages its own limits. However, since we're not allowed to change Item I'm not implementing this.
|
- _Why_: this one in not critical. However it seemed wasteful to create new updaters over and over again when they don't have any unique (extrinsic) properties and can use just one updater of each type instead.
|
||||||
-
|
- Used a `Builder` pattern to enforce building valid items.
|
||||||
|
- _Why_: to prevent building items the violate the requirement. Specifically to enforce the quality limits and the legacy items special quality value.
|
||||||
|
|
||||||
|
|
||||||
|
## Suggested Improvements if we could change anything
|
||||||
|
The used solution is good in general, I would probably do the following changes as well:
|
||||||
|
- Define `Quality` as a TinyType that protects its limits and derive `LegendaryQuality` class to support the legendary items special quality rules.
|
||||||
|
- Add properties to Item:
|
||||||
|
- Type - use enum to define the type. This will allow better seperation between the name of the item and its type and will make the rest of our processing easier and more readable.
|
||||||
|
- Updater - a rference to the item's updater that can be created in the constructor depending on the item's type (usign the simple factory). From then on, this can be called directly on the item. This will use a `semi-Strategy` pattern in combination with the `Template` pattern in that the updater behaviour is being plugged into the objects.
|
||||||
|
- the `Builder` might be redundant now that the items can enforce their own valid creation.
|
||||||
|
- Instead of using the `Flywieght` pattern, I would probably use a dependency injection framework to manage the creation of the updaters.
|
||||||
@ -18,7 +18,7 @@ public class ApprovalTest
|
|||||||
TextTestFixture.Main(new string[] { "30" });
|
TextTestFixture.Main(new string[] { "30" });
|
||||||
var output = fakeOutput.ToString();
|
var output = fakeOutput.ToString();
|
||||||
|
|
||||||
var expectedOutput = File.ReadAllText(@"C:\MyFiles\Training\GildedRose-Refactoring-Kata\csharpcore\GildedRoseTests\ExpectedApprovalTestOutput_WithoutConjured.txt");
|
var expectedOutput = File.ReadAllText(@"C:\MyFiles\Training\GildedRose-Refactoring-Kata\csharpcore\GildedRoseTests\ExpectedApprovalTestOutput_WithConjured.txt");
|
||||||
expectedOutput.Should().Be(output);
|
expectedOutput.Should().Be(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,373 @@
|
|||||||
|
OMGHAI!
|
||||||
|
-------- day 0 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, 10, 20
|
||||||
|
Aged Brie, 2, 0
|
||||||
|
Elixir of the Mongoose, 5, 7
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 15, 20
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 10, 49
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 5, 49
|
||||||
|
Conjured Mana Cake, 3, 12
|
||||||
|
|
||||||
|
-------- day 1 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, 9, 19
|
||||||
|
Aged Brie, 1, 1
|
||||||
|
Elixir of the Mongoose, 4, 6
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 14, 21
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 9, 50
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 4, 50
|
||||||
|
Conjured Mana Cake, 2, 10
|
||||||
|
|
||||||
|
-------- day 2 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, 8, 18
|
||||||
|
Aged Brie, 0, 2
|
||||||
|
Elixir of the Mongoose, 3, 5
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 13, 22
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 8, 50
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 3, 50
|
||||||
|
Conjured Mana Cake, 1, 8
|
||||||
|
|
||||||
|
-------- day 3 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, 7, 17
|
||||||
|
Aged Brie, -1, 4
|
||||||
|
Elixir of the Mongoose, 2, 4
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 12, 23
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 7, 50
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 2, 50
|
||||||
|
Conjured Mana Cake, 0, 6
|
||||||
|
|
||||||
|
-------- day 4 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, 6, 16
|
||||||
|
Aged Brie, -2, 6
|
||||||
|
Elixir of the Mongoose, 1, 3
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 11, 24
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 6, 50
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 1, 50
|
||||||
|
Conjured Mana Cake, -1, 2
|
||||||
|
|
||||||
|
-------- day 5 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, 5, 15
|
||||||
|
Aged Brie, -3, 8
|
||||||
|
Elixir of the Mongoose, 0, 2
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 10, 25
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 5, 50
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 0, 50
|
||||||
|
Conjured Mana Cake, -2, 0
|
||||||
|
|
||||||
|
-------- day 6 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, 4, 14
|
||||||
|
Aged Brie, -4, 10
|
||||||
|
Elixir of the Mongoose, -1, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 9, 27
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 4, 50
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -1, 0
|
||||||
|
Conjured Mana Cake, -3, 0
|
||||||
|
|
||||||
|
-------- day 7 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, 3, 13
|
||||||
|
Aged Brie, -5, 12
|
||||||
|
Elixir of the Mongoose, -2, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 8, 29
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 3, 50
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -2, 0
|
||||||
|
Conjured Mana Cake, -4, 0
|
||||||
|
|
||||||
|
-------- day 8 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, 2, 12
|
||||||
|
Aged Brie, -6, 14
|
||||||
|
Elixir of the Mongoose, -3, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 7, 31
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 2, 50
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -3, 0
|
||||||
|
Conjured Mana Cake, -5, 0
|
||||||
|
|
||||||
|
-------- day 9 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, 1, 11
|
||||||
|
Aged Brie, -7, 16
|
||||||
|
Elixir of the Mongoose, -4, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 6, 33
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 1, 50
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -4, 0
|
||||||
|
Conjured Mana Cake, -6, 0
|
||||||
|
|
||||||
|
-------- day 10 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, 0, 10
|
||||||
|
Aged Brie, -8, 18
|
||||||
|
Elixir of the Mongoose, -5, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 5, 35
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 0, 50
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -5, 0
|
||||||
|
Conjured Mana Cake, -7, 0
|
||||||
|
|
||||||
|
-------- day 11 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -1, 8
|
||||||
|
Aged Brie, -9, 20
|
||||||
|
Elixir of the Mongoose, -6, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 4, 38
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -1, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -6, 0
|
||||||
|
Conjured Mana Cake, -8, 0
|
||||||
|
|
||||||
|
-------- day 12 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -2, 6
|
||||||
|
Aged Brie, -10, 22
|
||||||
|
Elixir of the Mongoose, -7, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 3, 41
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -2, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -7, 0
|
||||||
|
Conjured Mana Cake, -9, 0
|
||||||
|
|
||||||
|
-------- day 13 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -3, 4
|
||||||
|
Aged Brie, -11, 24
|
||||||
|
Elixir of the Mongoose, -8, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 2, 44
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -3, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -8, 0
|
||||||
|
Conjured Mana Cake, -10, 0
|
||||||
|
|
||||||
|
-------- day 14 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -4, 2
|
||||||
|
Aged Brie, -12, 26
|
||||||
|
Elixir of the Mongoose, -9, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 1, 47
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -4, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -9, 0
|
||||||
|
Conjured Mana Cake, -11, 0
|
||||||
|
|
||||||
|
-------- day 15 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -5, 0
|
||||||
|
Aged Brie, -13, 28
|
||||||
|
Elixir of the Mongoose, -10, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, 0, 50
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -5, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -10, 0
|
||||||
|
Conjured Mana Cake, -12, 0
|
||||||
|
|
||||||
|
-------- day 16 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -6, 0
|
||||||
|
Aged Brie, -14, 30
|
||||||
|
Elixir of the Mongoose, -11, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -1, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -6, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -11, 0
|
||||||
|
Conjured Mana Cake, -13, 0
|
||||||
|
|
||||||
|
-------- day 17 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -7, 0
|
||||||
|
Aged Brie, -15, 32
|
||||||
|
Elixir of the Mongoose, -12, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -2, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -7, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -12, 0
|
||||||
|
Conjured Mana Cake, -14, 0
|
||||||
|
|
||||||
|
-------- day 18 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -8, 0
|
||||||
|
Aged Brie, -16, 34
|
||||||
|
Elixir of the Mongoose, -13, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -3, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -8, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -13, 0
|
||||||
|
Conjured Mana Cake, -15, 0
|
||||||
|
|
||||||
|
-------- day 19 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -9, 0
|
||||||
|
Aged Brie, -17, 36
|
||||||
|
Elixir of the Mongoose, -14, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -4, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -9, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -14, 0
|
||||||
|
Conjured Mana Cake, -16, 0
|
||||||
|
|
||||||
|
-------- day 20 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -10, 0
|
||||||
|
Aged Brie, -18, 38
|
||||||
|
Elixir of the Mongoose, -15, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -5, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -10, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -15, 0
|
||||||
|
Conjured Mana Cake, -17, 0
|
||||||
|
|
||||||
|
-------- day 21 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -11, 0
|
||||||
|
Aged Brie, -19, 40
|
||||||
|
Elixir of the Mongoose, -16, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -6, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -11, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -16, 0
|
||||||
|
Conjured Mana Cake, -18, 0
|
||||||
|
|
||||||
|
-------- day 22 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -12, 0
|
||||||
|
Aged Brie, -20, 42
|
||||||
|
Elixir of the Mongoose, -17, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -7, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -12, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -17, 0
|
||||||
|
Conjured Mana Cake, -19, 0
|
||||||
|
|
||||||
|
-------- day 23 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -13, 0
|
||||||
|
Aged Brie, -21, 44
|
||||||
|
Elixir of the Mongoose, -18, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -8, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -13, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -18, 0
|
||||||
|
Conjured Mana Cake, -20, 0
|
||||||
|
|
||||||
|
-------- day 24 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -14, 0
|
||||||
|
Aged Brie, -22, 46
|
||||||
|
Elixir of the Mongoose, -19, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -9, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -14, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -19, 0
|
||||||
|
Conjured Mana Cake, -21, 0
|
||||||
|
|
||||||
|
-------- day 25 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -15, 0
|
||||||
|
Aged Brie, -23, 48
|
||||||
|
Elixir of the Mongoose, -20, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -10, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -15, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -20, 0
|
||||||
|
Conjured Mana Cake, -22, 0
|
||||||
|
|
||||||
|
-------- day 26 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -16, 0
|
||||||
|
Aged Brie, -24, 50
|
||||||
|
Elixir of the Mongoose, -21, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -11, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -16, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -21, 0
|
||||||
|
Conjured Mana Cake, -23, 0
|
||||||
|
|
||||||
|
-------- day 27 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -17, 0
|
||||||
|
Aged Brie, -25, 50
|
||||||
|
Elixir of the Mongoose, -22, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -12, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -17, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -22, 0
|
||||||
|
Conjured Mana Cake, -24, 0
|
||||||
|
|
||||||
|
-------- day 28 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -18, 0
|
||||||
|
Aged Brie, -26, 50
|
||||||
|
Elixir of the Mongoose, -23, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -13, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -18, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -23, 0
|
||||||
|
Conjured Mana Cake, -25, 0
|
||||||
|
|
||||||
|
-------- day 29 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -19, 0
|
||||||
|
Aged Brie, -27, 50
|
||||||
|
Elixir of the Mongoose, -24, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -14, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -19, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -24, 0
|
||||||
|
Conjured Mana Cake, -26, 0
|
||||||
|
|
||||||
|
-------- day 30 --------
|
||||||
|
name, sellIn, quality
|
||||||
|
+5 Dexterity Vest, -20, 0
|
||||||
|
Aged Brie, -28, 50
|
||||||
|
Elixir of the Mongoose, -25, 0
|
||||||
|
Sulfuras, Hand of Ragnaros, 0, 80
|
||||||
|
Sulfuras, Hand of Ragnaros, -1, 80
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -15, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -20, 0
|
||||||
|
Backstage passes to a TAFKAL80ETC concert, -25, 0
|
||||||
|
Conjured Mana Cake, -27, 0
|
||||||
|
|
||||||
@ -246,4 +246,45 @@ public class UpdateQualityTestFixture
|
|||||||
app.UpdateQuality();
|
app.UpdateQuality();
|
||||||
items.Should().BeEquivalentTo(expectedItemsAfterTest);
|
items.Should().BeEquivalentTo(expectedItemsAfterTest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ConjuredItems_WhenNotExpired_Should_DecreaseQualityByTwo()
|
||||||
|
{
|
||||||
|
var items = new List<Item>
|
||||||
|
{
|
||||||
|
new ItemBuilder("Conjured Mana Cake", 1, 4).Build(),
|
||||||
|
new ItemBuilder("some other conjured item", 5, 50).Build()
|
||||||
|
};
|
||||||
|
var expectedItemsAfterTest = new List<Item>
|
||||||
|
{
|
||||||
|
new ItemBuilder("Conjured Mana Cake", 0, 2).Build(),
|
||||||
|
new ItemBuilder("some other conjured item", 4, 48).Build()
|
||||||
|
};
|
||||||
|
|
||||||
|
var app = new GildedRose(items);
|
||||||
|
app.UpdateQuality();
|
||||||
|
|
||||||
|
items.Should().BeEquivalentTo(expectedItemsAfterTest);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ConjuredItems_WhenExpired_Should_DecreaseQualityByFourDownToZero()
|
||||||
|
{
|
||||||
|
var items = new List<Item>
|
||||||
|
{
|
||||||
|
new ItemBuilder("Conjured Mana Cake", 0, 3).Build(),
|
||||||
|
new ItemBuilder("some other conjured item", -1, 50).Build()
|
||||||
|
};
|
||||||
|
var expectedItemsAfterTest = new List<Item>
|
||||||
|
{
|
||||||
|
new ItemBuilder("Conjured Mana Cake", -1, 0).Build(),
|
||||||
|
new ItemBuilder("some other conjured item", -2, 46).Build()
|
||||||
|
};
|
||||||
|
|
||||||
|
var app = new GildedRose(items);
|
||||||
|
app.UpdateQuality();
|
||||||
|
|
||||||
|
items.Should().BeEquivalentTo(expectedItemsAfterTest);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user