Пример #1
0
        public void SerializedCollectViewsFromCache_does_not_scan_from_entry_assembly_if_any_view_assemblies_known()
        {
            var mockCache = new Mock <IViewAssemblyCache>();

            mockCache.Setup(m => m.Assemblies).Returns(new[] { typeof(object).Assembly });

            Dictionary <EntitySetBase, GeneratedView> _;
            Dictionary <Pair <EntitySetBase, Pair <EntityTypeBase, bool> >, GeneratedView> __;
            var viewDictionary = new StorageMappingItemCollection.ViewDictionary(
                new Mock <StorageMappingItemCollection>().Object, out _, out __, mockCache.Object);

            viewDictionary.SerializedCollectViewsFromCache(
                new Mock <MetadataWorkspace>().Object,
                new Mock <Dictionary <EntitySetBase, GeneratedView> >().Object,
                () => typeof(object).Assembly);

            mockCache.Verify(m => m.Assemblies, Times.Exactly(2));
            mockCache.Verify(m => m.CheckAssembly(It.IsAny <Assembly>(), It.IsAny <bool>()), Times.Never());
        }
Пример #2
0
        public void SerializedCollectViewsFromCache_performs_scan_from_entry_assembly_if_no_view_assemblies_known()
        {
            var mockCache = new Mock <IViewAssemblyCache>();

            mockCache.Setup(m => m.Assemblies).Returns(Enumerable.Empty <Assembly>());

            Dictionary <EntitySetBase, GeneratedView> _;
            Dictionary <Pair <EntitySetBase, Pair <EntityTypeBase, bool> >, GeneratedView> __;
            var viewDictionary = new StorageMappingItemCollection.ViewDictionary(
                new Mock <StorageMappingItemCollection>().Object, out _, out __, mockCache.Object);

            viewDictionary.SerializedCollectViewsFromCache(
                new Mock <MetadataWorkspace>().Object,
                new Mock <Dictionary <EntitySetBase, GeneratedView> >().Object,
                () => typeof(object).Assembly);

            mockCache.Verify(m => m.Assemblies, Times.Exactly(2));
            mockCache.Verify(m => m.CheckAssembly(typeof(object).Assembly, true), Times.Once());
        }