Пример #1
0
        public void LoadResources_MigrateBinResources_DirectoryExits_True()
        {
            //------------------Arrange---------------
            const string resourceDirectory = "Resources - ServerTests";

            var mockWriter    = new Mock <IWriter>();
            var mockDirectory = new Mock <IDirectory>();
            var mockResourceCatalogFactory = new Mock <IResourceCatalogFactory>();

            mockDirectory.Setup(o => o.Exists(It.IsAny <string>())).Returns(true);
            //------------------Act-------------------
            var loadResources = new LoadResources(resourceDirectory, mockWriter.Object, mockDirectory.Object, mockResourceCatalogFactory.Object);

            loadResources.MigrateBinResources();
            //------------------Assert----------------
            mockDirectory.Verify(o => o.Copy(It.IsAny <string>(), It.IsAny <string>(), true), Times.Never);
            mockDirectory.Verify(o => o.CleanUp(It.IsAny <string>()), Times.Never);
        }
Пример #2
0
        public void LoadResources_MigrateBinResources_DirectoryExits_False()
        {
            //------------------Arrange---------------
            const string resourceDirectory = "Resources - ServerTests";

            var mockWriter    = new Mock <IWriter>();
            var mockDirectory = new Mock <IDirectory>();
            var mockResourceCatalogFactory = new Mock <IResourceCatalogFactory>();

            mockDirectory.Setup(o => o.Exists(EnvironmentVariables.ResourcePath)).Returns(false);
            mockDirectory.Setup(o => o.Exists(Path.Combine(EnvironmentVariables.ApplicationPath, "Resources"))).Returns(true);
            mockDirectory.Setup(o => o.Copy(It.IsAny <string>(), It.IsAny <string>(), true))
            .Verifiable();
            mockDirectory.Setup(o => o.CleanUp(It.IsAny <string>()))
            .Verifiable();
            //------------------Act-------------------
            var loadResources = new LoadResources(resourceDirectory, mockWriter.Object, mockDirectory.Object, mockResourceCatalogFactory.Object);

            loadResources.MigrateBinResources();
            //------------------Assert----------------
            mockDirectory.Verify();
        }