public static Item GetItem(string itemName, int sellInValue, int quality) { switch (itemName.ToLowerInvariant()) { case "aged brie": return(new AgedBrie(sellInValue, quality)); case "sulfuras": return(new LegendaryItem(sellInValue, quality)); case "normal item": return(new NormalItem(sellInValue, quality)); case "backstage passes": return(new BackstagePass(sellInValue, quality)); case "conjured": NormalItem conjured = new NormalItem(sellInValue, quality); conjured.DegradeRate = 2; return(conjured); default: return(null); } }
public void QualityWithSellInPastDate() { NormalItem item = new NormalItem("testItem", -1, 55, (int)Product.ProductType.NormalItem); item.Update(); Assert.That(item.quality.Equals(50)); }
public void NormalTestQualityDecreasesTwiceAsFastWhenSellinNegative() { var normalItem = new NormalItem(); normalItem.EndOfDayUpdate(0, 4); normalItem.Quality.ShouldBe(2); }
public void QualityMinLimit() { NormalItem item = new NormalItem("testItem", 1, -51, (int)Product.ProductType.NormalItem); item.Update(); Assert.That(minQuality <= item.quality && item.quality <= maxQuality); }
public void NormalTestQuality() { var normalItem = new NormalItem(); normalItem.EndOfDayUpdate(4, 5); normalItem.Quality.ShouldBe(4); }
public override void SetUp() { base.SetUp(); IPersister persister = mocks.Stub <IPersister>(); Expect.Call(delegate { persister.Save(null); }) .IgnoreArguments() .Do(new Action <ContentItem>(savedItems.Add)) .Repeat.Any(); IEditManager editManager = mocks.Stub <IEditManager>(); Expect.Call(editManager.GetEditorFilter(null)) .IgnoreArguments() .Return(new PageFilter()); IWebContext webContext = mocks.Stub <IWebContext>(); mocks.ReplayAll(); root = CreateOneItem <NormalPage>(1, "root", null); page1 = CreateOneItem <NormalPage>(2, "page1", root); item2 = CreateOneItem <NormalItem>(3, "item2", root); page3 = CreateOneItem <NormalPage>(4, "page3", root); item4 = CreateOneItem <NormalItem>(5, "item4", root); page5 = CreateOneItem <NormalPage>(6, "page5", root); N2.Utility.UpdateSortOrder(root.Children); sorter = new TreeSorter(persister, editManager, webContext); }
public void NormalItemDefaultsAreSetCorrectly() { const int defaultNormalDecreaseBy = 1; const int defaultOverdueDecreaseBy = 2; const int defaultMinimumQualityAllowed = 0; const int defaultMaximumQualityAllowed = 50; const int sellIn = 10; const int quality = 20; NormalItem normalItem = new NormalItem { Name = ItemNames.DEXTERITY_VEST, SellIn = sellIn, Quality = quality }; Assert.Equal(ItemNames.DEXTERITY_VEST, normalItem.Name); Assert.Equal(sellIn, normalItem.SellIn); Assert.Equal(quality, normalItem.Quality); Assert.Equal(defaultNormalDecreaseBy, normalItem.NormalDecreaseBy); Assert.Equal(defaultOverdueDecreaseBy, normalItem.OverdueDecreaseBy); Assert.Equal(defaultMinimumQualityAllowed, normalItem.MinimumQualityAllowed); Assert.Equal(defaultMaximumQualityAllowed, normalItem.MaximumQualityAllowed); }
public void NormalTestSellin() { var normalItem = new NormalItem(); normalItem.EndOfDayUpdate(4, 5); normalItem.SellIn.ShouldBe(3); }
public void NormalTestQualityNotBelowZero() { var normalItem = new NormalItem(); normalItem.EndOfDayUpdate(4, 0); normalItem.Quality.ShouldBe(0); }
public void Quality() { NormalItem item = new NormalItem("testItem", 1, 6, (int)Product.ProductType.NormalItem); item.Update(); Assert.That(item.quality.Equals(5)); }
void Replace(NormalItem i, string path) { byte[] dat = File.ReadAllBytes(path); // /*debug */{ File.WriteAllBytes(Path.Combine("debug", Path.GetFileName(i.fullName)), i.data); File.WriteAllBytes(Path.Combine("debug2", Path.GetFileName(i.fullName)), dat); } i.data = dat; Log.log(string.Format("[Info ]Replace {0} by {1}", i.fullName, Path.GetFileName(path))); }
public void Test_ItemFactory_Create_NormalItem_ReturnOk() { // Arrange NormalItem normalItem = new NormalItem("Normal Test", 0, 0); //Act var itemCreated = ItemFactory.Create("Normal Test", 0, 0); //Assert Assert.Equal(itemCreated.GetType(), normalItem.GetType()); }
public void Test_NormalItem_Update_DegreaseFaster_ReturnOk() { // Arrange NormalItem normalItem = new NormalItem("Teste 1234", 0, 10); //Act normalItem.Update(); //Assert Assert.Equal(8, normalItem.Quality); Assert.Equal(-1, normalItem.SellIn); }
public void Test_NormalItem_Update_MaximumQuality_ReturnOk() { // Arrange NormalItem normalItem = new NormalItem("Teste 1234", 12, 60); //Act normalItem.Update(); //Assert Assert.Equal(49, normalItem.Quality); Assert.Equal(11, normalItem.SellIn); }
public void ItemQualityCannotExceedMaxValue() { var normalItem = new NormalItem { SellIn = 10, Quality = 100 }; ManageInventory.ProcessItem(normalItem); Assert.AreEqual(normalItem.MaxQuality, normalItem.Quality); }
public void ItemQualityCannotDecreaseBelowMinValue() { var normalItem = new NormalItem { SellIn = 10, Quality = 0 }; ManageInventory.ProcessItem(normalItem); Assert.AreEqual(normalItem.MinQuality, normalItem.Quality); }
public void NormalItemQualityDecreasesByOne() { var normalItem = new NormalItem { SellIn = 10, Quality = 10 }; var oldQuality = normalItem.Quality; ManageInventory.ProcessItem(normalItem); Assert.AreEqual(oldQuality - 1, normalItem.Quality); }
public void SellInValueLessThanZeroNormalItemQualityDegradesTwiceAsFast() { var normalItem = new NormalItem { SellIn = -1, Quality = 10 }; var oldQuality = normalItem.Quality; ManageInventory.ProcessItem(normalItem); Assert.AreEqual(oldQuality - 2, normalItem.Quality); }
void GetImage() { if (Directory.Exists(img_path)) { Dictionary <string, string> imgtype = new Dictionary <string, string> { { ".jpg", "image/jpeg" }, { ".png", "image/png" } }; foreach (var f in Directory.GetFiles(img_path)) { string ext = Path.GetExtension(f.ToLower()); string fn = Path.GetFileName(f); if (imgtype.ContainsKey(ext)) { NormalItem i = new NormalItem("OEBPS/Images/" + fn, File.ReadAllBytes(f)); epub.items.Add(i); items += string.Format(" <item id=\"{0}\" href=\"Images/{0}\" media-type=\"{1}\"/>\n", fn, imgtype[ext]); if (!img_names.Contains(fn)) { Log.log("[Warn]Unrefered image: " + fn); } Log.log("[Info]Add image: " + fn); } } } if (cc_option == ChineseConvertOption.T2S) { string patch_dir = Path.Combine(dir, "patch_t2s"); string patch_img_dir = Path.Combine(patch_dir, "Images"); if (Directory.Exists(patch_dir)) { if (Directory.Exists(patch_img_dir)) { foreach (var f in Directory.GetFiles(patch_img_dir)) { string fn = Path.GetFileName(f); NormalItem img = epub.GetItem <NormalItem>("OEBPS/Images/" + fn); if (img != null) { img.data = File.ReadAllBytes(f); Log.log("[Info]T2S:Image Replaced:" + fn); } } } } } }
public void DecreaseQualityByOneIfNotOverdue() { const int sellIn = 10; const int quality = 20; Item item = new NormalItem { Name = ItemNames.DEXTERITY_VEST, SellIn = sellIn, Quality = quality }; item.UpdateQuality(); Assert.Equal(sellIn - 1, item.SellIn); Assert.Equal(quality - 1, item.Quality); }
public void Normal_Item_Should_Decrease_Quality_By_One(int days) { // Arrange var target = new NormalItem { Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20 }; //Act for (int i = 0; i < days; i++) { target.Update(); } // Assert Assert.Equal("+5 Dexterity Vest", target.Name); Assert.Equal(20 - (1 * days), target.Quality); }
public void AgedBrieQualityAlwaysIncreases() { const int sellIn = 2; const int quality = 0; Item item = new NormalItem { Name = ItemNames.AGED_BRIE, SellIn = sellIn, Quality = quality, NormalDecreaseBy = -1, OverdueDecreaseBy = -1 }; item.UpdateQuality(); Assert.Equal(sellIn - 1, item.SellIn); Assert.Equal(quality + 1, item.Quality); }
public void SulfurasQualityNeverChanges() { const int sellIn = 1; const int quality = 80; Item item = new NormalItem { Name = ItemNames.SULFURAS, SellIn = sellIn, Quality = quality, NormalDecreaseBy = 0, OverdueDecreaseBy = 0, MinimumQualityAllowed = 80, MaximumQualityAllowed = 80 }; item.UpdateQuality(); Assert.Equal(sellIn - 1, item.SellIn); Assert.Equal(quality, item.Quality); }
public void Normal_Item_Should_Decrease_Quality_By_Two_When_SellingDate_Passed() { // Arrange var days = 8; var target = new NormalItem { Name = "+5 Dexterity Vest", SellIn = 5, Quality = 20 }; // Act for (int i = 0; i < days; i++) { target.Update(); } // Assert Assert.Equal("+5 Dexterity Vest", target.Name); //Only passed 8 days but 3 passed selling date, => 20 -5 -(3*2) = 9 Assert.Equal(9, target.Quality); }
public void AgedBrieQualityNeverExceedsFifty() { const int sellIn = 2; const int quality = 50; Item item = new NormalItem { Name = ItemNames.AGED_BRIE, SellIn = sellIn, Quality = quality, NormalDecreaseBy = -1, OverdueDecreaseBy = -1 }; item.UpdateQuality(); item.UpdateQuality(); item.UpdateQuality(); // SellIn days went down to zero but quality never changed as maximum quality allowed is 50. Assert.Equal(0, item.SellIn); Assert.Equal(50, item.Quality); }
internal void FillGapsWithNewItems() { for (int x = 0; x < boardSizeX; x++) { for (int y = 0; y < boardSizeY; y++) { Cell cell = m_cells[x, y]; if (!cell.IsEmpty) { continue; } NormalItem item = new NormalItem(); item.SetType(Utils.GetRandomNormalType()); item.SetView(); item.SetViewRoot(m_root); cell.Assign(item); cell.ApplyItemPosition(true); } } }
public void DecreaseQualityByTwoIfOverdue() { const int sellIn = 10; const int quality = 20; Item item = new NormalItem { Name = ItemNames.DEXTERITY_VEST, SellIn = sellIn, Quality = quality }; // Normal decrements for the first "sellIn" days. for (int i = 0; i < sellIn; i++) { item.UpdateQuality(); } // Double decrement for the first overdue day. item.UpdateQuality(); Assert.Equal(0, item.SellIn); Assert.Equal(8, item.Quality); }
internal void Fill() { for (int x = 0; x < boardSizeX; x++) { for (int y = 0; y < boardSizeY; y++) { Cell cell = m_cells[x, y]; NormalItem item = new NormalItem(); List <NormalItem.eNormalType> types = new List <NormalItem.eNormalType>(); if (cell.NeighbourBottom != null) { NormalItem nitem = cell.NeighbourBottom.Item as NormalItem; if (nitem != null) { types.Add(nitem.ItemType); } } if (cell.NeighbourLeft != null) { NormalItem nitem = cell.NeighbourLeft.Item as NormalItem; if (nitem != null) { types.Add(nitem.ItemType); } } item.SetType(Utils.GetRandomNormalTypeExcept(types.ToArray())); item.SetView(); item.SetViewRoot(m_root); cell.Assign(item); cell.ApplyItemPosition(false); } } }
public override void SetUp() { base.SetUp(); persister = TestSupport.SetupFakePersister(); var webContext = new ThreadContext(); IEditManager editManager = mocks.Stub <IEditManager>(); Expect.Call(editManager.GetEditorFilter(null)) .IgnoreArguments() .Return(new PageFilter()); mocks.ReplayAll(); root = CreateOneItem <NormalPage>(1, "root", null); page1 = CreateOneItem <NormalPage>(2, "page1", root); item2 = CreateOneItem <NormalItem>(3, "item2", root); page3 = CreateOneItem <NormalPage>(4, "page3", root); item4 = CreateOneItem <NormalItem>(5, "item4", root); page5 = CreateOneItem <NormalPage>(6, "page5", root); N2.Utility.UpdateSortOrder(root.Children); sorter = new TreeSorter(persister, editManager, webContext); }
// Use this for initialization void Start() { normalItem = new NormalItem(Item_Name, Price, Description, Take_place); }