Ejemplo n.º 1
0
        public void LoadResources_LoadActivityCache_Success()
        {
            //------------------Arrange---------------
            const string resourceDirectory = "Resources - ServerTests";

            var mockWriter                 = new Mock <IWriter>();
            var mockDirectory              = new Mock <IDirectory>();
            var mockResourceCatalog        = new Mock <IResourceCatalog>();
            var mockResourceCatalogFactory = new Mock <IResourceCatalogFactory>();
            var mockAssemblyLoader         = new Mock <IAssemblyLoader>();

            mockResourceCatalogFactory.Setup(o => o.New()).Returns(mockResourceCatalog.Object);
            mockResourceCatalog.Setup(o => o.CleanUpOldVersionControlStructure()).Verifiable();
            mockResourceCatalog.Setup(o => o.LoadServerActivityCache()).Verifiable();

            mockWriter.Setup(o => o.Write("Loading resource activity cache...  ")).Verifiable();
            mockWriter.Setup(o => o.Write("Preloading assemblies...  ")).Verifiable();


            mockAssemblyLoader.Setup(o => o.AssemblyNames(It.IsAny <Assembly>())).Returns(new AssemblyName[] { new AssemblyName()
                                                                                                               {
                                                                                                                   Name = "testAssemblyName"
                                                                                                               } });
            //------------------Act-------------------
            var loadResources = new LoadResources(resourceDirectory, mockWriter.Object, mockDirectory.Object, mockResourceCatalogFactory.Object);

            loadResources.LoadActivityCache(mockAssemblyLoader.Object);
            //------------------Assert----------------
            mockWriter.Verify(o => o.WriteLine("done."), Times.Exactly(2));
            mockWriter.Verify();
        }