Ejemplo n.º 1
0
        public void CovertToDynamicTableEntityTest()
        {
            var testObj            = TestObject.BuildTestObject();
            var currentTime        = DateTime.Now;
            var dynamicTableEntity = EntityConverter.ConvertToDynamicTableEntity(testObj, (_ => "partitionA"), (_ => "rowB"), currentTime, "etag");

            dynamicTableEntity.PartitionKey.Should().Be("partitionA");
            dynamicTableEntity.RowKey.Should().Be("rowB");
            dynamicTableEntity.Timestamp.Should().Be(currentTime);
            dynamicTableEntity.ETag.Should().Be("etag");

            dynamicTableEntity.Properties.Should().NotBeNull();
            dynamicTableEntity.Properties.Keys.Count.Should().Be(8);
            dynamicTableEntity.Properties["StringValue"].StringValue.Should().Be(testObj.StringValue);
            dynamicTableEntity.Properties["BoolValue"].BooleanValue.Should().Be(testObj.BoolValue);
            dynamicTableEntity.Properties["BinaryValue"].BinaryValue.Should().BeSameAs(testObj.BinaryValue);
            dynamicTableEntity.Properties["Int32Value"].Int64Value.Should().Be(testObj.Int32Value); // Converts 32 to 64 always
            dynamicTableEntity.Properties["Int64Value"].Int64Value.Should().Be(testObj.Int64Value);
            dynamicTableEntity.Properties["DoubleValue"].DoubleValue.Should().Be(testObj.DoubleValue);
            dynamicTableEntity.Properties["GuidValue"].GuidValue.Should().Be(testObj.GuidValue);
            dynamicTableEntity.Properties["DateTimeValue"].DateTime.Should().Be(testObj.DateTimeValue);
        }