public ODataConventionalEntityMetadataBuilderTests()
        {
            #region Product Entry

            this.productEntry = new ODataEntry();
            this.sinlgeKeyCollection = new Dictionary<string, object>() { { "Id", 42 } };
            this.multiKeysCollection = new Dictionary<string, object>() { { "KeyA", "keya" }, { "KeyB", 1 } };

            TestFeedAndEntryTypeContext productTypeContext = new TestFeedAndEntryTypeContext
            {
                NavigationSourceName = EntitySetName,
                NavigationSourceEntityTypeName = EntityTypeName,
                ExpectedEntityTypeName = EntityTypeName,
                IsMediaLinkEntry = false,
                UrlConvention = UrlConvention.CreateWithExplicitValue(/*generateKeyAsSegment*/ false),
                IsFromCollection = false,
                NavigationSourceKind = EdmNavigationSourceKind.EntitySet
            };

            TestEntryMetadataContext productEntryMetadataContext = new TestEntryMetadataContext
            {
                TypeContext = productTypeContext,
                Entry = this.productEntry,
                ETagProperties = new[] { new KeyValuePair<string, object>("Name", "Value") },
                KeyProperties = this.sinlgeKeyCollection,
                ActualEntityTypeName = EntityTypeName,
                SelectedBindableOperations = new IEdmOperation[0],
                SelectedNavigationProperties = new IEdmNavigationProperty[0],
                SelectedStreamProperties = new Dictionary<string, IEdmStructuralProperty>()
            };

            this.productConventionalEntityMetadataBuilder = new ODataConventionalEntityMetadataBuilder(productEntryMetadataContext, this.metadataContext, this.uriBuilder);
            this.productEntry.MetadataBuilder = this.productConventionalEntityMetadataBuilder;

            #endregion Product Entry

            #region Derived, MultiKey, Multi ETag, MLE Entry

            var action = new EdmAction("TestModel", "Action", /*returnType*/ null, /*isBindable*/ true, /*entitySet*/ null);
            var actionImport = new EdmActionImport(TestModel.Container, "Action", action);

            var function = new EdmFunction("TestModel", "Function", /*returnType*/ EdmCoreModel.Instance.GetInt32(true), /*isBindable*/ true, /*entitySet*/ null, false /*isComposable*/);
            var functionImport = new EdmFunctionImport(TestModel.Container, "Function", function);
            this.derivedMultiKeyMultiEtagMleEntry = new ODataEntry();
            TestFeedAndEntryTypeContext derivedMultiKeyMultiEtagMleTypeContext = new TestFeedAndEntryTypeContext
            {
                NavigationSourceName = EntitySetName,
                NavigationSourceEntityTypeName = EntityTypeName,
                ExpectedEntityTypeName = DerivedEntityTypeName,
                IsMediaLinkEntry = true,
                UrlConvention = UrlConvention.CreateWithExplicitValue(/*generateKeyAsSegment*/ false),
                IsFromCollection = false
            };
            TestEntryMetadataContext derivedProductMleEntryMetadataContext = new TestEntryMetadataContext
            {
                TypeContext = derivedMultiKeyMultiEtagMleTypeContext,
                Entry = this.derivedMultiKeyMultiEtagMleEntry,
                ETagProperties = new[] { new KeyValuePair<string, object>("ETag1", "ETagValue1"), new KeyValuePair<string, object>("ETag2", "ETagValue2") },
                KeyProperties = this.multiKeysCollection,
                ActualEntityTypeName = DerivedMleEntityTypeName,
                SelectedBindableOperations = new IEdmOperation[] 
                {
                    action,
                    function
                },
                SelectedNavigationProperties = TestModel.ProductWithNavPropsType.NavigationProperties(),
                SelectedStreamProperties = new Dictionary<string, IEdmStructuralProperty>
                {
                    {"Photo", new EdmStructuralProperty(TestModel.ProductType, "Photo", EdmCoreModel.Instance.GetStream( /*isNullable*/true))}
                },
            };

            this.derivedMultiKeyMultiEtagMleConventionalEntityMetadataBuilder = new ODataConventionalEntityMetadataBuilder(derivedProductMleEntryMetadataContext, this.metadataContext, this.uriBuilder);
            this.derivedMultiKeyMultiEtagMleEntry.MetadataBuilder = this.derivedMultiKeyMultiEtagMleConventionalEntityMetadataBuilder;

            #endregion Derived, MultiKey, Multi ETag, MLE Entry

            #region Contained Product Entry

            this.containedCollectionProductEntry = new ODataEntry();
            this.containedSinlgeKeyCollection = new Dictionary<string, object>() { { "Id", 43 } };
            this.containedMultiKeysCollection = new Dictionary<string, object>() { { "KeyA", "keya" }, { "KeyB", 2 } };

            TestFeedAndEntryTypeContext containedCollectionProductTypeContext = new TestFeedAndEntryTypeContext
            {
                NavigationSourceName = EntitySetName,
                NavigationSourceEntityTypeName = EntityTypeName,
                ExpectedEntityTypeName = EntityTypeName,
                IsMediaLinkEntry = false,
                UrlConvention = UrlConvention.CreateWithExplicitValue(/*generateKeyAsSegment*/ false),
                NavigationSourceKind = EdmNavigationSourceKind.ContainedEntitySet,
                IsFromCollection = true
            };

            TestEntryMetadataContext containedCollectionProductEntryMetadataContext = new TestEntryMetadataContext
            {
                TypeContext = containedCollectionProductTypeContext,
                Entry = this.containedCollectionProductEntry,
                ETagProperties = new[] { new KeyValuePair<string, object>("Name", "Value") },
                KeyProperties = this.containedSinlgeKeyCollection,
                ActualEntityTypeName = EntityTypeName,
                SelectedBindableOperations = new IEdmOperation[0],
                SelectedNavigationProperties = new IEdmNavigationProperty[0],
                SelectedStreamProperties = new Dictionary<string, IEdmStructuralProperty>()
            };

            this.containedCollectionProductConventionalEntityMetadataBuilder = new ODataConventionalEntityMetadataBuilder(containedCollectionProductEntryMetadataContext, this.metadataContext, this.uriBuilder);
            this.containedCollectionProductEntry.MetadataBuilder = this.containedCollectionProductConventionalEntityMetadataBuilder;
            this.containedCollectionProductEntry.MetadataBuilder.ParentMetadataBuilder = this.productConventionalEntityMetadataBuilder;

            this.containedProductEntry = new ODataEntry();
            this.containedSinlgeKeyCollection = new Dictionary<string, object>() { { "Id", 43 } };
            this.containedMultiKeysCollection = new Dictionary<string, object>() { { "KeyA", "keya" }, { "KeyB", 2 } };

            TestFeedAndEntryTypeContext containedProductTypeContext = new TestFeedAndEntryTypeContext
            {
                NavigationSourceName = EntitySetName,
                NavigationSourceEntityTypeName = EntityTypeName,
                ExpectedEntityTypeName = EntityTypeName,
                IsMediaLinkEntry = false,
                UrlConvention = UrlConvention.CreateWithExplicitValue(/*generateKeyAsSegment*/ false),
                NavigationSourceKind = EdmNavigationSourceKind.ContainedEntitySet,
                IsFromCollection = false
            };

            TestEntryMetadataContext containedProductEntryMetadataContext = new TestEntryMetadataContext
            {
                TypeContext = containedProductTypeContext,
                Entry = this.containedCollectionProductEntry,
                ETagProperties = new[] { new KeyValuePair<string, object>("Name", "Value") },
                KeyProperties = this.containedSinlgeKeyCollection,
                ActualEntityTypeName = EntityTypeName,
                SelectedBindableOperations = new IEdmOperation[0],
                SelectedNavigationProperties = new IEdmNavigationProperty[0],
                SelectedStreamProperties = new Dictionary<string, IEdmStructuralProperty>()
            };

            this.containedProductConventionalEntityMetadataBuilder = new ODataConventionalEntityMetadataBuilder(containedProductEntryMetadataContext, this.metadataContext, this.uriBuilder);
            this.containedProductEntry.MetadataBuilder = this.containedProductConventionalEntityMetadataBuilder;
            this.containedProductEntry.MetadataBuilder.ParentMetadataBuilder = this.productConventionalEntityMetadataBuilder;

            #endregion
        }
        public void TestSingletonIdAndEditLink()
        {
            var singletonEntryTypeContext = new TestFeedAndEntryTypeContext
            {
                NavigationSourceName = "Boss",
                NavigationSourceEntityTypeName = "BossType",
                ExpectedEntityTypeName = "BossType",
                UrlConvention = UrlConvention.CreateWithExplicitValue(/*generateKeyAsSegment*/ false),
                NavigationSourceKind = EdmNavigationSourceKind.Singleton,
            };

            var singletonEntryMetadataContext = new TestEntryMetadataContext
            {
                TypeContext = singletonEntryTypeContext,
                Entry = new ODataEntry(),
                ETagProperties = new[] { new KeyValuePair<string, object>("Name", "Value") },
                KeyProperties = this.sinlgeKeyCollection,
                ActualEntityTypeName = "BossType",
                SelectedBindableOperations = new IEdmOperation[0],
                SelectedNavigationProperties = new IEdmNavigationProperty[0],
                SelectedStreamProperties = new Dictionary<string, IEdmStructuralProperty>(),
            };

            var singletonEntityMetadataBuilder = new ODataConventionalEntityMetadataBuilder(singletonEntryMetadataContext, this.metadataContext, this.uriBuilder);
            singletonEntityMetadataBuilder.GetId().Should().Be(new Uri("http://odata.org/base/Boss"));
            singletonEntityMetadataBuilder.GetEditLink().Should().Be(new Uri("http://odata.org/base/Boss"));
            singletonEntityMetadataBuilder.GetReadLink().Should().Be(new Uri("http://odata.org/base/Boss"));
        }