public void Variant_Should_Be_Added() { var slicerAttributeId = Random <int>(); var slicerAttributeValueId = Random <int>(); var productId = Random <Guid>(); var barcode = Random <String>(); var varianterAttributeId = Random <int>(); var varianterAttributeValueId = Random <int>(); var @event = new VariantAddedToProduct(productId, barcode, new AttributeRef(slicerAttributeId, slicerAttributeValueId), new AttributeRef(varianterAttributeId, varianterAttributeValueId)); ScenarioForExisting() .Given( () => { var aggregate = Product.Create(productId, Random <int>(), Random <int>(), Random <string>()); aggregate.AddContent(Random <string>(), Random <string>(), new AttributeRef(slicerAttributeId, slicerAttributeValueId)); return(aggregate); }) .When ( product => product.AddVariant(barcode, new AttributeRef(slicerAttributeId, slicerAttributeValueId), new AttributeRef(varianterAttributeId, varianterAttributeValueId)) ) .Then(@event) .AlsoAssert( product => product.Contents.SelectMany(c => c.Variants) .Any(x => x.Barcode == barcode) ); }
private void Apply(VariantAddedToProduct @event) { _variants.Add(new Variant(@event.Barcode, @event.VarianterAttribute)); }
private void Apply(VariantAddedToProduct @event) => _contents.First(c => c.SlicerAttribute == @event.SlicerAttribute).Route(@event);