Exemplo n.º 1
0
        public void Should_WriteOffsetDateTimeEntity()
        {
            var date   = DateTimeOffset.Now;
            var entity = new OffsetDateTimeEntity()
            {
                OffsetDateTime = OffsetDateTime.FromDateTimeOffset(date)
            };
            var tEntity = (ITableEntity)entity;

            var result = tEntity.WriteEntity(new OperationContext());

            result.Should().ContainKey(nameof(OffsetDateTimeEntity.OffsetDateTime));
            result[nameof(OffsetDateTimeEntity.OffsetDateTime)].DateTimeOffsetValue.Should().NotBeNull();
            result[nameof(OffsetDateTimeEntity.OffsetDateTime)].DateTimeOffsetValue.Should().Be(date);
        }
Exemplo n.º 2
0
        public void Should_ReadOffsetDateTimeEntity_FromDateTimeOffset()
        {
            var date    = DateTimeOffset.Now;
            var entity  = new OffsetDateTimeEntity();
            var tEntity = (ITableEntity)entity;

            tEntity.ReadEntity(new Dictionary <string, EntityProperty>
            {
                {
                    nameof(OffsetDateTimeEntity.OffsetDateTime),
                    EntityProperty.GeneratePropertyForDateTimeOffset(date)
                }
            }, new OperationContext());

            entity.OffsetDateTime.Should().Be(OffsetDateTime.FromDateTimeOffset(date.UtcDateTime));
        }