public void Serialize_ForbiddenPropertyName_Throws() { var source = fixture.Create <ForbiddenPropertyNameObject>(); source.Invoking(s => AzureTableSerializer.Serialize(s)).Should().Throw <SerializationException>() .And.Message.Should().Contain(nameof(ForbiddenPropertyNameObject.ForbiddenName_Property)); }
private DynamicTableEntity Serialize(IEvent stateEvent) { return(new DynamicTableEntity(stateEvent.AggregateRootId, stateEvent.Version.ToString("D9", CultureInfo.InvariantCulture)) { Properties = AzureTableSerializer.Serialize(stateEvent, persistType: true) }); }
private DynamicTableEntity Serialize(string transactionId, IEvent @event) { return(new DynamicTableEntity(transactionId, GetRowKey(@event.Created)) { Properties = AzureTableSerializer.Serialize(@event, persistType: true) }); }
private DynamicTableEntity Serialize(ICommand command) { return(new DynamicTableEntity(command.AggregateRootId, command.Id) { Properties = AzureTableSerializer.Serialize(command, persistType: true) }); }
private DynamicTableEntity Serialize(TQueryModel queryModel) { return(new DynamicTableEntity(queryModel.Id, GetRowKey(queryModel.Version)) { Timestamp = queryModel.Timestamp, Properties = AzureTableSerializer.Serialize(queryModel) }); }
private DynamicTableEntity Serialize(IIntegrationEvent integrationEvent, bool isPublished) { return(new DynamicTableEntity(integrationEvent.AggregateRootId, GetRowKey(integrationEvent.Created)) { Properties = AzureTableSerializer.Serialize(integrationEvent, persistType: true), [IsPublishedColumnName] = new EntityProperty(isPublished) }); }
public void DeserializeWithoutType_NoTypeNameColumn_WorksCorrectly() { var source = fixture.Create <ZeroDepthObject>(); var serialized = AzureTableSerializer.Serialize(source); serialized.Invoking(s => AzureTableSerializer.Deserialize(Entity(s))) .Should().Throw <InvalidOperationException>(); }
private DynamicTableEntity Serialize(TQueryModel queryModel, string etag = null) { return(new DynamicTableEntity(Options.GetPartitionKey(queryModel.Id), queryModel.Id) { ETag = etag ?? queryModel.ETag, Timestamp = queryModel.Timestamp, Properties = AzureTableSerializer.Serialize(queryModel) }); }
public void Serialize_MinDateTimeObject_SetsToMinValuesForTableStorage() { var source = new MinDateTimeObject(); var serialized = AzureTableSerializer.Serialize(source); serialized[nameof(source.DateTimeProperty)].PropertyAsObject.Should().BeEquivalentTo(new DateTime(1601, 1, 1, 0, 0, 0, DateTimeKind.Utc)); serialized[nameof(source.DateTimeOffsetProperty)].PropertyAsObject.Should().BeEquivalentTo(new DateTime(1601, 1, 1, 0, 0, 0, DateTimeKind.Utc)); }
public void Serialize_PersistType_AddsTypeNameColumn() { var source = fixture.Create <ZeroDepthObject>(); var serialized = AzureTableSerializer.Serialize(source, true); serialized[AzureTableSerializer.TypeNameColumnName].PropertyAsObject.Should() .Be(source.GetType().AssemblyQualifiedName); }
public void Deserialize_ExceptionPropertyObject_Throws() { var source = new ExceptionPropertyObject(); var serialized = AzureTableSerializer.Serialize(source); serialized.Invoking(s => AzureTableSerializer.Deserialize <ExceptionPropertyObject>(Entity(s))) .Should().Throw <SerializationException>() .And.Message.Contains(nameof(ExceptionPropertyObject.ExceptionProperty), StringComparison.Ordinal); }
public void Serialize_CircularDependency_Throws() { var source = new CircularDependencyObject(); source.DependencyProperty = source; source.Invoking(s => AzureTableSerializer.Serialize(s)).Should().Throw <SerializationException>() .And.Message.Should().Contain("Circular"); }
public void Deserialize_ZeroDepthObject_WorksCorrectly() { var source = fixture.Create <ZeroDepthObject>(); var serialized = AzureTableSerializer.Serialize(source); var deserialized = AzureTableSerializer.Deserialize <ZeroDepthObject>(Entity(serialized)); deserialized.Should().BeEquivalentTo(source, options => options .Excluding(o => o.Timestamp)); }
public void Deserialize_MinDateTimeObject_RestoredDefaultValue() { var source = new MinDateTimeObject(); var serialized = AzureTableSerializer.Serialize(source); var deserialized = AzureTableSerializer.Deserialize <MinDateTimeObject>(Entity(serialized)); deserialized.Should().BeEquivalentTo(source, options => options .Excluding(o => o.Timestamp)); }
public void DeserializeWithoutType_CollectionObject_WorksCorrectly() { var source = fixture.Create <CollectionObject>(); var serialized = AzureTableSerializer.Serialize(source, true); var deserialized = AzureTableSerializer.Deserialize(Entity(serialized)); deserialized.Should().BeEquivalentTo(source, options => options .Excluding(o => o.Timestamp)); }
public void Deserialize_ObjectHasNoPropertyWithSuchName_WorksCorrectly() { var source = fixture.Create <ZeroDepthObject>(); var serialized = AzureTableSerializer.Serialize(source); serialized["SomeRandomPropertyName"] = new EntityProperty("SomeRandomPropertyValue"); var deserialized = AzureTableSerializer.Deserialize <ZeroDepthObject>(Entity(serialized)); deserialized.Should().BeEquivalentTo(source, options => options .Excluding(o => o.Timestamp)); }
public void Deserialize_NewtonsoftJsonSerializableObject_WorksCorrectly() { var source = new NewtonsoftJsonSerializableObject { ChildPrivateConstructorObject = ChildPrivateConstructorObject.CreateRandom(), ChildNoDefaultConstructorObject = new ChildNoDefaultConstructorObject(FixtureUtils.String()) }; var serialized = AzureTableSerializer.Serialize(source); var deserialized = AzureTableSerializer.Deserialize <NewtonsoftJsonSerializableObject>(Entity(serialized)); deserialized.Should().BeEquivalentTo(source, options => options .Excluding(o => o.Timestamp)); }
public void DeserializeWithoutType_TypeNameIsUnknown_WorksCorrectly() { var source = fixture.Create <ZeroDepthObject>(); var serialized = AzureTableSerializer.Serialize(source, true); // Replace existing type name with unknown one. var serializedUnknownTypeName = serialized[AzureTableSerializer.TypeNameColumnName].StringValue .Replace(nameof(ZeroDepthObject), nameof(ZeroDepthObject) + "2", StringComparison.Ordinal); serialized[AzureTableSerializer.TypeNameColumnName] = new EntityProperty(serializedUnknownTypeName); serialized.Invoking(s => AzureTableSerializer.Deserialize(Entity(s))) .Should().Throw <TypeLoadException>(); }
public void Deserialize_EnumObject_WorksCorrectly() { var source = new EnumObject { TestEnumProperty = FixtureUtils.FromEnum <TestEnum>(), ChildEnumObjectProperty = new ChildEnumObject { TestEnumProperty = FixtureUtils.FromEnum <TestEnum>() } }; var serialized = AzureTableSerializer.Serialize(source); var deserialized = AzureTableSerializer.Deserialize <EnumObject>(Entity(serialized)); deserialized.Should().BeEquivalentTo(source, options => options .Excluding(o => o.Timestamp)); }
public void Deserialize_CommandWithMetadata_WorksCorrectly() { var command = new TestCreateCommand { AggregateRootId = Unified.NewCode(), Metadata = new Dictionary <MetadataKey, string> { { MetadataKey.UserId, Unified.NewCode() } } }; var serialized = AzureTableSerializer.Serialize(command, true); var deserialized = AzureTableSerializer.Deserialize(Entity(serialized)); deserialized.Should().BeEquivalentTo(command, options => options .Excluding(o => o.Created)); }
public void Deserialize_HugeCollection_UsesGZip() { var source = new CollectionObject { RandomObject1CollectionProperty = FixtureUtils.Array(1000, 1000, () => new RandomObject1 { StringProperty = FixtureUtils.String() }).ToList() }; var serialized = AzureTableSerializer.Serialize(source); var deserialized = AzureTableSerializer.Deserialize <CollectionObject>(Entity(serialized)); serialized.Keys.Any(k => k.Contains("GZip", StringComparison.Ordinal)).Should().BeTrue(); deserialized.Should().BeEquivalentTo(source, options => options .Excluding(o => o.Timestamp)); }
/// <inheritdoc/> public Task PersistMessagesAsync(string id, IReadOnlyCollection <AbstractMessage> messages) { if (messages.Count >= MaxBatchSize) { throw new NotSupportedException($"Storage unable to persist '{messages.Count}' messages. Supported message count is up to '{MaxBatchSize}'."); } var batchOperation = new TableBatchOperation(); foreach (var msg in messages) { var properties = AzureTableSerializer.Serialize(msg, true); properties.Add(IsPublishedColumnName, new EntityProperty(false)); batchOperation.Insert(new DynamicTableEntity(id, msg.Id, "*", properties)); } return(tableProxy.ExecuteBatchAsync(batchOperation)); }
public void Serialize_NullObject_ReturnsEmptyResult() { var result = AzureTableSerializer.Serialize(null); result.Should().BeEmpty(); }