コード例 #1
0
ファイル: StoreLogicTest.cs プロジェクト: JeeneFG/UnitTests
        public void SortTest()
        {
            Store store = new Store(); // TODO: инициализация подходящего значения
            Box minBox = new Box(1, 1, 1);
            Box middleBox = new Box(1, 2, 1);
            Box maxBox = new Box(1, 2, 2);
            store.Add(maxBox);
            store.Add(minBox);
            store.Add(middleBox);

            StoreLogic target = new StoreLogic();
            target.Sort(store);

            List<Box> expected = new List<Box>() { minBox, middleBox, maxBox };

            List<Box> actual;
            actual = target.Sort(store);
            CollectionAssert.AreEqual(expected, actual);
        }
コード例 #2
0
ファイル: StoreLogic.cs プロジェクト: JeeneFG/UnitTests
        public List<Box> Sort(Store store)
        {
            if (store == null)
            {
                throw new ArgumentException("Ссылка не указывает на объект");
            }

            List<Box> boxes = store.Boxes;

            boxes.Sort((o1, o2) =>
                {
                    /*BoxParam param = new BoxParam();*/
                    double firstVolume = BoxParam.GetVolume(o1);
                    double secondVolume = BoxParam.GetVolume(o2);

                    return firstVolume.CompareTo(secondVolume);
                });

            return boxes;
        }