Exemple #1
0
        public void Assemblies_can_be_called_from_multiple_threads_concurrently()
        {
            var expectedAssemblies = new[] { typeof(PregenContextEdmxViews).Assembly };
            var cache = new ViewAssemblyCache();

            cache.CheckAssembly(typeof(PregenContextEdmxViews).Assembly, followReferences: true);
            ExecuteInParallel(() => Assert.Equal(expectedAssemblies, cache.Assemblies));
        }
        public void CheckAssembly_scans_assembly_only_if_it_has_not_already_been_scanned()
        {
            var mockChecker = new Mock<ViewAssemblyChecker>();
            var cache = new ViewAssemblyCache(mockChecker.Object);

            cache.CheckAssembly(typeof(object).Assembly, followReferences: false);
            mockChecker.Verify(m => m.IsViewAssembly(typeof(object).Assembly), Times.Once());

            cache.CheckAssembly(typeof(object).Assembly, followReferences: false);
            mockChecker.Verify(m => m.IsViewAssembly(typeof(object).Assembly), Times.Once());
        }
        public void CheckAssembly_can_scan_all_referenced_assemblies()
        {
            var mockChecker = new Mock<ViewAssemblyChecker>();
            mockChecker.Setup(m => m.IsViewAssembly(typeof(DbContext).Assembly)).Returns(true);
            mockChecker.Setup(m => m.IsViewAssembly(typeof(RequiredAttribute).Assembly)).Returns(true);

            var cache = new ViewAssemblyCache(mockChecker.Object);

            cache.CheckAssembly(typeof(DbContext).Assembly, followReferences: true);
            Assert.Equal(new[] { typeof(DbContext).Assembly, typeof(RequiredAttribute).Assembly }, cache.Assemblies);
        }
Exemple #4
0
        public void CheckAssembly_scans_assembly_only_if_it_has_not_already_been_scanned()
        {
            var mockChecker = new Mock <ViewAssemblyChecker>();
            var cache       = new ViewAssemblyCache(mockChecker.Object);

            cache.CheckAssembly(typeof(object).Assembly, followReferences: false);
            mockChecker.Verify(m => m.IsViewAssembly(typeof(object).Assembly), Times.Once());

            cache.CheckAssembly(typeof(object).Assembly, followReferences: false);
            mockChecker.Verify(m => m.IsViewAssembly(typeof(object).Assembly), Times.Once());
        }
Exemple #5
0
        public void CheckAssembly_can_scan_all_referenced_assemblies()
        {
            var mockChecker = new Mock <ViewAssemblyChecker>();

            mockChecker.Setup(m => m.IsViewAssembly(typeof(DbContext).Assembly)).Returns(true);
            mockChecker.Setup(m => m.IsViewAssembly(typeof(RequiredAttribute).Assembly)).Returns(true);

            var cache = new ViewAssemblyCache(mockChecker.Object);

            cache.CheckAssembly(typeof(DbContext).Assembly, followReferences: true);
            Assert.Equal(new[] { typeof(DbContext).Assembly, typeof(RequiredAttribute).Assembly }, cache.Assemblies);
        }
Exemple #6
0
        public void Clear_can_be_called_from_multiple_threads_concurrently()
        {
            var cache = new ViewAssemblyCache();

            cache.CheckAssembly(typeof(PregenContextEdmxViews).Assembly, followReferences: true);
            ExecuteInParallel(
                () =>
            {
                cache.Clear();
                Assert.Equal(Enumerable.Empty <Assembly>(), cache.Assemblies);
            });
        }
        public void CheckAssembly_does_not_processes_assembly_again_if_references_were_already_scanned()
        {
            var mockChecker = new Mock<ViewAssemblyChecker>();
            var cache = new ViewAssemblyCache(mockChecker.Object);

            cache.CheckAssembly(typeof(DbContext).Assembly, followReferences: true);
            mockChecker.Verify(m => m.IsViewAssembly(typeof(DbContext).Assembly), Times.Once());
            mockChecker.Verify(m => m.IsViewAssembly(typeof(RequiredAttribute).Assembly), Times.Once());

            cache.CheckAssembly(typeof(DbContext).Assembly, followReferences: true);
            mockChecker.Verify(m => m.IsViewAssembly(typeof(DbContext).Assembly), Times.Once());
            mockChecker.Verify(m => m.IsViewAssembly(typeof(RequiredAttribute).Assembly), Times.Once());
        }
        public void CheckAssembly_processes_assembly_again_if_previously_references_were_not_scanned_but_now_they_should_be()
        {
            var mockChecker = new Mock<ViewAssemblyChecker>();
            var cache = new ViewAssemblyCache(mockChecker.Object);

            cache.CheckAssembly(typeof(DbContext).Assembly, followReferences: false);
            mockChecker.Verify(m => m.IsViewAssembly(typeof(DbContext).Assembly), Times.Once());
            mockChecker.Verify(m => m.IsViewAssembly(typeof(RequiredAttribute).Assembly), Times.Never());

            cache.CheckAssembly(typeof(DbContext).Assembly, followReferences: true);
            mockChecker.Verify(m => m.IsViewAssembly(typeof(DbContext).Assembly));
            mockChecker.Verify(m => m.IsViewAssembly(typeof(RequiredAttribute).Assembly), Times.Once());
        }
