• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ScriptCsArgs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ScriptCsArgs的典型用法代码示例。如果您正苦于以下问题:C# ScriptCsArgs类的具体用法?C# ScriptCsArgs怎么用?C# ScriptCsArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ScriptCsArgs类属于命名空间,在下文中一共展示了ScriptCsArgs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: NonManagedAssembliesAreExcluded

            public void NonManagedAssembliesAreExcluded(
                [Frozen] Mock<IFileSystem> fileSystem,
                [Frozen] Mock<IAssemblyUtility> assemblyUtility,
                [Frozen] Mock<IScriptExecutor> executor,
                CommandFactory factory)
            {
                // Arrange
                const string NonManaged = "non-managed.dll";

                var args = new ScriptCsArgs { AllowPreRelease = false, Install = "", ScriptName = "test.csx" };

                fileSystem.SetupGet(x => x.CurrentDirectory).Returns(CurrentDirectory);
                fileSystem.Setup(x => x.EnumerateFiles(It.IsAny<string>(), It.IsAny<string>(), SearchOption.AllDirectories))
                          .Returns(new[] { "managed.dll", NonManaged });

                assemblyUtility.Setup(x => x.IsManagedAssembly(It.Is<string>(y => y == NonManaged))).Returns(false);

                // Act
                factory.CreateCommand(args, new string[0]).Execute();

                // Assert
                executor.Verify(i => i.Initialize(It.Is<IEnumerable<string>>(x => !x.Contains(NonManaged)), It.IsAny<IEnumerable<IScriptPack>>()), Times.Once());
                executor.Verify(i => i.Execute(It.Is<string>(x => x == "test.csx"), It.IsAny<string[]>()), Times.Once());
                executor.Verify(i => i.Terminate(), Times.Once());
            }
开发者ID:jden,项目名称:scriptcs,代码行数:25,代码来源:ExecuteScriptCommandTests.cs


示例2: ShouldCreateBinFolderIfItDoesNotExist

            public void ShouldCreateBinFolderIfItDoesNotExist()
            {
                var args = new ScriptCsArgs { Restore = true, ScriptName = "" };

                var fs = new Mock<IFileSystem>();
                var resolver = new Mock<IPackageAssemblyResolver>();
                var executor = new Mock<IScriptExecutor>();
                var scriptpackResolver = new Mock<IScriptPackResolver>();
                var packageInstaller = new Mock<IPackageInstaller>();
                var root = new ScriptServiceRoot(fs.Object, resolver.Object, executor.Object, scriptpackResolver.Object, packageInstaller.Object);

                const string CurrentDirectory = @"C:\";
                const string BinFolder = @"C:\bin";

                fs.Setup(x => x.GetWorkingDirectory(It.IsAny<string>())).Returns(CurrentDirectory);

                var binFolderCreated = false;

                fs.Setup(x => x.DirectoryExists(BinFolder)).Returns(() => binFolderCreated).Verifiable();
                fs.Setup(x => x.CreateDirectory(BinFolder)).Callback(() => binFolderCreated = true).Verifiable();

                var factory = new CommandFactory(root);
                var result = factory.CreateCommand(args);

                result.Execute();

                fs.Verify(x => x.DirectoryExists(BinFolder), Times.AtLeastOnce());
                fs.Verify(x => x.CreateDirectory(BinFolder), Times.Once());
            }
开发者ID:bangoker,项目名称:scriptcs,代码行数:29,代码来源:RestoreCommandTests.cs


示例3: ReconcileArguments

        private static ScriptCsArgs ReconcileArguments(ScriptCsArgs configArgs, ScriptCsArgs commandArgs, SplitResult splitResult)
        {
            if (configArgs == null)
                return commandArgs;

            if (commandArgs == null)
                return configArgs;

            foreach (var property in typeof(ScriptCsArgs).GetProperties(BindingFlags.Instance | BindingFlags.Public))
            {
                var configValue = property.GetValue(configArgs);
                var commandValue = property.GetValue(commandArgs);
                var defaultValue = GetPropertyDefaultValue(property);

                if (!object.Equals(configValue, commandValue))
                {
                    if (!object.Equals(commandValue, defaultValue))
                    {
                        property.SetValue(configArgs, commandValue);
                    }
                    else
                    {
                        if (IsCommandLinePresent(splitResult.CommandArguments, property))
                            property.SetValue(configArgs, commandValue);
                    }
                }
            }

            return configArgs;
        }
