Пример #1
0
        public void When_using_a_greedy_strategy_and_return_the_maximum_for_this_strategy()
        {
            var el50          = Element.Create(50);
            var el20          = Element.Create(20);
            var el10          = Element.Create(10);
            var elements      = new[] { el50, el20, el10 };
            var strategy      = new GreedyStrategy(elements);
            var wardrobeWidth = 80;

            Wardrobe[] options = strategy.FindMatchingOptions(wardrobeWidth);

            Assert.Equal(new[] { el50, el20, el10 }, options[0].Elements);
        }
Пример #2
0
        public void When_using_a_greedy_strategy_then_the_widest_element_should_be_choosen()
        {
            var el50          = Element.Create(50);
            var elements      = new[] { el50, Element.Create(40) };
            var strategy      = new GreedyStrategy(elements);
            var wardrobeWidth = 50;

            Wardrobe[] options = strategy.FindMatchingOptions(wardrobeWidth);

            var wardrobe = Wardrobe.Create(50);

            wardrobe.AddElement(el50);
            var expected = new[] { wardrobe };

            Assert.Equal(new[] { el50 }, options[0].Elements);
        }
Пример #3
0
        public void When_using_a_greedy_strategy_and_the_widest_element_is_to_big_then_the_secound_smallest_element_should_be_added()
        {
            var el50          = Element.Create(50);
            var el40          = Element.Create(40);
            var elements      = new[] { el50, el40 };
            var strategy      = new GreedyStrategy(elements);
            var wardrobeWidth = 49;

            Wardrobe[] options = strategy.FindMatchingOptions(wardrobeWidth);

            var wardrobe = Wardrobe.Create(wardrobeWidth);

            wardrobe.AddElement(el40);
            var expected = new[] { wardrobe };

            Assert.Equal(new[] { el40 }, options[0].Elements);
        }