public void When_a_Wardrobe_has_less_space_than_the_element_needs_it_should_throw_an_exception() { var wardrobe = Wardrobe.Create(40); var element = Element.Create(50); Assert.Throws <ApplicationException>(() => wardrobe.AddElement(element)); }
public void When_a_Wardrobe_has_one_50_Element_its_RemainingSpace_should_be_reduced_by_50() { var wardrobe = Wardrobe.Create(250); var element = Element.Create(50); wardrobe.AddElement(element); Assert.Equal(200, wardrobe.RemainingSpace); }
public Wardrobe[] FindMatchingOptions(int wardrobeWidth) { var wardrobe = Wardrobe.Create(wardrobeWidth); var added = false; do { added = TryAddElement(wardrobe); } while (added); return(new[] { wardrobe }); }
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); }
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); }
public void When_Creating_a_Wardrobe_a_positive_width_should_be_accepted() { var wardrobe = Wardrobe.Create(250); Assert.Equal(250, wardrobe.width); }
public void wordrobe_should_return_remaining_space() { var wardrobe = Wardrobe.Create(250); Assert.Equal(250, wardrobe.RemainingSpace); }
public void When_Creating_a_Wardrobe_a_negative_width_should_be_rejected() { Assert.Throws <ApplicationException>(() => Wardrobe.Create(-10)); }