public async Task GivenAVersionedReferenceThatDoesNotExistsThenAnAggregateVersionNotFoundExceptionIsThrownAsync() { _ = repository .Setup(repo => repo.GetAsync( It.IsAny <Guid>(), It.IsAny <CancellationToken?>(), It.IsAny <SignedVersion>())) .ReturnsAsync(default(SerializableAggregateRoot)); var aggregate = new SerializableAggregateRoot(); var reference = Reference.Create(aggregate); AggregateVersionNotFoundException <SerializableAggregateRoot> exception = await Assert.ThrowsAsync <AggregateVersionNotFoundException <SerializableAggregateRoot> >( () => repository.Object.GetAsync(context, reference, latest: false)); repository.Verify( repo => repo.GetAsync( It.IsAny <Guid>(), It.IsAny <CancellationToken?>(), It.IsAny <SignedVersion>()), Times.Once); Assert.Equal(reference, exception.Aggregate); Assert.Equal(context, exception.Context); }
public void GivenAnAggregateIdAContextAndANullVersionThenAnInstanceIsReturnedWithAnEmptyVersion() { var subject = new SerializableAggregateRoot(); Guid aggregateId = subject.Id; var context = new SerializableMessage(); SignedVersion?version = default; var instance = new AggregateVersionNotFoundException <SerializableAggregateRoot>(context, aggregateId, version: version); Assert.False(instance.Aggregate.IsVersioned); }
public void GivenAnAggregateAndAContextThenAnInstanceIsReturnedWithAllPropertiesSet() { var subject = new SerializableAggregateRoot(); var aggregate = subject.ToReference(); var context = new SerializableMessage(); var instance = new AggregateVersionNotFoundException <SerializableAggregateRoot>(context, aggregate); Assert.Equal(aggregate, instance.Aggregate); Assert.Equal(context, instance.Context); }
public void GivenAnInstanceThenAllPropertiesAreSerialized() { var subject = new SerializableAggregateRoot(); var aggregate = subject.ToReference(); var context = new SerializableMessage(); var original = new AggregateVersionNotFoundException <SerializableAggregateRoot>(context, aggregate); AggregateVersionNotFoundException <SerializableAggregateRoot> deserialized = original.Clone(); Assert.NotSame(original, deserialized); Assert.Equal(original.Aggregate, deserialized.Aggregate); Assert.Equal(original.Context, deserialized.Context); }
public void GivenAnAggregateIdAContextAndAVersionThenAnInstanceIsReturnedWithAllPropertiesSet() { var subject = new SerializableAggregateRoot(); Guid aggregateId = subject.Id; var context = new SerializableMessage(); SignedVersion version = subject.Version; var instance = new AggregateVersionNotFoundException <SerializableAggregateRoot>( context, aggregateId, version: version); Assert.Equal(aggregateId, instance.Aggregate.Id); Assert.Equal(context, instance.Context); Assert.Equal(version, instance.Aggregate.Version); }