public void Convert_PopulatesTimestamp()
        {
            // Arrange
            DateTimeOffset expectedTimestamp = DateTimeOffset.Now;
            IConverter <PocoWithTimestamp, TableEntity> product = CreateProductUnderTest <PocoWithTimestamp>();
            PocoWithTimestamp input = new PocoWithTimestamp
            {
                Timestamp = expectedTimestamp
            };
            // Act
            TableEntity actual = product.Convert(input);

            // Assert
            Assert.NotNull(actual);
            Assert.AreEqual(expectedTimestamp, actual.Timestamp);
            Assert.AreEqual(expectedTimestamp.Offset, actual.Timestamp.Value.Offset);
        }
        public void Convert_PopulatesTimestamp()
        {
            // Arrange
            DateTimeOffset expectedTimestamp = DateTimeOffset.Now;
            IConverter <TableEntity, PocoWithTimestamp> product = CreateProductUnderTest <PocoWithTimestamp>();
            TableEntity entity = new TableEntity
            {
                Timestamp = expectedTimestamp
            };
            // Act
            PocoWithTimestamp actual = product.Convert(entity);

            // Assert
            Assert.NotNull(actual);
            Assert.AreEqual(expectedTimestamp, actual.Timestamp);
            Assert.AreEqual(expectedTimestamp.Offset, actual.Timestamp.Offset);
        }
        public void Convert_IfDictionaryContainsTimestamp_PopulatesFromOfficialTimestamp()
        {
            // Arrange
            DateTimeOffset expectedTimestamp = DateTimeOffset.Now;
            IConverter <TableEntity, PocoWithTimestamp> product = CreateProductUnderTest <PocoWithTimestamp>();
            TableEntity entity = new TableEntity
            {
                Timestamp     = expectedTimestamp,
                ["Timestamp"] = DateTimeOffset.MinValue
            };
            // Act
            PocoWithTimestamp actual = product.Convert(entity);

            // Assert
            Assert.NotNull(actual);
            Assert.AreEqual(expectedTimestamp, actual.Timestamp);
            Assert.AreEqual(expectedTimestamp.Offset, actual.Timestamp.Offset);
        }
        public void Convert_DoesNotIncludeTimestampInDictionary()
        {
            // Arrange
            DateTimeOffset expectedTimestamp = DateTimeOffset.Now;
            IConverter <PocoWithTimestamp, TableEntity> product = CreateProductUnderTest <PocoWithTimestamp>();
            PocoWithTimestamp input = new PocoWithTimestamp
            {
                Timestamp = expectedTimestamp
            };
            // Act
            TableEntity actual = product.Convert(input);

            // Assert
            Assert.NotNull(actual);
            Assert.AreEqual(expectedTimestamp, actual.Timestamp);
            Assert.AreEqual(expectedTimestamp.Offset, actual.Timestamp.Value.Offset);
            Assert.NotNull(actual);
            Assert.False(actual.ContainsKey("Timestamp"));
        }
Esempio n. 5
0
        public void Convert_IfDictionaryContainsTimestamp_PopulatesFromOfficialTimestamp()
        {
            // Arrange
            DateTimeOffset expectedTimestamp = DateTimeOffset.Now;
            IConverter <ITableEntity, PocoWithTimestamp> product = CreateProductUnderTest <PocoWithTimestamp>();
            DynamicTableEntity entity = new DynamicTableEntity
            {
                Timestamp  = expectedTimestamp,
                Properties = new Dictionary <string, EntityProperty>
                {
                    { "Timestamp", new EntityProperty(DateTimeOffset.MinValue) }
                }
            };

            // Act
            PocoWithTimestamp actual = product.Convert(entity);

            // Assert
            Assert.NotNull(actual);
            Assert.Equal(expectedTimestamp, actual.Timestamp);
            Assert.Equal(expectedTimestamp.Offset, actual.Timestamp.Offset);
        }
        public void Convert_DoesNotIncludeTimestampInDictionary()
        {
            // Arrange
            DateTimeOffset expectedTimestamp = DateTimeOffset.Now;
            IConverter <PocoWithTimestamp, ITableEntity> product = CreateProductUnderTest <PocoWithTimestamp>();
            PocoWithTimestamp input = new PocoWithTimestamp
            {
                Timestamp = expectedTimestamp
            };

            // Act
            ITableEntity actual = product.Convert(input);

            // Assert
            Assert.NotNull(actual);
            Assert.Equal(expectedTimestamp, actual.Timestamp);
            Assert.Equal(expectedTimestamp.Offset, actual.Timestamp.Offset);
            IDictionary <string, EntityProperty> properties = actual.WriteEntity(operationContext: null);

            Assert.NotNull(properties);
            Assert.False(properties.ContainsKey("Timestamp"));
        }