예제 #1
0
 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
파일: AlgTests.cs 프로젝트: aBaTaPbl4/Mini
 public void FullEnumerationAlgTest_With3Goods()
 {
     int bagMaxWeight = 80;
     var alg = new FullEnumerationAlg(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);
 }
예제 #3
0
파일: AlgTests.cs 프로젝트: aBaTaPbl4/Mini
 public void FullEnumerationAlgTest_With9Goods()
 {
     int bagMaxWeight = 100;
     var alg = new FullEnumerationAlg(bagMaxWeight);
     Good[] goods = Create9GoodsArray();
     alg.Calc(goods);
     _printer.PrintPack(alg.BestPriceGoodsPack);
     Assert.AreEqual(193, alg.BestPriceGoodsPack.Price);
     Assert.IsTrue(alg.BestPriceGoodsPack.ContainsGoodWithName("5"));
     Assert.IsTrue(alg.BestPriceGoodsPack.ContainsGoodWithName("7"));
     Assert.IsTrue(alg.BestPriceGoodsPack.ContainsGoodWithName("1"));
     _printer.PrintPackShort(alg.UnbestPacks);
 }
예제 #4
0
 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");
 }