public void An_AggregateNotFound_Exception_is_thrown()
        {
            Exception caughtException = new ThereWasNoExceptionButOneWasExpectedException();

            try
            {
                _eventStore.GetEventsForAggregate(Guid.NewGuid());
            } catch (Exception e)
            {
                caughtException = e;
            }

            Assert.That(caughtException is AggregateNotFoundException);
        }
        public void A_merge_which_is_not_allowed_throws_a_RealConcurrencyException()
        {
            var aggregateId = Guid.NewGuid();

            //Set up existing aggregate state - will be at aggregate version 4
            var existingAggregateEvents = new List<Event>();
            existingAggregateEvents.Add(new InventoryItemCreated(aggregateId, "A Name"));
            existingAggregateEvents.Add(new InventoryItemReceivedIntoStock(aggregateId, 100));
            existingAggregateEvents.Add(new InventoryItemDeactivated(aggregateId));

            _eventStore.SaveEvents(aggregateId, existingAggregateEvents, 0);

            //Command has an earlier expected version and conflicts with changes between expected and actual version
            var command = new RenameInventoryItem(aggregateId, "A new name", 1);

            var specificCommandHandler = new RenameInventoryItemHandler(_repository);
            var mergingChain = new MergingContextCommitHandler<RenameInventoryItem>(specificCommandHandler, _eventStore,
                                                                                    _allowedMerges);

            Exception caughtException = new ThereWasNoExceptionButOneWasExpectedException();
            try
            {
                mergingChain.Handle(command, new CommandExecutionContext());
            } catch (Exception e)
            {
                caughtException = e;
            }

            Assert.That(caughtException is RealConcurrencyException);
        }