public void ArchiveBom_FailFor_TheOnlyBomForProducibleArticle()
        {
            //arrange
            var bom     = Product1InteriorDoor.PrimaryBillOfMaterial;
            var command = new ArchiveBillOfMaterial()
            {
                Id          = bom.Id,
                InitiatorId = GlobalAdmin.Id
            };
            var handler = new ArchiveBillOfMaterialHandler(EntityRepository, EventTransmitter);

            //assert () => act
            var ex = Assert.ThrowsAsync <DomainException>(async() => await handler.HandleAsync(command));

            Assert.That(ex.Message, Is.EqualTo(ArchivingTheOnlyBomForProducibleArticle(bom)));
            Assert.That(GetRecordedEvents <DomainEvent <BillOfMaterial> >(), Is.Empty);
        }
        public async Task ArchiveBom_Success()
        {
            //adhere
            var initial = Component2Horizontal.BillsOfMaterial.DeepCopy();

            //arrange
            var bom     = Component2Horizontal.PrimaryBillOfMaterial;
            var command = new ArchiveBillOfMaterial()
            {
                Id          = bom.Id,
                InitiatorId = GlobalAdmin.Id
            };
            var handler = new ArchiveBillOfMaterialHandler(EntityRepository, EventTransmitter);

            //act
            await handler.HandleAsync(command);

            //assert
            Assert.That(CallsTo(EntityRepository, nameof(EntityRepository.RemoveAsync)), Is.EqualTo(1));
            var id = GetRecordedIds(EntityRepository, nameof(EntityRepository.RemoveAsync)).Single();

            Assert.That(id, Is.EqualTo(bom.Id));

            var events = GetRecordedEvents <DomainEvent <BillOfMaterial> >();

            Assert.That(events.Count, Is.EqualTo(1));
            Assert.That(events[0].Entity, Is.EqualTo(bom));
            Assert.That(events[0].Trigger, Is.EqualTo(Trigger.Removed));
            Assert.That(events[0].RaisedBy, Is.EqualTo(command.InitiatorId));

            var bomDiff = initial.Except(Component2Horizontal.BillsOfMaterial).SingleOrDefault();

            Assert.That(bomDiff, Is.EqualTo(bom));
            Assert.That(Component2Horizontal.PrimaryBillOfMaterial, Is.Not.Null);
            Assert.That(Component2Horizontal.PrimaryBillOfMaterial, Is.Not.EqualTo(bom));

            //annul
            Component2Horizontal.BillsOfMaterial = initial;
        }