private static void AssertPropertyEqual <T>(T expected,
                                                    TableEntity entity,
                                                    string propertyName)
            where T : class
        {
            Assert.NotNull(entity);
            Assert.True(entity.ContainsKey(propertyName));
            var actualValue = entity[propertyName];

            Assert.AreEqual(expected, actualValue);
        }
        public void Convert_DoesNotIncludePartitionKeyInDictionary()
        {
            // Arrange
            const string expectedPartitionKey = "PK";
            IConverter <PocoWithPartitionKey, TableEntity> product = CreateProductUnderTest <PocoWithPartitionKey>();
            PocoWithPartitionKey input = new PocoWithPartitionKey
            {
                PartitionKey = expectedPartitionKey
            };
            // Act
            TableEntity actual = product.Convert(input);

            // Assert
            Assert.NotNull(actual);
            Assert.AreSame(expectedPartitionKey, actual.PartitionKey);
            Assert.False(actual.ContainsKey("PartitionKey"));
        }
        public void Convert_DoesNotIncludeETagInDictionary()
        {
            // Arrange
            const string expectedETag = "RK";
            IConverter <PocoWithETag, TableEntity> product = CreateProductUnderTest <PocoWithETag>();
            PocoWithETag input = new PocoWithETag
            {
                ETag = expectedETag
            };
            // Act
            TableEntity actual = product.Convert(input);

            // Assert
            Assert.NotNull(actual);
            Assert.AreEqual(new ETag(expectedETag), actual.ETag);
            Assert.NotNull(actual);
            Assert.False(actual.ContainsKey("ETag"));
        }
Example #4
0
        public void Convert_DoesNotIncludeRowKeyInDictionary()
        {
            // Arrange
            const string   expectedRowKey = "RK";
            var            product        = CreateProductUnderTest <PocoWithRowKey>();
            PocoWithRowKey input          = new PocoWithRowKey
            {
                RowKey = expectedRowKey
            };
            // Act
            TableEntity actual = product.Convert(input);

            // Assert
            Assert.NotNull(actual);
            Assert.AreSame(expectedRowKey, actual.RowKey);
            Assert.NotNull(actual);
            Assert.False(actual.ContainsKey("RowKey"));
        }
        public void Convert_IfOtherPropertyIsIndexer_Ignores()
        {
            // Arrange
            const string expectedPartitionKey = "PK";
            IConverter <PocoWithIndexerOtherProperty, TableEntity> product =
                CreateProductUnderTest <PocoWithIndexerOtherProperty>();
            PocoWithIndexerOtherProperty input = new PocoWithIndexerOtherProperty
            {
                PartitionKey = expectedPartitionKey
            };
            // Act
            TableEntity actual = product.Convert(input);

            // Assert
            Assert.NotNull(actual);
            Assert.NotNull(actual);
            Assert.False(actual.ContainsKey("OtherProperty"));
            Assert.AreSame(expectedPartitionKey, actual.PartitionKey);
        }
        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"));
        }
Example #7
0
        public void Convert_IfOtherPropertyGetterIsPrivate_Ignores()
        {
            // Arrange
            const string expectedPartitionKey = "PK";
            var          product =
                CreateProductUnderTest <PocoWithPrivateOtherPropertyGetter>();
            PocoWithPrivateOtherPropertyGetter input = new PocoWithPrivateOtherPropertyGetter
            {
                PartitionKey  = expectedPartitionKey,
                OtherProperty = 456
            };
            // Act
            TableEntity actual = product.Convert(input);

            // Assert
            Assert.NotNull(actual);
            Assert.NotNull(actual);
            Assert.False(actual.ContainsKey("OtherProperty"));
            Assert.AreSame(expectedPartitionKey, actual.PartitionKey);
        }
        public void Convert_PopulatesOtherProperty()
        {
            // Arrange
            int?expectedOtherProperty = 123;
            IConverter <PocoWithOtherProperty, TableEntity> product = CreateProductUnderTest <PocoWithOtherProperty>();
            PocoWithOtherProperty input = new PocoWithOtherProperty
            {
                OtherProperty = expectedOtherProperty
            };
            // Act
            TableEntity actual = product.Convert(input);

            // Assert
            Assert.NotNull(actual);
            Assert.NotNull(actual);
            Assert.True(actual.ContainsKey("OtherProperty"));
            var otherProperty = actual["OtherProperty"];

            Assert.NotNull(otherProperty);
            Assert.AreEqual(expectedOtherProperty, otherProperty);
        }
 private static void AssertPropertyNull(TableEntity entity,
                                        string propertyName)
 {
     Assert.NotNull(entity);
     Assert.False(entity.ContainsKey(propertyName));
 }