mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-18 16:01:42 +00:00
Update GildedRoseTest.cs
This commit is contained in:
parent
e692f0d55b
commit
6ab52bfc46
@ -1,5 +1,8 @@
|
|||||||
using Xunit;
|
using System;
|
||||||
|
using Xunit;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
using GildedRose.Models;
|
||||||
using GildedRoseKata;
|
using GildedRoseKata;
|
||||||
|
|
||||||
namespace GildedRoseTests
|
namespace GildedRoseTests
|
||||||
@ -9,10 +12,38 @@ namespace GildedRoseTests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void foo()
|
public void foo()
|
||||||
{
|
{
|
||||||
IList<Item> Items = new List<Item> { new Item { Name = "foo", SellIn = 0, Quality = 0 } };
|
IList<Item> items = new List<Item> { new AgedBrie() { Name = "fixme", SellIn = 0, Quality = 0 } };
|
||||||
GildedRoseKata.GildedRose app = new GildedRoseKata.GildedRose(Items);
|
|
||||||
app.UpdateQuality();
|
GildedRoseKata.GildedRose app = new GildedRoseKata.GildedRose(items);
|
||||||
Assert.Equal("fixme", Items[0].Name);
|
|
||||||
|
foreach (Item t in items)
|
||||||
|
{
|
||||||
|
Type type = t.GetType();
|
||||||
|
var instance = Activator.CreateInstance(type);
|
||||||
|
|
||||||
|
// Get a property on the type that is stored in the
|
||||||
|
// property string
|
||||||
|
PropertyInfo propSellDaysGone = type.GetProperty("SellDaysGone");
|
||||||
|
PropertyInfo propSellIn = type.GetProperty("SellIn");
|
||||||
|
PropertyInfo propQuality = type.GetProperty("Quality");
|
||||||
|
PropertyInfo propName = type.GetProperty("Name");
|
||||||
|
|
||||||
|
// Set the value of the given property on the given instance
|
||||||
|
propSellDaysGone.SetValue(instance, 10, null);
|
||||||
|
propSellIn.SetValue(instance, t.SellIn, null);
|
||||||
|
propQuality.SetValue(instance, t.Quality, null);
|
||||||
|
propName.SetValue(instance, t.Name, null);
|
||||||
|
|
||||||
|
// Fetch the methods
|
||||||
|
MethodInfo updateQualityMethod = type.GetMethod("UpdateQuality");
|
||||||
|
MethodInfo updateSellinMethod = type.GetMethod("UpdateSellIn");
|
||||||
|
|
||||||
|
// Invoke the respective implementation of the methods
|
||||||
|
updateQualityMethod.Invoke(instance, new object[0]);
|
||||||
|
updateSellinMethod.Invoke(instance, new object[0]);
|
||||||
|
|
||||||
|
Assert.Equal("fixme", t.Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user