public void CanCreateInstanceWithParameters() { var aggregateType = typeof(MyDynamicEventSourcedAggregateRoot).FullName; var aggregateId = Guid.NewGuid(); var snapshot = new MySnapshot(22).WithVersion(2); var testee = new SqlSnapshotDescriptor(aggregateType, aggregateId, snapshot); testee.AggregateType.Should().Be(aggregateType); testee.AggregateId.Should().Be(aggregateId); testee.Version.Should().Be(2); testee.Timestamp.Should().BeCloseTo(DateTime.Now, 2000); testee.SnapshotType.Should().Be("SimpleDomain.TestDoubles.MySnapshot"); testee.Snapshot.Should().BeSameAs(snapshot); testee.SerializedSnapshot.Should().Contain("\"Value\":22").And.Contain("\"Version\":2"); }
/// <inheritdoc /> public override async Task SaveSnapshotAsync(ISnapshot snapshot) { var snapshotDescriptor = new SqlSnapshotDescriptor(this.AggregateType, this.AggregateId, snapshot); using (var connection = await this.factory.CreateAsync(this.connectionStringName).ConfigureAwait(false)) using (var command = new SqlCommand(SqlCommands.InsertSnapshot, connection)) { command.AddParameter("@AggregateType", snapshotDescriptor.AggregateType); command.AddParameter("@AggregateId", snapshotDescriptor.AggregateId); command.AddParameter("@Version", snapshotDescriptor.Version); command.AddParameter("@Timestamp", snapshotDescriptor.Timestamp); command.AddParameter("@SnapshotType", snapshotDescriptor.SnapshotType); command.AddParameter("@SnapshotData", snapshotDescriptor.SerializedSnapshot); await command.ExecuteNonQueryAsync().ConfigureAwait(false); } }
public void CanCreateParameterlessInstance() { var testee = new SqlSnapshotDescriptor(); testee.Should().NotBeNull(); }