public void FailedCaseTest(int bagCapacity, string elements )
 {
     var fuAlg = new FullEnumerationAlg(bagCapacity);
     var muAlg = new MuAlg(bagCapacity);
     Good[] goods = _goodsGenerator.GenerateGoods(elements);
     fuAlg.Calc(goods);
     muAlg.Calc(goods);
     Assert.AreEqual(fuAlg.BestPriceGoodsPack, muAlg.BestPriceGoodsPack);
 }
示例#2
0
 public void MuAlgTest_With3Goods()
 {
     int bagMaxWeight = 80;
     var alg = new MuAlg(bagMaxWeight);
     Good[] goods = Create3GoodsArray();
     alg.Calc(goods);
     Assert.AreEqual(190, alg.BestPriceGoodsPack.Price);
     Assert.IsTrue(alg.BestPriceGoodsPack.ContainsGoodWithName("2"));
     Assert.IsTrue(alg.BestPriceGoodsPack.ContainsGoodWithName("3"));
     _printer.PrintPack(alg.BestPriceGoodsPack);
 }
 public void Test([Random(1, 100, 1000)] int bagCapacity)
 {
     var fuAlg = new FullEnumerationAlg(bagCapacity);
     var muAlg = new MuAlg(bagCapacity);
     var goods = _goodsGenerator.GenerateGoods(10, 200, 111);
     fuAlg.Calc(goods);
     muAlg.Calc(goods);
     if (!fuAlg.BestPriceGoodsPack.Equals(muAlg.BestPriceGoodsPack))
     {
         Console.WriteLine("Failed goods set:");
         _printer.PrintGoods(goods);
         Console.WriteLine();
         Console.WriteLine("Full enumeration alg results:");
         _printer.PrintPack(fuAlg.BestPriceGoodsPack);
         Console.WriteLine();
         Console.WriteLine("Mu enumeration alg results:");
         _printer.PrintPack(muAlg.BestPriceGoodsPack);
         Console.WriteLine();
         Assert.Fail("Different result received");
     }
     Assert.Pass("ok");
 }