示例#1
0
        public void Test_TableEntityConverter_ConvertObject()
        {
            // Arrange
            var auditLog = new FakeAuditLog
            {
                Key            = "testPartition/testRow",
                Message        = "testMessage",
                UserIdentifier = "testUserIdentifier",
                AppName        = "testAppName",
                CurrentValue   = "testCurrentValue",
                PreviousValue  = "testPreviousValue",
                TestArray      = new List <string> {
                    "test"
                },
                TestBool     = true,
                TestDateTime = new DateTime(),
                TestDouble   = 1.0,
                TestGuid     = Guid.Empty,
                TestLong     = 1,
                TestObject   = "other",
                TestOffset   = new DateTimeOffset()
            };

            // Act
            var objectConversion = new ObjectToTableEntityConverter(auditLog);
            var props            = objectConversion.GetEntityProperties();
            var table            = objectConversion.GetTableEntity();

            // Assert
            props.Count.Should().Be(13);
            props.ContainsKey("AppName").Should().BeTrue();
            props.ContainsKey("Message").Should().BeTrue();
            props.ContainsKey("UserIdentifier").Should().BeTrue();
            props.ContainsKey("CurrentValue").Should().BeTrue();
            props.ContainsKey("PreviousValue").Should().BeTrue();
            table.RowKey.Should().Be("testRow");
            table.PartitionKey.Should().Be("testPartition");
            table.ETag.Should().BeNull();
        }
示例#2
0
        public static ITableEntity ToTableEntity(object poco)
        {
            var converter = new ObjectToTableEntityConverter(poco);

            return(converter.GetTableEntity());
        }