开发者ID:selony,项目名称:scriptcs,代码行数:30,代码来源:ArgumentHandler.cs


示例4: WhenPassedAScript_ShouldPressedReplWithScript

            public void WhenPassedAScript_ShouldPressedReplWithScript(
                [Frozen] Mock<IScriptEngine> scriptEngine, 
                [Frozen] Mock<IFileSystem> fileSystem, 
                [Frozen] Mock<IConsole> console,
                [Frozen] Mock<IScriptServicesBuilder> servicesBuilder,
                [Frozen] Mock<IInitializationServices> initializationServices,
                ScriptServices services)
            {
                // Arrange
                var args = new ScriptCsArgs { Repl = true, ScriptName = "test.csx" };

                console.Setup(x => x.ReadLine()).Returns(() =>
                {
                    console.Setup(x => x.ReadLine()).Throws(new Exception());
                    return string.Empty;
                });
                fileSystem.SetupGet(x => x.CurrentDirectory).Returns("C:\\");
                servicesBuilder.Setup(b => b.Build()).Returns(services);
                //initializationServices.Setup(i => i.GetFileSystem()).Returns(fileSystem.Object);
                scriptEngine.Setup(
                    x => x.Execute("#load test.csx", It.IsAny<string[]>(), It.IsAny<AssemblyReferences>(), It.IsAny<IEnumerable<string>>(), It.IsAny<ScriptPackSession>()));

                servicesBuilder.SetupGet(b => b.InitializationServices).Returns(initializationServices.Object);
                initializationServices.Setup(i => i.GetFileSystem()).Returns(fileSystem.Object);

                var factory = new CommandFactory(servicesBuilder.Object);

                // Act
                factory.CreateCommand(args, new string[0]).Execute();

                // Assert
                scriptEngine.Verify();
            }
开发者ID:selony,项目名称:scriptcs,代码行数:33,代码来源:ExecuteReplCommandTests.cs


示例5: ScriptExecCommandShouldInvokeWithScriptPassedFromArgs

            public void ScriptExecCommandShouldInvokeWithScriptPassedFromArgs()
            {
                var args = new ScriptCsArgs
                    {
                        AllowPreRelease = false,
                        Install = "",
                        ScriptName = "test.csx"
                    };

                var fs = new Mock<IFileSystem>();
                var resolver = new Mock<IPackageAssemblyResolver>();
                var executor = new Mock<IScriptExecutor>();
                var engine = new Mock<IScriptEngine>();
                var scriptpackResolver = new Mock<IScriptPackResolver>();
                var packageInstaller = new Mock<IPackageInstaller>();
                var logger = new Mock<ILog>();
                var filePreProcessor = new Mock<IFilePreProcessor>();
                var root = new ScriptServiceRoot(fs.Object, resolver.Object, executor.Object, engine.Object, filePreProcessor.Object, scriptpackResolver.Object, packageInstaller.Object, logger.Object);

                var factory = new CommandFactory(root);
                var result = factory.CreateCommand(args);

                result.Execute();

                executor.Verify(i => i.Execute(It.Is<string>(x => x == "test.csx"), It.IsAny<IEnumerable<string>>(), It.IsAny<IEnumerable<IScriptPack>>()), Times.Once());
            }
开发者ID:ChowZenki,项目名称:scriptcs,代码行数:26,代码来源:ExecuteScriptCommandTests.cs


