public void Should_change_ObjectType_when_AddImpression_is_called_second_time() { this.existingImpressions.ObjectType.Should().Be(this.testObjectType); var newObjectType = new ImpressionsObjectType("new-type"); this.existingImpressions.AddImpression(new UserId("other-one"), newObjectType); this.existingImpressions.ObjectType.Should().Be(newObjectType); }
public void Should_change_ObjectType_when_RemoveImpression_is_called_second_time() { this.existingImpressions.ObjectType.Should().Be(this.testObjectType); var newObjectType = new ImpressionsObjectType("new-type"); this.existingImpressions.RemoveImpression(this.testImpressionist, newObjectType); this.existingImpressions.ObjectType.Should().Be(newObjectType); }
public virtual void RemoveImpression(UserId impressionistId, ImpressionsObjectType objectType) { if (this.ImpressionistIsValid(impressionistId) && this.ObjectTypeIsValid(objectType) && this._Impressionists.Contains(impressionistId)) { this.AddEventSourcedDomainEvent(this.CreateImpressionRemovedEvent(objectType), impressionistId); this.AddIntegrationEvent(this.CreateImpressionsChangedEvent()); } }
private bool ObjectTypeIsValid(ImpressionsObjectType objectType) { var validationResult = ImpressionsObjectType.Validator.Validate(objectType); if (!validationResult.IsValid) { this.AddFailedDomainEvent(new ImpressionsObjectTypeValidationFailedEvent <TAggregateId>(this.Id, validationResult)); return(false); } return(true); }
protected override ImpressionRemovedEvent <ImpressionsObjectId> CreateImpressionRemovedEvent(ImpressionsObjectType objectType) { return(Substitute.ForPartsOf <ImpressionRemovedEvent <ImpressionsObjectId> >(this.Id, objectType)); }
protected abstract ImpressionRemovedEvent <TAggregateId> CreateImpressionRemovedEvent( ImpressionsObjectType objectType);