mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 14:31:28 +00:00
Updated AgedBrieItemUpdateService tests, SulfurasItemUpdateService
This commit is contained in:
parent
20e93848e1
commit
b2724c7438
@ -54,10 +54,10 @@ func TestAgedBrieItemUpdateService_QualityNotHigherThan50(t *testing.T) {
|
|||||||
// sellIn date must decrease
|
// sellIn date must decrease
|
||||||
func TestAgedBrieItemUpdateService_SellInIsDecreased(t *testing.T) {
|
func TestAgedBrieItemUpdateService_SellInIsDecreased(t *testing.T) {
|
||||||
runTestCase(t, func(
|
runTestCase(t, func(
|
||||||
sulfurasItemUpdateService SulfurasItemUpdateService,
|
agedBrieItemUpdateService AgedBrieItemUpdateService,
|
||||||
) {
|
) {
|
||||||
item := models.NewItem(&models.ItemModel{"Aged Brie", 5, 5})
|
item := models.NewItem(&models.ItemModel{"Aged Brie", 5, 5})
|
||||||
sulfurasItemUpdateService.UpdateQuality(item)
|
agedBrieItemUpdateService.UpdateQuality(item)
|
||||||
assert.Equal(t, 4, item.Model.SellIn)
|
assert.Equal(t, 4, item.Model.SellIn)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,53 +19,7 @@ func (this SulfurasItemUpdateService) UpdateQuality(item *models.Item) error {
|
|||||||
item.Mutex.Lock()
|
item.Mutex.Lock()
|
||||||
defer item.Mutex.Unlock()
|
defer item.Mutex.Unlock()
|
||||||
|
|
||||||
itemModel := item.Model
|
item.Model.Quality = 80
|
||||||
|
|
||||||
if itemModel.Name != "Aged Brie" && itemModel.Name != "Backstage passes to a TAFKAL80ETC concert" {
|
|
||||||
if itemModel.Quality > 0 {
|
|
||||||
if itemModel.Name != "Sulfuras, Hand of Ragnaros" {
|
|
||||||
itemModel.Quality = itemModel.Quality - 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if itemModel.Quality < 50 {
|
|
||||||
itemModel.Quality = itemModel.Quality + 1
|
|
||||||
if itemModel.Name == "Backstage passes to a TAFKAL80ETC concert" {
|
|
||||||
if itemModel.SellIn < 11 {
|
|
||||||
if itemModel.Quality < 50 {
|
|
||||||
itemModel.Quality = itemModel.Quality + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if itemModel.SellIn < 6 {
|
|
||||||
if itemModel.Quality < 50 {
|
|
||||||
itemModel.Quality = itemModel.Quality + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if itemModel.Name != "Sulfuras, Hand of Ragnaros" {
|
|
||||||
itemModel.SellIn = itemModel.SellIn - 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if itemModel.SellIn < 0 {
|
|
||||||
if itemModel.Name != "Aged Brie" {
|
|
||||||
if itemModel.Name != "Backstage passes to a TAFKAL80ETC concert" {
|
|
||||||
if itemModel.Quality > 0 {
|
|
||||||
if itemModel.Name != "Sulfuras, Hand of Ragnaros" {
|
|
||||||
itemModel.Quality = itemModel.Quality - 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
itemModel.Quality = itemModel.Quality - itemModel.Quality
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if itemModel.Quality < 50 {
|
|
||||||
itemModel.Quality = itemModel.Quality + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user