示例6: ShouldCreateMissingBinFolder

            public void ShouldCreateMissingBinFolder()
            {
                const string WorkingDirectory = @"C:\";

                var binFolder = Path.Combine(WorkingDirectory, "bin");

                var args = new ScriptCsArgs { ScriptName = "test.csx" };

                var fs = new Mock<IFileSystem>();
                fs.Setup(x => x.GetWorkingDirectory(It.IsAny<string>())).Returns(WorkingDirectory);
                fs.Setup(x => x.DirectoryExists(binFolder)).Returns(false);

                var resolver = new Mock<IPackageAssemblyResolver>();
                var executor = new Mock<IScriptExecutor>();
                var engine = new Mock<IScriptEngine>();
                var scriptpackResolver = new Mock<IScriptPackResolver>();
                var packageInstaller = new Mock<IPackageInstaller>();
                var logger = new Mock<ILog>();
                var filePreProcessor = new Mock<IFilePreProcessor>();
                var root = new ScriptServiceRoot(fs.Object, resolver.Object, executor.Object, engine.Object, filePreProcessor.Object, scriptpackResolver.Object, packageInstaller.Object, logger.Object);

                var factory = new CommandFactory(root);
                var result = factory.CreateCommand(args);

                result.Execute();

                fs.Verify(x => x.CreateDirectory(binFolder), Times.Once());
            }
开发者ID:ChowZenki,项目名称:scriptcs,代码行数:28,代码来源:ExecuteScriptCommandTests.cs


示例7: ShouldDeletePackagesFolder

            public void ShouldDeletePackagesFolder()
            {
                var args = new ScriptCsArgs { Clean = true };

                var fs = new Mock<IFileSystem>();
                var resolver = new Mock<IPackageAssemblyResolver>();
                var executor = new Mock<IScriptExecutor>();
                var engine = new Mock<IScriptEngine>();
                var scriptpackResolver = new Mock<IScriptPackResolver>();
                var packageInstaller = new Mock<IPackageInstaller>();
                var logger = new Mock<ILog>();
                var filePreProcessor = new Mock<IFilePreProcessor>();
                var assemblyName = new Mock<IAssemblyName>();

                var root = new ScriptServiceRoot(fs.Object, resolver.Object, executor.Object, engine.Object, filePreProcessor.Object, scriptpackResolver.Object, packageInstaller.Object, logger.Object, assemblyName.Object);
                fs.Setup(i => i.DirectoryExists(It.Is<string>(x => x.Contains(Constants.PackagesFolder)))).Returns(true);
                fs.Setup(i => i.GetWorkingDirectory(It.IsAny<string>())).Returns("c:\\");

                var factory = new CommandFactory(root);
                var result = factory.CreateCommand(args, new string[0]);

                result.Execute();

                fs.Verify(i => i.DirectoryExists(It.Is<string>(x => x.Contains(Constants.PackagesFolder))), Times.Once());
                fs.Verify(i => i.DeleteDirectory(It.Is<string>(x => x.Contains(Constants.PackagesFolder))), Times.Once());
            }
开发者ID:7sharp9,项目名称:scriptcs,代码行数:26,代码来源:CleanCommandTests.cs


示例8: WatchScriptCommand

        public WatchScriptCommand(
            ScriptCsArgs commandArgs,
            string[] scriptArgs,
            IConsole console,
            IFileSystem fileSystem,
            ILog logger,
            IFileSystemMigrator fileSystemMigrator)
        {
            Guard.AgainstNullArgument("commandArgs", commandArgs);
            Guard.AgainstNullArgument("scriptArgs", scriptArgs);
            Guard.AgainstNullArgument("console", console);
            Guard.AgainstNullArgument("fileSystem", fileSystem);
            Guard.AgainstNullArgument("logger", logger);
            Guard.AgainstNullArgument("fileSystemMigrator", fileSystemMigrator);

            _commandArgs = commandArgs;
            _scriptArgs = scriptArgs;
            _console = console;
            _fileSystem = fileSystem;
            _logger = logger;
            _fileSystemMigrator = fileSystemMigrator;

            _executeScriptCommand = new CrossAppDomainExecuteScriptCommand
            {
                CommandArgs = _commandArgs,
                ScriptArgs = _scriptArgs,
            };
        }
开发者ID:nagyistoce,项目名称:scriptcs,代码行数:28,代码来源:WatchScriptCommand.cs


