예제 #1
0
        public void GivenItemsInARow_WhenRemoveMultipleItems_ShouldWireUpCorrectly()
        {
            var item1 = new TestItem(1);
            var item2 = new TestItem(2);
            var item3 = new TestItem(3);
            var item4 = new TestItem(4);

            _testee.ItemDetected(item1);
            _testee.ItemDetected(item2);
            _testee.ItemDetected(item3);
            _testee.ItemDetected(item4);

            _testee.RemoveItem(item3);
            _testee.RemoveItem(item4);

            _testee.Count.Should().Be(2);
            _testee.GetOrderedList().Count.Should().Be(2);
            item3.ItemBehind.Should().BeNull();
            item3.ItemInFront.Should().BeNull();
            item4.ItemBehind.Should().BeNull();
            item4.ItemInFront.Should().BeNull();
        }
예제 #2
0
        public void GivenItem_WhenDetectNewItem_ShouldRaiseEvent()
        {
            var oldItem = new TestItem(1);

            _testee.ItemDetected(oldItem);
            _testee.MonitorEvents();

            _testee.ItemDetected(oldItem);

            _testee.ShouldNotRaise("NewItemDetectedEvent", "this item is not new it was just scanned a second time");

            var newItem = new TestItem(2);

            _testee.ItemDetected(newItem);

            _testee
            .ShouldRaise("NewItemDetectedEvent")
            .WithArgs <ItemEventArgs <TestItem> >(x => x.Item == newItem);

            _testee
            .ShouldRaise("ItemDetectedEvent")
            .WithArgs <ItemEventArgs <TestItem> >(x => x.Item == newItem);
        }