public void ConvertToTableEntityWithNameMapping() { // Arrange var converter = new TableEntityConverter<LogEntry>(); var entity = new LogEntry { Id = "My id", Message = "My message" }; var context = new OperationContext(); // Act ITableEntity tableEntity = converter.GetEntity(entity); IDictionary<string, EntityProperty> properties = tableEntity.WriteEntity(context); // Assert Assert.Equal(null, tableEntity.ETag); Assert.Equal(entity.Id, tableEntity.PartitionKey); Assert.Equal(string.Empty, tableEntity.RowKey); Assert.Equal(entity.Message, properties["OldMessage"].StringValue); }
public void ConvertToTableEntityWithFewKeys() { // Arrange var converter = new TableEntityConverter<LogEntry>(); var entry = new LogEntry { Id = Guid.NewGuid().ToString("N"), ETag = "MyETag", Timestamp = DateTime.UtcNow, Message = "My message", PrivateData = new byte[] {0xaa, 0xbb, 0xcc} }; var context = new OperationContext(); // Act ITableEntity tableEntity = converter.GetEntity(entry); IDictionary<string, EntityProperty> properties = tableEntity.WriteEntity(context); // Assert Assert.Equal(entry.ETag, tableEntity.ETag); Assert.Equal(entry.Id, tableEntity.PartitionKey); Assert.Equal(string.Empty, tableEntity.RowKey); Assert.Equal(default(DateTimeOffset), tableEntity.Timestamp); Assert.Equal(entry.Message, properties["OldMessage"].StringValue); Assert.DoesNotContain("PrivateData", properties.Keys); }