示例9: VersionCommandShouldOutputVersion

            public void VersionCommandShouldOutputVersion()
            {
                var args = new ScriptCsArgs
                    {
                        Version = true
                    };

                var fs = new Mock<IFileSystem>();
                var resolver = new Mock<IPackageAssemblyResolver>();
                var executor = new Mock<IScriptExecutor>();
                var engine = new Mock<IScriptEngine>();
                var scriptpackResolver = new Mock<IScriptPackResolver>();
                var packageInstaller = new Mock<IPackageInstaller>();
                var logger = new Mock<ILog>();
                var filePreProcessor = new Mock<IFilePreProcessor>();
                var root = new ScriptServiceRoot(fs.Object, resolver.Object, executor.Object, engine.Object, filePreProcessor.Object, scriptpackResolver.Object, packageInstaller.Object, logger.Object);

                var factory = new CommandFactory(root);
                var result = factory.CreateCommand(args);

                // clear the fake console output
                _outputText.Clear();

                result.Execute();

                Assert.Contains("scriptcs version " + _currentVersion.ToString(), _outputText.ToString());
            }
开发者ID:ChowZenki,项目名称:scriptcs,代码行数:27,代码来源:VersionCommandTests.cs


示例10: NonManagedAssembliesAreExcluded

            public void NonManagedAssembliesAreExcluded(
                [Frozen] Mock<IFileSystem> fileSystem,
                [Frozen] Mock<IAssemblyUtility> assemblyUtility,
                [Frozen] Mock<IScriptExecutor> executor,
                [Frozen] Mock<IInitializationServices> initializationServices,
                ScriptServices services)
            {
                // Arrange
                const string NonManaged = "non-managed.dll";

                var args = new ScriptCsArgs { AllowPreRelease = false, Install = "", ScriptName = "test.csx" };
                var fixture = new Fixture().Customize(new AutoMoqCustomization());
                var servicesBuilder = fixture.Freeze<Mock<IScriptServicesBuilder>>();

                fileSystem.SetupGet(x => x.CurrentDirectory).Returns(CurrentDirectory);
                fileSystem.Setup(x => x.EnumerateFiles(It.IsAny<string>(), It.IsAny<string>(), SearchOption.AllDirectories))
                          .Returns(new[] { "managed.dll", NonManaged });

                assemblyUtility.Setup(x => x.IsManagedAssembly(It.Is<string>(y => y == NonManaged))).Returns(false);
                initializationServices.Setup(i => i.GetFileSystem()).Returns(fileSystem.Object);
                servicesBuilder.SetupGet(b => b.InitializationServices).Returns(initializationServices.Object);
                servicesBuilder.Setup(b => b.Build()).Returns(services);

                var factory = fixture.Create<CommandFactory>();

                // Act
                factory.CreateCommand(args, new string[0]).Execute();

                // Assert
                executor.Verify(i => i.Initialize(It.Is<IEnumerable<string>>(x => !x.Contains(NonManaged)), It.IsAny<IEnumerable<IScriptPack>>()), Times.Once());
                executor.Verify(i => i.Execute(It.Is<string>(x => x == "test.csx"), It.IsAny<string[]>()), Times.Once());
                executor.Verify(i => i.Terminate(), Times.Once());
            }
开发者ID:selony,项目名称:scriptcs,代码行数:33,代码来源:ExecuteScriptCommandTests.cs


