Beispiel #1
0
        public void ElectronNetBuildCustom_Should_Execute_Command_By_Given_ElectronNetCustomBuildSettings()
        {
            ICakeContext cakeContext = _cakeContextMock.Object;

            var settings = new ElectronNetCustomBuildSettings()
            {
                WorkingDirectory     = "./SomeDirectory",
                DotNetConfig         = DotNetConfig.Release,
                ElectronTargetCustom = ElectronTargetCustom.MacOs1011X64,
                ElectronArch         = "ia32",
                ElectronParams       = new[] { "command=conquer" }
            };

            string expectedCommand =
                $"{CmdBase} /target custom {ElectronTargetCustom.MacOs1011X64.Value} /dotnet-configuration Release /electron-arch {settings.ElectronArch} /electron-params \"--command=conquer\"";

            var processHelperMock  = new Mock <IProcessHelper>(MockBehavior.Strict);
            var commandBuilderMock = new Mock <ICommandBuilder>(MockBehavior.Strict);

            ElectronCakeContext.Current = new TestCakeContext(processHelperMock, commandBuilderMock);

            commandBuilderMock.Setup(builder => builder.SwitchHelper(It.Is <string[]>(strings => strings.All(s => settings.ElectronParams.Contains(s)))))
            .Returns(() => "--command=conquer");

            processHelperMock.Setup(helper => helper.CmdExecute(It.Is <string>(s => s == expectedCommand), It.Is <string>(s => s == settings.WorkingDirectory),
                                                                It.IsAny <bool>(), It.IsAny <bool>()))
            .Returns(1);

            cakeContext.ElectronNetBuildCustom(settings);

            processHelperMock.Verify(helper => helper.CmdExecute(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>()), Times.Once);
            commandBuilderMock.Verify(builder => builder.SwitchHelper(It.IsAny <string[]>()), Times.Once);
        }
Beispiel #2
0
        public static int ElectronNetBuildCustom(this ICakeContext context, ElectronNetCustomBuildSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            return(ElectronNetBuildCustom(context, settings.WorkingDirectory, settings.ElectronTargetCustom, settings.ElectronArch, settings.DotNetConfig,
                                          settings.RelativePath, settings.AbsolutePath, settings.PackageJson, settings.InstallModules, settings.Manifest, settings.PublishSingleFile, settings.PublishReadyToRun,
                                          settings.ElectronParams));
        }