public async Task Attempting_to_re_source_an_aggregate_that_was_instantiated_using_a_snapshot_succeeds_if_the_specified_version_is_at_or_after_the_snapshot() { var originalEmail = Any.Email(); var customerAccount = new CustomerAccount(new CustomerAccountSnapshot { AggregateId = Any.Guid(), Version = 10, EmailAddress = originalEmail }); customerAccount.Apply(new ChangeEmailAddress(Any.Email())); var accountAtv10 = customerAccount.AsOfVersion(10); accountAtv10.Version.Should().Be(10); accountAtv10.EmailAddress.Should().Be(originalEmail); }
public async Task Attempting_to_re_source_an_aggregate_that_was_instantiated_using_a_snapshot_throws_if_the_specified_version_is_prior_to_the_snapshot() { var originalEmail = Any.Email(); var customerAccount = new CustomerAccount(new CustomerAccountSnapshot { AggregateId = Any.Guid(), Version = 10, EmailAddress = originalEmail }); Action rollBack = () => customerAccount.AsOfVersion(9); rollBack.ShouldThrow <InvalidOperationException>() .And .Message .Should() .Contain("Snapshot version is later than specified version."); }
public void Attempting_to_re_source_an_aggregate_that_was_instantiated_using_a_snapshot_succeeds_if_the_specified_version_is_at_or_after_the_snapshot() { // arrange var originalEmail = Any.Email(); var account = new CustomerAccount() .Apply(new ChangeEmailAddress(originalEmail)); account.ConfirmSave(); var snapshot = account.CreateSnapshot(); snapshot.Version = 10; account = new CustomerAccount(snapshot); account.Apply(new ChangeEmailAddress(Any.Email())); // act var accountAtVersion10 = account.AsOfVersion(10); // arrange accountAtVersion10.Version.Should().Be(10); accountAtVersion10.EmailAddress.Should().Be(originalEmail); }
public void Attempting_to_re_source_an_aggregate_that_was_instantiated_using_a_snapshot_throws_if_the_specified_version_is_prior_to_the_snapshot() { // arrange var account = new CustomerAccount() .Apply(new ChangeEmailAddress(Any.Email())); account.ConfirmSave(); var snapshot = account .CreateSnapshot(); snapshot.Version = 10; account = new CustomerAccount(snapshot); // act Action rollBack = () => account.AsOfVersion(9); // assert rollBack.ShouldThrow <InvalidOperationException>() .And .Message .Should() .Contain("Snapshot version is later than specified version."); }
public async Task Attempting_to_re_source_an_aggregate_that_was_instantiated_using_a_snapshot_throws_if_the_specified_version_is_prior_to_the_snapshot() { var originalEmail = Any.Email(); var customerAccount = new CustomerAccount(new CustomerAccountSnapshot { AggregateId = Any.Guid(), Version = 10, EmailAddress = originalEmail }); Action rollBack = () => customerAccount.AsOfVersion(9); rollBack.ShouldThrow<InvalidOperationException>() .And .Message .Should() .Contain("Snapshot version is later than specified version."); }
public async Task Attempting_to_re_source_an_aggregate_that_was_instantiated_using_a_snapshot_succeeds_if_the_specified_version_is_at_or_after_the_snapshot() { var originalEmail = Any.Email(); var customerAccount = new CustomerAccount(new CustomerAccountSnapshot { AggregateId = Any.Guid(), Version = 10, EmailAddress = originalEmail }); customerAccount.Apply(new ChangeEmailAddress(Any.Email())); var accountAtv10 = customerAccount.AsOfVersion(10); accountAtv10.Version.Should().Be(10); accountAtv10.EmailAddress.Should().Be(originalEmail); }