Exemple #9
0
        public void CheckAssembly_does_not_processes_assembly_again_if_references_were_already_scanned()
        {
            var mockChecker = new Mock <ViewAssemblyChecker>();
            var cache       = new ViewAssemblyCache(mockChecker.Object);

            cache.CheckAssembly(typeof(DbContext).Assembly, followReferences: true);
            mockChecker.Verify(m => m.IsViewAssembly(typeof(DbContext).Assembly), Times.Once());
            mockChecker.Verify(m => m.IsViewAssembly(typeof(RequiredAttribute).Assembly), Times.Once());

            cache.CheckAssembly(typeof(DbContext).Assembly, followReferences: true);
            mockChecker.Verify(m => m.IsViewAssembly(typeof(DbContext).Assembly), Times.Once());
            mockChecker.Verify(m => m.IsViewAssembly(typeof(RequiredAttribute).Assembly), Times.Once());
        }
Exemple #10
0
        public void CheckAssembly_processes_assembly_again_if_previously_references_were_not_scanned_but_now_they_should_be()
        {
            var mockChecker = new Mock <ViewAssemblyChecker>();
            var cache       = new ViewAssemblyCache(mockChecker.Object);

            cache.CheckAssembly(typeof(DbContext).Assembly, followReferences: false);
            mockChecker.Verify(m => m.IsViewAssembly(typeof(DbContext).Assembly), Times.Once());
            mockChecker.Verify(m => m.IsViewAssembly(typeof(RequiredAttribute).Assembly), Times.Never());

            cache.CheckAssembly(typeof(DbContext).Assembly, followReferences: true);
            mockChecker.Verify(m => m.IsViewAssembly(typeof(DbContext).Assembly));
            mockChecker.Verify(m => m.IsViewAssembly(typeof(RequiredAttribute).Assembly), Times.Once());
        }
Exemple #11
0
        public void Clear_clears_all_cached_assembly_information()
        {
            var mockChecker = new Mock <ViewAssemblyChecker>();

            mockChecker.Setup(m => m.IsViewAssembly(typeof(object).Assembly)).Returns(true);
            var cache = new ViewAssemblyCache(mockChecker.Object);

            cache.CheckAssembly(typeof(object).Assembly, followReferences: false);
            mockChecker.Verify(m => m.IsViewAssembly(typeof(object).Assembly), Times.Once());
            Assert.Equal(new[] { typeof(object).Assembly }, cache.Assemblies);

            cache.Clear();
            Assert.Equal(Enumerable.Empty <Assembly>(), cache.Assemblies);

            cache.CheckAssembly(typeof(object).Assembly, followReferences: false);
            mockChecker.Verify(m => m.IsViewAssembly(typeof(object).Assembly), Times.Exactly(2));
            Assert.Equal(new[] { typeof(object).Assembly }, cache.Assemblies);
        }
        public void Clear_clears_all_cached_assembly_information()
        {
            var mockChecker = new Mock<ViewAssemblyChecker>();
            mockChecker.Setup(m => m.IsViewAssembly(typeof(object).Assembly)).Returns(true);
            var cache = new ViewAssemblyCache(mockChecker.Object);

            cache.CheckAssembly(typeof(object).Assembly, followReferences: false);
            mockChecker.Verify(m => m.IsViewAssembly(typeof(object).Assembly), Times.Once());
            Assert.Equal(new[] { typeof(object).Assembly }, cache.Assemblies);

            cache.Clear();
            Assert.Equal(Enumerable.Empty<Assembly>(), cache.Assemblies);

            cache.CheckAssembly(typeof(object).Assembly, followReferences: false);
            mockChecker.Verify(m => m.IsViewAssembly(typeof(object).Assembly), Times.Exactly(2));
            Assert.Equal(new[] { typeof(object).Assembly }, cache.Assemblies);
        }
 public void Assemblies_can_be_called_from_multiple_threads_concurrently()
 {
     var expectedAssemblies = new[] { typeof(PregenContextEdmxViews).Assembly };
     var cache = new ViewAssemblyCache();
     cache.CheckAssembly(typeof(PregenContextEdmxViews).Assembly, followReferences: true);
     ExecuteInParallel(() => Assert.Equal(expectedAssemblies, cache.Assemblies));
 }
 public void Clear_can_be_called_from_multiple_threads_concurrently()
 {
     var cache = new ViewAssemblyCache();
     cache.CheckAssembly(typeof(PregenContextEdmxViews).Assembly, followReferences: true);
     ExecuteInParallel(
         () =>
             {
                 cache.Clear();
                 Assert.Equal(Enumerable.Empty<Assembly>(), cache.Assemblies);
             });
 }