Exemple #1
0
        internal void OpenSignRequestForm_Click(object sender, RoutedEventArgs e)
        {
            string header0 = "Issue Certificate";
            IEnumerable <TabablzControl> tctrl;

            GetTabablzData(out header0, out tctrl);
            header0 = "Issue Certificate";

            GenerateSignRequest gr = new GenerateSignRequest(certFriendlyName);

            if (loadedUserForm == null || loadedUserForm != gr)
            {
                loadedUserForm = new GenerateSignRequest(certFriendlyName);
            }

            //mainGrid.Child = loadedUserForm;
            //TabContent tc1 = new TabContent("Issue Certificate", loadedUserForm);
            TabContent tc1 = new TabContent(header0, loadedUserForm);

            AddTabablzData(header0, tctrl, tc1);

            //MenuItem mi = (MenuItem)sender;
            //sbiSelectedMenuOption.Content = mi.Header;
            sbiSelectedMenuOption.Content = header0;
        }
        public void ItCreatesSignRequest()
        {
            var rootDir   = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "C:/" : "/";
            var nupkgPath = Path.Combine(AppContext.BaseDirectory, "build", "MyLib.nupkg");
            var requests  = new ITaskItem[]
            {
                new TaskItem(Path.Combine(AppContext.BaseDirectory, "build", "ZZApp.vsix"),
                             new Hashtable
                {
                    ["IsContainer"] = "true",
                    ["Certificate"] = "Cert4",
                }),
                new TaskItem(nupkgPath,
                             new Hashtable
                {
                    ["IsContainer"] = "true",
                    ["Type"]        = "nupkg",
                }),
                new TaskItem(Path.Combine(AppContext.BaseDirectory, "MyLib.dll"),
                             new Hashtable
                {
                    ["Container"]   = nupkgPath,
                    ["PackagePath"] = "lib/netstandard2.0/MyLib.dll",
                    ["Certificate"] = "Cert1",
                    ["StrongName"]  = "Key1",
                }),
                new TaskItem(Path.Combine(AppContext.BaseDirectory, "MyRefLib.dll"),
                             new Hashtable
                {
                    ["Container"]   = nupkgPath,
                    ["PackagePath"] = "ref/netstandard2.0/",
                    ["Certificate"] = "Cert1",
                    ["StrongName"]  = "Key1",
                }),
                new TaskItem(Path.Combine(AppContext.BaseDirectory, "build", "MyLib.dll"),
                             new Hashtable
                {
                    ["Certificate"] = "Cert1",
                }),
                new MockTaskItem(Path.Combine(rootDir + "MyProject", "lib", "net461", "MyLib.dll"))
                {
                    ["Container"] = nupkgPath,
                    ["MSBuildSourceProjectFile"] = rootDir + "MyProject/MyProject.csproj",
                    ["Certificate"] = "Cert1",
                },
            };

            var exclusions = new ITaskItem[]
            {
                new TaskItem(Path.Combine(AppContext.BaseDirectory, "NotMyLib.dll"),
                             new Hashtable
                {
                    ["PackagePath"] = "lib/NotMyLib.dll",
                    ["Container"]   = nupkgPath,
                }),
                new MockTaskItem(Path.Combine(rootDir + "MyProject", "tool", "net461", "NotMyLib.dll"))
                {
                    ["Container"] = nupkgPath,
                    ["MSBuildSourceProjectFile"] = rootDir + "MyProject/MyProject.csproj",
                },
            };

            var task = new GenerateSignRequest
            {
                Requests    = requests,
                BasePath    = AppContext.BaseDirectory,
                Exclusions  = exclusions,
                BuildEngine = new MockEngine(_output),
            };

            var sb = new StringBuilder();

            Assert.True(task.Execute(() => new StringWriter(sb)), "Task should pass");

            var expected = $@"<SignRequest>
  <File Path=`build/MyLib.dll` Certificate=`Cert1` />
  <Nupkg Path=`build/MyLib.nupkg`>
    <ExcludedFile Path=`lib/NotMyLib.dll` />
    <File Path=`lib/net461/MyLib.dll` Certificate=`Cert1` />
    <File Path=`lib/netstandard2.0/MyLib.dll` Certificate=`Cert1` StrongName=`Key1` />
    <File Path=`ref/netstandard2.0/MyRefLib.dll` Certificate=`Cert1` StrongName=`Key1` />
    <ExcludedFile Path=`tool/net461/NotMyLib.dll` />
  </Nupkg>
  <Vsix Path=`build/ZZApp.vsix` Certificate=`Cert4` />
</SignRequest>".Replace('`', '"');

            _output.WriteLine(sb.ToString());

            Assert.Equal(expected, sb.ToString(), ignoreLineEndingDifferences: true, ignoreWhiteSpaceDifferences: true);
        }