Beispiel #1
0
        public void Should_WriteLocalDateTimeEntity()
        {
            var date   = DateTime.Now;
            var entity = new LocalDateTimeEntity()
            {
                LocalDateTime = LocalDateTime.FromDateTime(date)
            };
            var tEntity = (ITableEntity)entity;

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

            result.Should().ContainKey(nameof(LocalDateTimeEntity.LocalDateTime));
            result[nameof(LocalDateTimeEntity.LocalDateTime)].DateTimeOffsetValue.Should().NotBeNull();
            result[nameof(LocalDateTimeEntity.LocalDateTime)].DateTimeOffsetValue.Should().Be(date);
        }
Beispiel #2
0
        public void Should_ReadLocalDateTimeEntity_FromDateTimeOffset()
        {
            var date    = DateTime.Now;
            var entity  = new LocalDateTimeEntity();
            var tEntity = (ITableEntity)entity;

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

            entity.LocalDateTime.Should().BeLessOrEqualTo(LocalDateTime.FromDateTime(date.ToUniversalTime()));
        }
Beispiel #3
0
        public void Should_ReadLocalDateTimeEntity()
        {
            var date    = DateTime.Now;
            var entity  = new LocalDateTimeEntity();
            var tEntity = (ITableEntity)entity;

            tEntity.ReadEntity(new Dictionary <string, EntityProperty>
            {
                {
                    nameof(LocalDateTimeEntity.LocalDateTime),
                    EntityProperty.GeneratePropertyForString(LocalDateTimePattern.ExtendedIso.Format(LocalDateTime.FromDateTime(date)))
                }
            }, new OperationContext());

            entity.LocalDateTime.Should().BeLessOrEqualTo(LocalDateTime.FromDateTime(date));
        }