示例11: InstallCommandShouldInstallFromPackagesConfigIfNoNamePassed

            public void InstallCommandShouldInstallFromPackagesConfigIfNoNamePassed()
            {
                var args = new ScriptCsArgs
                {
                    AllowPreReleaseFlag = false,
                    Install = "",
                    ScriptName = null
                };

                var fs = new Mock<IFileSystem>();
                fs.Setup(x => x.GetWorkingDirectory(It.IsAny<string>())).Returns(@"C:\");

                var resolver = new Mock<IPackageAssemblyResolver>();
                var executor = new Mock<IScriptExecutor>();
                var scriptpackResolver = new Mock<IScriptPackResolver>();
                var packageInstaller = new Mock<IPackageInstaller>();
                var root = new ScriptServiceRoot(fs.Object, resolver.Object, executor.Object, scriptpackResolver.Object, packageInstaller.Object);

                resolver.Setup(i => i.GetPackages(It.IsAny<string>())).Returns(new List<IPackageReference>
                    {
                        new PackageReference("a", new FrameworkName(".NETFramework,Version=v4.0"), new Version()),
                        new PackageReference("b", new FrameworkName(".NETFramework,Version=v4.0"), new Version())
                    });

                var factory = new CommandFactory(root);
                var result = factory.CreateCommand(args);

                result.Execute();

                packageInstaller.Verify(i => i.InstallPackages(It.Is<IEnumerable<IPackageReference>>(x => x.Count() == 2), It.IsAny<bool>(), It.IsAny<Action<string>>()), Times.Once());
            }
开发者ID:eendrulat,项目名称:scriptcs,代码行数:31,代码来源:InstallCommandTests.cs


示例12: ShouldDeleteAllFilesResolvedFromPackages

            public void ShouldDeleteAllFilesResolvedFromPackages()
            {
                var args = new ScriptCsArgs { Clean = true };

                var fs = new Mock<IFileSystem>();
                var resolver = new Mock<IPackageAssemblyResolver>();
                var executor = new Mock<IScriptExecutor>();
                var engine = new Mock<IScriptEngine>();
                var scriptpackResolver = new Mock<IScriptPackResolver>();
                var packageInstaller = new Mock<IPackageInstaller>();
                var logger = new Mock<ILog>();
                var filePreProcessor = new Mock<IFilePreProcessor>();
                var root = new ScriptServiceRoot(fs.Object, resolver.Object, executor.Object, engine.Object, filePreProcessor.Object, scriptpackResolver.Object, packageInstaller.Object, logger.Object);

                fs.Setup(i => i.DirectoryExists(It.Is<string>(x => x.Contains(Constants.BinFolder)))).Returns(true);
                fs.Setup(i => i.GetWorkingDirectory(It.IsAny<string>())).Returns("c:\\");
                fs.Setup(i => i.FileExists(It.IsAny<string>())).Returns(true);
                resolver.Setup(i => i.GetAssemblyNames(It.IsAny<string>(), It.IsAny<Action<string>>())).Returns(new[] { "c:\\file.dll", "c:\\file2.dll" });

                var factory = new CommandFactory(root);
                var result = factory.CreateCommand(args);

                result.Execute();

                fs.Verify(i => i.FileDelete(It.IsAny<string>()), Times.Exactly(2));
            }
开发者ID:ChowZenki,项目名称:scriptcs,代码行数:26,代码来源:CleanCommandTests.cs


示例13: ScriptExecCommandShouldInvokeWithScriptPassedFromArgs

            public void ScriptExecCommandShouldInvokeWithScriptPassedFromArgs(
                [Frozen] Mock<IFileSystem> fileSystem,
                [Frozen] Mock<IScriptExecutor> executor,
                [Frozen] Mock<IInitializationServices> initializationServices,
                ScriptServices services)
            {
                // Arrange
                var args = new ScriptCsArgs { AllowPreRelease = false, Install = "", ScriptName = "test.csx" };
                var fixture = new Fixture().Customize(new AutoMoqCustomization());
                var servicesBuilder = fixture.Freeze<Mock<IScriptServicesBuilder>>();

                fileSystem.SetupGet(x => x.CurrentDirectory).Returns(CurrentDirectory);

                initializationServices.Setup(i => i.GetFileSystem()).Returns(fileSystem.Object);
                servicesBuilder.SetupGet(b => b.InitializationServices).Returns(initializationServices.Object);
                servicesBuilder.Setup(b => b.Build()).Returns(services);

                var factory = fixture.Create<CommandFactory>();

                // Act
                factory.CreateCommand(args, new string[0]).Execute();

                // Assert
                executor.Verify(i => i.Initialize(It.IsAny<IEnumerable<string>>(), It.IsAny<IEnumerable<IScriptPack>>()), Times.Once());
                executor.Verify(i => i.Execute(It.Is<string>(x => x == "test.csx"), It.IsAny<string[]>()), Times.Once());
                executor.Verify(i => i.Terminate(), Times.Once());
            }
开发者ID:selony,项目名称:scriptcs,代码行数:27,代码来源:ExecuteScriptCommandTests.cs


示例14: InstallCommandShouldInstallFromPackagesConfigIfNoNamePassed

            public void InstallCommandShouldInstallFromPackagesConfigIfNoNamePassed(
                [Frozen] Mock<IPackageInstaller> packageInstaller,
                [Frozen] Mock<IFileSystem> fileSystem,
                [Frozen] Mock<IPackageAssemblyResolver> resolver,
                [Frozen] Mock<IInitializationServices> initServices)
            {
                // Arrange
                var args = new ScriptCsArgs { AllowPreRelease = false, Install = "", ScriptName = null };
                var fixture = new Fixture().Customize(new AutoMoqCustomization());
                var servicesBuilder = fixture.Freeze<Mock<IScriptServicesBuilder>>();
                
                fileSystem.Setup(x => x.GetWorkingDirectory(It.IsAny<string>())).Returns(CurrentDirectory);
                fileSystem.SetupGet(x => x.CurrentDirectory).Returns(CurrentDirectory);

                initServices.Setup(i => i.GetFileSystem()).Returns(fileSystem.Object);
                initServices.Setup(i => i.GetPackageInstaller()).Returns(packageInstaller.Object);
                initServices.Setup(i => i.GetPackageAssemblyResolver()).Returns(resolver.Object);
                
                servicesBuilder.SetupGet(b => b.InitializationServices).Returns(initServices.Object);
      
                resolver.Setup(i => i.GetPackages(It.IsAny<string>())).Returns(new List<IPackageReference>
                    {
                        new PackageReference("a", new FrameworkName(".NETFramework,Version=v4.0"), new Version()),
                        new PackageReference("b", new FrameworkName(".NETFramework,Version=v4.0"), new Version())
                    });
                var factory = fixture.Create<CommandFactory>();

                // Act
                factory.CreateCommand(args, new string[0]).Execute();

                // Assert
                packageInstaller.Verify(i => i.InstallPackages(It.Is<IEnumerable<IPackageReference>>(x => x.Count() == 2), It.IsAny<bool>()), Times.Once());
            }
开发者ID:selony,项目名称:scriptcs,代码行数:33,代码来源:InstallCommandTests.cs


示例15: InstallCommandShouldInstallSinglePackageIfNamePassed

            public void InstallCommandShouldInstallSinglePackageIfNamePassed()
            {
                var args = new ScriptCsArgs
                    {
                        AllowPreRelease = false,
                        Install = "mypackage",
                        ScriptName = null
                    };

                const string CurrentDirectory = @"C:\";

                var fs = new Mock<IFileSystem>();
                fs.Setup(x => x.GetWorkingDirectory(It.IsAny<string>())).Returns(CurrentDirectory);
                fs.SetupGet(x => x.CurrentDirectory).Returns(CurrentDirectory);

                var resolver = new Mock<IPackageAssemblyResolver>();
                var executor = new Mock<IScriptExecutor>();
                var engine = new Mock<IScriptEngine>();
                var scriptpackResolver = new Mock<IScriptPackResolver>();
                var packageInstaller = new Mock<IPackageInstaller>();
                var logger = new Mock<ILog>();
                var filePreProcessor = new Mock<IFilePreProcessor>();
                var root = new ScriptServiceRoot(fs.Object, resolver.Object, executor.Object, engine.Object, filePreProcessor.Object, scriptpackResolver.Object, packageInstaller.Object, logger.Object);

                var factory = new CommandFactory(root);
                var result = factory.CreateCommand(args);

                result.Execute();

                packageInstaller.Verify(i => i.InstallPackages(It.Is<IEnumerable<IPackageReference>>(x => x.Count() == 1 && x.First().PackageId == "mypackage"), It.IsAny<bool>(), It.IsAny<Action<string>>()), Times.Once());
            }
开发者ID:ChowZenki,项目名称:scriptcs,代码行数:31,代码来源:InstallCommandTests.cs


示例16: ShouldPromptForInput

            public void ShouldPromptForInput(
                [Frozen] Mock<IFileSystem> fileSystem,
                [Frozen] Mock<IConsole> console,
                [Frozen] Mock<IScriptServicesBuilder> servicesBuilder,
                [Frozen] Mock<IInitializationServices> initializationServices,
                ScriptServices services)
            {
                // Arrange
                var readLines = 0;
                var builder = new StringBuilder();
                var args = new ScriptCsArgs { Repl = true };

                fileSystem.SetupGet(x => x.CurrentDirectory).Returns("C:\\");
                servicesBuilder.Setup(b => b.Build()).Returns(services);
                servicesBuilder.SetupGet(b => b.ConsoleInstance).Returns(console.Object);
                servicesBuilder.SetupGet(b => b.InitializationServices).Returns(initializationServices.Object);
                initializationServices.Setup(i => i.GetFileSystem()).Returns(fileSystem.Object);

                console.Setup(x => x.ReadLine()).Callback(() => readLines++).Throws(new Exception());
                console.Setup(x => x.Write(It.IsAny<string>())).Callback<string>(value => builder.Append(value));

                var factory = new CommandFactory(servicesBuilder.Object);

                // Act
                factory.CreateCommand(args, new string[0]).Execute();

                // Assert
                builder.ToString().EndsWith("> ").ShouldBeTrue();
                readLines.ShouldEqual(1);
            }
开发者ID:selony,项目名称:scriptcs,代码行数:30,代码来源:ExecuteReplCommandTests.cs


示例17: InstallCommandShouldInstallSinglePackageIfNamePassed

            public void InstallCommandShouldInstallSinglePackageIfNamePassed(
                [Frozen] Mock<IFileSystem> fileSystem,
                [Frozen] Mock<IPackageInstaller> packageInstaller,
                [Frozen] Mock<IPackageAssemblyResolver> resolver,
                [Frozen] Mock<IInitializationServices> initializationServices,
                ScriptServices services)
            {
                // Arrange
                var args = new ScriptCsArgs { AllowPreRelease = false, Install = "mypackage", };
                var fixture = new Fixture().Customize(new AutoMoqCustomization());
                var servicesBuilder = fixture.Freeze<Mock<IScriptServicesBuilder>>();

                initializationServices.Setup(i => i.GetFileSystem()).Returns(fileSystem.Object);
                initializationServices.Setup(i => i.GetPackageInstaller()).Returns(packageInstaller.Object);
                initializationServices.Setup(i => i.GetPackageAssemblyResolver()).Returns(resolver.Object);

                servicesBuilder.Setup(b => b.Build()).Returns(services);
                servicesBuilder.SetupGet(b => b.InitializationServices).Returns(initializationServices.Object);
                var factory = fixture.Create<CommandFactory>();

                // Act
                factory.CreateCommand(args, new string[0]).Execute();

                // Assert
                packageInstaller.Verify(
                    i => i.InstallPackages(
                        It.Is<IEnumerable<IPackageReference>>(x => x.Count() == 1 && x.First().PackageId == "mypackage"),
                        It.IsAny<bool>()),
                    Times.Once());
            }
开发者ID:nagyistoce,项目名称:scriptcs,代码行数:30,代码来源:InstallCommandTests.cs


示例18: InstallCommandShouldInstallFromPackagesConfigIfNoNamePassed

            public void InstallCommandShouldInstallFromPackagesConfigIfNoNamePassed(
                [Frozen] Mock<IPackageInstaller> packageInstaller,
                [Frozen] Mock<IFileSystem> fileSystem,
                [Frozen] Mock<IPackageAssemblyResolver> resolver,
                [Frozen] Mock<IInitializationServices> initializationServices,
                [Frozen] Mock<IScriptServicesBuilder> servicesBuilder,
                ScriptServices services)
            {
                // Arrange
                var args = new ScriptCsArgs { AllowPreRelease = false, Install = string.Empty, };

                initializationServices.Setup(i => i.GetFileSystem()).Returns(fileSystem.Object);
                initializationServices.Setup(i => i.GetPackageInstaller()).Returns(packageInstaller.Object);
                initializationServices.Setup(i => i.GetPackageAssemblyResolver()).Returns(resolver.Object);

                servicesBuilder.Setup(b => b.Build()).Returns(services);
                servicesBuilder.SetupGet(b => b.InitializationServices).Returns(initializationServices.Object);

                resolver.Setup(i => i.GetPackages(It.IsAny<string>())).Returns(new List<IPackageReference>
                    {
                        new PackageReference("a", new FrameworkName(".NETFramework,Version=v4.0"), new Version()),
                        new PackageReference("b", new FrameworkName(".NETFramework,Version=v4.0"), new Version())
                    });

                var factory = new CommandFactory(servicesBuilder.Object);
                var sut = factory.CreateCommand(args, new string[0]);

                // act
                sut.Execute();

                // Assert
                packageInstaller.Verify(i => i.InstallPackages(It.Is<IEnumerable<IPackageReference>>(x => x.Count() == 2), It.IsAny<bool>()), Times.Once());
            }
开发者ID:nagyistoce,项目名称:scriptcs,代码行数:33,代码来源:InstallCommandTests.cs


示例19: ShouldCopyFilesInPathIfLastWriteTimeDiffersFromLastWriteTimeOfFileInBin

            public void ShouldCopyFilesInPathIfLastWriteTimeDiffersFromLastWriteTimeOfFileInBin()
            {
                var args = new ScriptCsArgs { Restore = true, ScriptName = "" };

                var fs = new Mock<IFileSystem>();
                var resolver = new Mock<IPackageAssemblyResolver>();
                var executor = new Mock<IScriptExecutor>();
                var scriptpackResolver = new Mock<IScriptPackResolver>();
                var packageInstaller = new Mock<IPackageInstaller>();
                var root = new ScriptServiceRoot(fs.Object, resolver.Object, executor.Object, scriptpackResolver.Object, packageInstaller.Object);

                const string CurrentDirectory = @"C:\";

                var sourceFilePath = Path.Combine(CurrentDirectory, "fileName.cs");
                var sourceWriteTime = new DateTime(2013, 3, 7);

                var destFilePath = Path.Combine(CurrentDirectory, "bin", "fileName.cs");
                var destWriteTime = new DateTime(2013, 2, 7);

                fs.Setup(x => x.GetWorkingDirectory(It.IsAny<string>())).Returns(CurrentDirectory);

                fs.Setup(x => x.GetLastWriteTime(sourceFilePath)).Returns(sourceWriteTime).Verifiable();
                fs.Setup(x => x.GetLastWriteTime(destFilePath)).Returns(destWriteTime).Verifiable();

                resolver.Setup(i => i.GetAssemblyNames(CurrentDirectory, It.IsAny<Action<string>>())).Returns(new[] { sourceFilePath });

                var factory = new CommandFactory(root);
                var result = factory.CreateCommand(args);

                result.Execute();

                fs.Verify(x => x.Copy(sourceFilePath, destFilePath, true), Times.Once());
                fs.Verify(x => x.GetLastWriteTime(sourceFilePath), Times.Once());
                fs.Verify(x => x.GetLastWriteTime(destFilePath), Times.Once());
            }
开发者ID:bangoker,项目名称:scriptcs,代码行数:35,代码来源:RestoreCommandTests.cs


示例20: ShouldCleanWhenCleanFlagIsPassed

            public void ShouldCleanWhenCleanFlagIsPassed()
            {
                var args = new ScriptCsArgs { Clean = true, ScriptName = null };

                var factory = new CommandFactory(CreateRoot());
                var result = factory.CreateCommand(args);

                result.ShouldNotBeNull();
                result.ShouldImplement<ICleanCommand>();
            }
开发者ID:eendrulat,项目名称:scriptcs,代码行数:10,代码来源:CommandFactoryTests.cs



注:本文中的ScriptCsArgs类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ScriptEngine类代码示例发布时间:2022-05-24
下一篇:
C# ScriptCoreLib类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap