Main() public static method

public static Main ( String args ) : int
args String
return int
Exemplo n.º 1
0
        private static void Main(string[] argv)
        {
            Console.WriteLine(argv);
            Console.WriteLine("Hello from Test World!");
            try
            {
                RunNeoTests();
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                RunScenarioTests();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            try
            {
                RunAggregatorTests();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Program program = new Program();
            program.Main();

            Console.WriteLine("So Long from Test World");
        }
        public void AddUserSecrets_With_An_Existing_Secret_File()
        {
            string userSecretsId;
            var projectPath = UserSecretHelper.GetTempSecretProject(out userSecretsId);

            var logger = new TestLogger(_runtimeEnv);
            var secretManager = new Program(_runtimeEnv) { Logger = logger };

            secretManager.Main(new string[] { "set", "Facebook:AppSecret", "value1", "-p", projectPath });

            var builder = new ConfigurationBuilder().SetBasePath(projectPath).AddUserSecrets();
            var configuration = builder.Build();
            Assert.Equal("value1", configuration["Facebook:AppSecret"]);

            UserSecretHelper.DeleteTempSecretProject(projectPath);
        }
Exemplo n.º 3
0
	void Start () {
		Program program = new Program();
		program.Main(personPrefab, pathPrefab);
	}
Exemplo n.º 4
0
 public void MainTest_ArgsHasZeroElements_ThrowException()
 {
     Assert.ThrowsException <ArgumentException>(
         () => Program.Main(new string[] { }));
 }
Exemplo n.º 5
0
        public void Main_When_Valid_MinMax_Command_With_Returns_Expected_Cities_With_Min_Max(string cmd, string expectedOutput, string extension)
        {
            Program.Main(new[] { ValidTransactionsFile + extension, cmd, OutputFile + extension });

            AssertMatchingContents(expectedOutput, OutputFile + extension);
        }
Exemplo n.º 6
0
        public void Main_When_Transactions_File_Empty_Or_Not_Found_Throws_NoTransactionsException(string input)
        {
            Action action = () => Program.Main(new[] { input, "time", OutputFile + ".json" });

            action.Should().Throw <NoTransactionsFoundException>();
        }
Exemplo n.º 7
0
        public async Task CallingCycloneDX_WithoutOutputDirectory_ReturnsOutputDirectoryParameterMissingExitCode()
        {
            var exitCode = await Program.Main(new string[] { XFS.Path(@"c:\SolutionPath\Solution.sln") }).ConfigureAwait(false);

            Assert.Equal((int)ExitCode.OutputDirectoryParameterMissing, exitCode);
        }
Exemplo n.º 8
0
        public void Should_Throw_Exception_If_Input_Text_File_Found_At_Path_But_Contains_Bad_Data()
        {
            var filePath = AppDomain.CurrentDomain.BaseDirectory + "\\TestInputBad.txt";

            Assert.Throws <ArgumentException>(() => Program.Main(new[] { filePath }));
        }
Exemplo n.º 9
0
        public void NoArgumentsShouldNotBeAccepted()
        {
            int returnCode = Program.Main(new string[] { });

            Assert.AreEqual(1, returnCode, "No arguments should not be accepted.");
        }
Exemplo n.º 10
0
        public void CallingCycloneDX__GeneratesBom()
        {
            var mockFileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { XFS.Path(@"c:\Solution\Solution.sln"), new MockFileData(@"Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"") = ""Project.WithPackages"", ""Project.WithPackages\Project.WithPackages.csproj"", ""{5849EBB9-CC38-4FCE-A3E1-3501C674249C}""
EndProject
Project(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"") = ""Project.NoPackages"", ""Project.NoPackages\Project.NoPackages.csproj"", ""{C6071BA2-1168-41E7-9BD3-A48585C9637A}""
EndProject
Project(""{F184B08F-C81C-45F6-A57F-5ABD9991F28F}"") = ""Project.Vb"", ""Project.Vb\Project.Vb.vbproj"", ""{A775F37D-4AA6-47D8-8305-6DFDB843B347}""
EndProject
Global
  GlobalSection(SolutionConfigurationPlatforms) = preSolution
    Debug|Any CPU = Debug|Any CPU
    Debug|x64 = Debug|x64
    Debug|x86 = Debug|x86
    Release|Any CPU = Release|Any CPU
    Release|x64 = Release|x64
    Release|x86 = Release|x86
  EndGlobalSection
  GlobalSection(SolutionProperties) = preSolution
    HideSolutionNode = FALSE
  EndGlobalSection
  GlobalSection(ProjectConfigurationPlatforms) = postSolution
    {5849EBB9-CC38-4FCE-A3E1-3501C674249C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
    {5849EBB9-CC38-4FCE-A3E1-3501C674249C}.Debug|Any CPU.Build.0 = Debug|Any CPU
    {5849EBB9-CC38-4FCE-A3E1-3501C674249C}.Debug|x64.ActiveCfg = Debug|Any CPU
    {5849EBB9-CC38-4FCE-A3E1-3501C674249C}.Debug|x64.Build.0 = Debug|Any CPU
    {5849EBB9-CC38-4FCE-A3E1-3501C674249C}.Debug|x86.ActiveCfg = Debug|Any CPU
    {5849EBB9-CC38-4FCE-A3E1-3501C674249C}.Debug|x86.Build.0 = Debug|Any CPU
    {5849EBB9-CC38-4FCE-A3E1-3501C674249C}.Release|Any CPU.ActiveCfg = Release|Any CPU
    {5849EBB9-CC38-4FCE-A3E1-3501C674249C}.Release|Any CPU.Build.0 = Release|Any CPU
    {5849EBB9-CC38-4FCE-A3E1-3501C674249C}.Release|x64.ActiveCfg = Release|Any CPU
    {5849EBB9-CC38-4FCE-A3E1-3501C674249C}.Release|x64.Build.0 = Release|Any CPU
    {5849EBB9-CC38-4FCE-A3E1-3501C674249C}.Release|x86.ActiveCfg = Release|Any CPU
    {5849EBB9-CC38-4FCE-A3E1-3501C674249C}.Release|x86.Build.0 = Release|Any CPU
    {C6071BA2-1168-41E7-9BD3-A48585C9637A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
    {C6071BA2-1168-41E7-9BD3-A48585C9637A}.Debug|Any CPU.Build.0 = Debug|Any CPU
    {C6071BA2-1168-41E7-9BD3-A48585C9637A}.Debug|x64.ActiveCfg = Debug|Any CPU
    {C6071BA2-1168-41E7-9BD3-A48585C9637A}.Debug|x64.Build.0 = Debug|Any CPU
    {C6071BA2-1168-41E7-9BD3-A48585C9637A}.Debug|x86.ActiveCfg = Debug|Any CPU
    {C6071BA2-1168-41E7-9BD3-A48585C9637A}.Debug|x86.Build.0 = Debug|Any CPU
    {C6071BA2-1168-41E7-9BD3-A48585C9637A}.Release|Any CPU.ActiveCfg = Release|Any CPU
    {C6071BA2-1168-41E7-9BD3-A48585C9637A}.Release|Any CPU.Build.0 = Release|Any CPU
    {C6071BA2-1168-41E7-9BD3-A48585C9637A}.Release|x64.ActiveCfg = Release|Any CPU
    {C6071BA2-1168-41E7-9BD3-A48585C9637A}.Release|x64.Build.0 = Release|Any CPU
    {C6071BA2-1168-41E7-9BD3-A48585C9637A}.Release|x86.ActiveCfg = Release|Any CPU
    {C6071BA2-1168-41E7-9BD3-A48585C9637A}.Release|x86.Build.0 = Release|Any CPU
    {A775F37D-4AA6-47D8-8305-6DFDB843B347}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
    {A775F37D-4AA6-47D8-8305-6DFDB843B347}.Debug|Any CPU.Build.0 = Debug|Any CPU
    {A775F37D-4AA6-47D8-8305-6DFDB843B347}.Debug|x64.ActiveCfg = Debug|Any CPU
    {A775F37D-4AA6-47D8-8305-6DFDB843B347}.Debug|x64.Build.0 = Debug|Any CPU
    {A775F37D-4AA6-47D8-8305-6DFDB843B347}.Debug|x86.ActiveCfg = Debug|Any CPU
    {A775F37D-4AA6-47D8-8305-6DFDB843B347}.Debug|x86.Build.0 = Debug|Any CPU
    {A775F37D-4AA6-47D8-8305-6DFDB843B347}.Release|Any CPU.ActiveCfg = Release|Any CPU
    {A775F37D-4AA6-47D8-8305-6DFDB843B347}.Release|Any CPU.Build.0 = Release|Any CPU
    {A775F37D-4AA6-47D8-8305-6DFDB843B347}.Release|x64.ActiveCfg = Release|Any CPU
    {A775F37D-4AA6-47D8-8305-6DFDB843B347}.Release|x64.Build.0 = Release|Any CPU
    {A775F37D-4AA6-47D8-8305-6DFDB843B347}.Release|x86.ActiveCfg = Release|Any CPU
    {A775F37D-4AA6-47D8-8305-6DFDB843B347}.Release|x86.Build.0 = Release|Any CPU
  EndGlobalSection
EndGlobal") },
                {
                    XFS.Path(@"c:\Solution\Project.WithPackages\Project.WithPackages.csproj"),
                    new MockFileData(@"<Project Sdk=""Microsoft.NET.Sdk"">
  <ItemGroup>
    <PackageReference Include=""Microsoft.AspNetCore.All"" Version=""1.0.0"" />
    <PackageReference Include=""Microsoft.AspNetCore.Mvc"" Version=""1.0.0"" />
    <PackageReference Include=""Microsoft.AspNetCore.Mvc.Core"" Version=""1.0.0"" />
    <PackageReference Include=""Microsoft.AspNetCore.Server.IISIntegration"" Version=""1.0.0"" />
    <PackageReference Include=""System.Net.Http"" Version=""4.3.1"" />
    <PackageReference Include=""System.Net.Security"" Version=""4.3.0"" />
  </ItemGroup>
</Project>")
                },
                {
                    XFS.Path(@"c:\Solution\Project.NoPackages\Project.NoPackages.csproj"),
                    new MockFileData(@"<Project Sdk=""Microsoft.NET.Sdk""><ItemGroup></ItemGroup></Project>")
                },
                {
                    XFS.Path(@"c:\Solution\Project.Vb\Project.Vb.vbproj"),
                    new MockFileData(@"<Project Sdk=""Microsoft.NET.Sdk"">
  <ItemGroup>
    <PackageReference Include=""Microsoft.AspNetCore.All"" Version=""1.0.0"" />
    <PackageReference Include=""Microsoft.AspNetCore.Mvc"" Version=""1.0.0"" />
    <PackageReference Include=""Microsoft.AspNetCore.Mvc.Core"" Version=""1.0.0"" />
    <PackageReference Include=""Microsoft.AspNetCore.Server.IISIntegration"" Version=""1.0.0"" />
    <PackageReference Include=""System.Net.Http"" Version=""4.3.1"" />
    <PackageReference Include=""System.Net.Security"" Version=""4.3.0"" />
  </ItemGroup>
</Project>")
                },
            });

            Program.fileSystem = mockFileSystem;

            var exitCode = Program.Main(new string[] {
                XFS.Path(@"c:\Solution\Solution.sln"),
                "--noSerialNumber",
                "--out", XFS.Path(@"c:\Solution")
            });
            var bomContents = mockFileSystem.File.ReadAllText(XFS.Path(@"c:\Solution\bom.xml"));

            Assert.Equal(@"<?xml version=""1.0"" encoding=""utf-8""?>
<bom version=""1"" xmlns=""http://cyclonedx.org/schema/bom/1.1"">
  <components>
    <component type=""library"">
      <name>Microsoft.AspNetCore.All</name>
      <version>1.0.0</version>
      <purl>pkg:nuget/[email protected]</purl>
    </component>
    <component type=""library"">
      <name>Microsoft.AspNetCore.Mvc</name>
      <version>1.0.0</version>
      <description><![CDATA[ASP.NET Core MVC is a web framework that gives you a powerful, patterns-based way to build dynamic websites and web APIs. ASP.NET Core MVC enables a clean separation of concerns and gives you full control over markup.]]></description>
      <licenses>
        <license>
          <url>http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm</url>
        </license>
      </licenses>
      <copyright>Copyright © Microsoft Corporation</copyright>
      <purl>pkg:nuget/[email protected]</purl>
      <externalReferences>
        <reference type=""website"">
          <url>http://www.asp.net/</url>
        </reference>
      </externalReferences>
    </component>
    <component type=""library"">
      <name>Microsoft.AspNetCore.Mvc.Core</name>
      <version>1.0.0</version>
      <description><![CDATA[ASP.NET Core MVC core components. Contains common action result types, attribute routing, application model conventions, API explorer, application parts, filters, formatters, model binding, and more.
Commonly used types:
Microsoft.AspNetCore.Mvc.AreaAttribute
Microsoft.AspNetCore.Mvc.BindAttribute
Microsoft.AspNetCore.Mvc.ControllerBase
Microsoft.AspNetCore.Mvc.FromBodyAttribute
Microsoft.AspNetCore.Mvc.FromFormAttribute
Microsoft.AspNetCore.Mvc.RequireHttpsAttribute
Microsoft.AspNetCore.Mvc.RouteAttribute]]></description>
      <licenses>
        <license>
          <url>http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm</url>
        </license>
      </licenses>
      <copyright>Copyright © Microsoft Corporation</copyright>
      <purl>pkg:nuget/[email protected]</purl>
      <externalReferences>
        <reference type=""website"">
          <url>http://www.asp.net/</url>
        </reference>
      </externalReferences>
    </component>
    <component type=""library"">
      <name>Microsoft.AspNetCore.Server.IISIntegration</name>
      <version>1.0.0</version>
      <description><![CDATA[ASP.NET Core components for working with the IIS AspNetCoreModule.]]></description>
      <licenses>
        <license>
          <url>http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm</url>
        </license>
      </licenses>
      <copyright>Copyright © Microsoft Corporation</copyright>
      <purl>pkg:nuget/[email protected]</purl>
      <externalReferences>
        <reference type=""website"">
          <url>http://www.asp.net/</url>
        </reference>
      </externalReferences>
    </component>
    <component type=""library"">
      <name>System.Net.Http</name>
      <version>4.3.1</version>
      <description><![CDATA[Provides a programming interface for modern HTTP applications, including HTTP client components that allow applications to consume web services over HTTP and HTTP components that can be used by both clients and servers for parsing HTTP headers.

Commonly Used Types:
System.Net.Http.HttpResponseMessage
System.Net.Http.DelegatingHandler
System.Net.Http.HttpRequestException
System.Net.Http.HttpClient
System.Net.Http.MultipartContent
System.Net.Http.Headers.HttpContentHeaders
System.Net.Http.HttpClientHandler
System.Net.Http.StreamContent
System.Net.Http.FormUrlEncodedContent
System.Net.Http.HttpMessageHandler
 
When using NuGet 3.x this package requires at least version 3.4.]]></description>
      <licenses>
        <license>
          <url>http://go.microsoft.com/fwlink/?LinkId=329770</url>
        </license>
      </licenses>
      <copyright>© Microsoft Corporation.  All rights reserved.</copyright>
      <purl>pkg:nuget/[email protected]</purl>
      <externalReferences>
        <reference type=""website"">
          <url>https://dot.net/</url>
        </reference>
      </externalReferences>
    </component>
    <component type=""library"">
      <name>System.Net.Security</name>
      <version>4.3.0</version>
      <description><![CDATA[Provides types, such as System.Net.Security.SslStream, that uses SSL/TLS protocols to provide secure network communication between client and server endpoints.

Commonly Used Types:
System.Net.Security.SslStream
System.Net.Security.ExtendedProtectionPolicy
 
When using NuGet 3.x this package requires at least version 3.4.]]></description>
      <licenses>
        <license>
          <url>http://go.microsoft.com/fwlink/?LinkId=329770</url>
        </license>
      </licenses>
      <copyright>© Microsoft Corporation.  All rights reserved.</copyright>
      <purl>pkg:nuget/[email protected]</purl>
      <externalReferences>
        <reference type=""website"">
          <url>https://dot.net/</url>
        </reference>
      </externalReferences>
    </component>
  </components>
</bom>", bomContents);
        }
Exemplo n.º 11
0
        public int ExecuteFixtureInProcess(string fixture, string arguments = null)
        {
            var pathToFixture = TestPathUtils.GetPathToTestFixture(fixture);

            return(Program.Main(new[] { pathToFixture }.Concat(arguments?.Split(" ") ?? Array.Empty <string>()).ToArray()));
        }
Exemplo n.º 12
0
 public int ExecuteInProcess(string arguments = null)
 {
     return(Program.Main(arguments?.Split(" ") ?? Array.Empty <string>()));
 }
Exemplo n.º 13
0
 public void CreateCodeGeneratorOptions_NoProjectId_ReturnsError()
 {
     Assert.Equal(1, Program.Main(new string[] { }));
 }
Exemplo n.º 14
0
 public void TestMain()
 {
     Program.Main(null);
 }
Exemplo n.º 15
0
 //[DataRow("--role transverter --operation work --address 127.0.0.1")]
 public void TestProgram(string arg)
 {
     Program.Main(arg.Split(" "));
 }
Exemplo n.º 16
0
        public void Program_Main_Throws_Not_Implemented_Exception()
        {
            Action runProgramMain = () => Program.Main(Array.Empty <string>());

            runProgramMain.Should().Throw <NotImplementedException>();
        }
Exemplo n.º 17
0
 static void Main(string[] args)
 {
     Program _P = new Program();
     _P.Main();
 }
Exemplo n.º 18
0
 protected void InvokingMain()
 {
     var arguments = Arguments.ToArray();
     Arguments.Clear();
     ExitCode = (ExitCode)Program.Main(arguments);
 }
Exemplo n.º 19
0
        public void Should_Throw_Exception_If_Input_Text_File_Not_Found_At_Path()
        {
            var filePath = AppDomain.CurrentDomain.BaseDirectory + "\\NotFound.txt";

            Assert.Throws <FileNotFoundException>(() => Program.Main(new[] { filePath }));
        }
Exemplo n.º 20
0
 public void SetUpServer()
 {
     Task.Run(() => Program.Main(null));
     GetData();
 }
Exemplo n.º 21
0
        public async Task CallingCycloneDX_WithoutSolutionFile_ReturnsSolutionOrProjectFileParameterMissingExitCode()
        {
            var exitCode = await Program.Main(new string[] {}).ConfigureAwait(false);

            Assert.Equal((int)ExitCode.SolutionOrProjectFileParameterMissing, exitCode);
        }
Exemplo n.º 22
0
 private static void RunRepresenter(TestSolution solution) =>
 Program.Main(new[] { solution.Slug, solution.Directory, solution.Directory,
                      "--SkipLogConfiguration" });
Exemplo n.º 23
0
 public void Xml_file_can_generate_class()
 {
     Program.Main(new[] { "C:/git/XmlClassGenerator/XmlClassGenerator.Tests/Resources/dbc.xml" });
 }
Exemplo n.º 24
0
 /// <summary>
 /// Use this if you need to debug.
 /// </summary>
 private static int ExecuteInProcess(params string[] args)
 {
     return(Program.Main(args));
 }
Exemplo n.º 25
0
        public void Main_When_Command_Invalid_Throws_InvalidCommandException(string cmd)
        {
            Action action = () => Program.Main(new[] { "Input/Transactions.json", cmd, OutputFile + ".json" });

            action.Should().Throw <InvalidCommandException>();
        }
Exemplo n.º 26
0
 public void SmokeTest()
 {
     Program.Main(null);
 }
Exemplo n.º 27
0
 public void TestMethod1()
 {
     Program.Main();
 }
Exemplo n.º 28
0
        public void Test1_EmptyArgument_ThrowException()
        {
            Exception ex = Assert.ThrowsAsync <ArgumentException>(async() => await Program.Main(new string[] { }));

            Assert.That(ex.Message.Equals("No arguments."));
        }
Exemplo n.º 29
0
        public WebTests(ITestOutputHelper output)
        {
            this.output = output;
            LoggerConfiguration logConfig = new LoggerConfiguration().WriteTo.Console()
                                            .WriteTo.TestOutput(output, LogEventLevel.Verbose);

            Log.Logger = logConfig.CreateLogger();

            // Set up web module
            if (!File.Exists(this.configFile))
            {
                File.WriteAllText(this.configFile,
                                  JsonConvert.SerializeObject(new WebConfig {
                    EngineConfig = new EngineConfig {
                        DatastoreConfig = new MongoDbConfig {
                            MongoHostnames = new[] {
                                "127.0.0.1:27017"
                            },
                            MongoAuthDb     = "admin",
                            MongoCollection = "MagnumMicroservices",
                            MongoPassword   = "******",
                            MongoUser       = "******",
                            UseReplicaSet   = false,
                            SslConfig       = new MongoDbSslConfig {
                                UseSsl = false
                            }
                        },
                        QueueConfig = new RabbitQueueConfig {
                            Hostname = "127.0.0.1",
                            Username = "******",
                            Password = "******"
                        }
                    },
                    UseSsl               = true,
                    Port                 = 6883,
                    SslCertLocation      = "Cert.pfx",
                    SslCertPassword      = "******",
                    UseAuth              = true,
                    UseCloudWatchLogging = false
                },
                                                              Formatting.Indented));
                throw new Exception("Failed to find config file. Created default.");
            }
            string configText = File.ReadAllText(this.configFile);

            this.webConfig = WebConfigHelper.FromJson(configText);
            this.webModule = new Task(() => {
                Program.Main(new[] {
                    "--config", this.configFile, "--tokens", this.tokensFile
                });
            });
            this.webModule.Start();
            Thread.Sleep(10000);

            // Read in tokens
            string tokensText = File.ReadAllText(this.tokensFile);

            string[] split = tokensText.Split('\"');
            tokens = split[1] + ":" + split[3];

            // Set up queue id
            this.testQueueId = "TESTAPPLICATION" +
                               DateTime.UtcNow.ToString("u").Replace(" ", "").Replace("-", "").Replace(":", "");

            // Store default SSL certificate validation method so we can revert back after we change it
            HttpClientHandler handler = new HttpClientHandler {
                SslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12,
                ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true
            };

            client = new HttpClient(handler);

            submitUri   = $"https://localhost:{this.webConfig.Port}/job/submit/";
            requestUri  = $"https://localhost:{this.webConfig.Port}/job/request/";
            completeUri = $"https://localhost:{this.webConfig.Port}/job/complete/";
            emptyUri    = $"https://localhost:{this.webConfig.Port}/job/isempty/";
            failUri     = $"https://localhost:{this.webConfig.Port}/job/fail/";
        }
Exemplo n.º 30
0
        public void CorrectAndSuccessfulAnalysis()
        {
            /// TODO: This is a big test as it does an end-to-end assertion
            /// of many aspects. However, using some mock types this test
            /// implementation can be significantly simplified.
            ///

            // Arrange
            string outputPath = "session_" + DateTime.Now.ToString("yyyyMMdd_HHmmssfff_", CultureInfo.InvariantCulture) + new Random().Next(100000, 999999).ToString();
            string culture    = "fa-IR";
            double pValue;
            string rep1Filename = Path.GetTempPath() + Guid.NewGuid().ToString() + ".bed";

            using (StreamWriter writter = new StreamWriter(rep1Filename))
            {
                pValue = 7.12;
                writter.WriteLine("chr1\t10\t20\tmspc_peak_1\t" + pValue.ToString(CultureInfo.CreateSpecificCulture(culture)));
                pValue = 5.5067;
                writter.WriteLine("chr1\t25\t35\tmspc_peak_2\t" + pValue.ToString(CultureInfo.CreateSpecificCulture(culture)));
            }

            string rep2Filename = Path.GetTempPath() + Guid.NewGuid().ToString() + ".bed";

            using (StreamWriter writter = new StreamWriter(rep2Filename))
            {
                pValue = 19.9;
                writter.WriteLine("chr1\t4\t12\tmspc_peak_3\t" + pValue.ToString(CultureInfo.CreateSpecificCulture(culture)));
                pValue = 8.999999;
                writter.WriteLine("chr1\t30\t45\tmspc_peak_4\t" + pValue.ToString(CultureInfo.CreateSpecificCulture(culture)));
            }

            ParserConfig cols = new ParserConfig()
            {
                Culture = culture
            };
            var configFilename = Path.GetTempPath() + Guid.NewGuid().ToString() + ".json";

            using (StreamWriter w = new StreamWriter(configFilename))
                w.WriteLine(JsonConvert.SerializeObject(cols));

            string args = $"-i {rep1Filename} -i {rep2Filename} -r bio -w 1e-2 -s 1e-4 -p {configFilename} -o {outputPath}";


            // Act
            string output;

            using (StringWriter sw = new StringWriter())
            {
                Console.SetOut(sw);
                Program.Main(args.Split(' '));
                output = sw.ToString();
            }

            var standardOutput = new StreamWriter(Console.OpenStandardOutput())
            {
                AutoFlush = true
            };

            Console.SetOut(standardOutput);

            // Assert
            Assert.Contains("All processes successfully finished", output);
            using (var reader = new StreamReader(Directory.GetFiles(outputPath, "*ConsensusPeaks.bed")[0]))
            {
                Assert.Equal("chr\tstart\tstop\tname\t-1xlog10(p-value)", reader.ReadLine());
                Assert.Equal("chr1\t4\t20\tMSPC_Peak_2\t25.219", reader.ReadLine());
                Assert.Equal("chr1\t25\t45\tMSPC_Peak_1\t12.97", reader.ReadLine());
                Assert.Null(reader.ReadLine());
            }

            var dirs = Directory.GetDirectories(outputPath);

            Assert.True(dirs.Length == 2);

            Assert.True(Directory.GetFiles(dirs[0]).Length == 14);
            string line;

            using (var reader = new StreamReader(Directory.GetFiles(dirs[0], "*TruePositive.bed")[0]))
            {
                Assert.Equal("chr\tstart\tstop\tname\t-1xlog10(p-value)", reader.ReadLine());
                line = reader.ReadLine();
                Assert.True("chr1\t10\t20\tmspc_peak_1\t7.12" == line || "chr1\t4\t12\tmspc_peak_3\t19.9" == line);
                line = reader.ReadLine();
                Assert.True("chr1\t25\t35\tmspc_peak_2\t5.507" == line || "chr1\t30\t45\tmspc_peak_4\t9" == line);
                Assert.Null(reader.ReadLine());
            }

            Assert.True(Directory.GetFiles(dirs[1]).Length == 14);
            using (var reader = new StreamReader(Directory.GetFiles(dirs[1], "*TruePositive.bed")[0]))
            {
                Assert.Equal("chr\tstart\tstop\tname\t-1xlog10(p-value)", reader.ReadLine());
                line = reader.ReadLine();
                Assert.True("chr1\t10\t20\tmspc_peak_1\t7.12" == line || "chr1\t4\t12\tmspc_peak_3\t19.9" == line);
                line = reader.ReadLine();
                Assert.True("chr1\t25\t35\tmspc_peak_2\t5.507" == line || "chr1\t30\t45\tmspc_peak_4\t9" == line);
                Assert.Null(reader.ReadLine());
            }

            // Clean up
            Directory.Delete(outputPath, true);
            File.Delete(rep1Filename);
            File.Delete(rep2Filename);
        }
Exemplo n.º 31
0
        public static int Main(string[] args)
        {
            if (args.Length == 0)
            {
                outwriter.WriteLine(" Please provide filename to sort");
                return 1;
            }
            IFileWrapper input = new StreamWrapper(args[0]);
            ISort sortImpl = new ArraySorter();
            TextWriter output = Console.Out;

            Program app = new Program(input, sortImpl, output);
            return app.Main();
        }
Exemplo n.º 32
0
 public void Should_Throw_Exception_If_Path_Argument_Is_Empty()
 {
     Assert.Throws <ArgumentException>(() => Program.Main(new[] { "" }));
 }
Exemplo n.º 33
0
 static void Main(string[] args)
 {
     Program p1 = new Program();
     p1.Main();
 }
Exemplo n.º 34
0
 public void Should_Throw_Exception_If_No_Argument_Provided()
 {
     Assert.Throws <ArgumentException>(() => Program.Main(new string[] { }));
 }
Exemplo n.º 35
0
 public void Should_Throw_Exception_If_More_Than_One_Argument_Provided()
 {
     Assert.Throws <ArgumentException>(() => Program.Main(new[] { "Arg1", "Arg2" }));
 }
Exemplo n.º 36
0
        public void MoreThanTwoArgumentsShouldNotBeAccepted()
        {
            int returnCode = Program.Main(new string[] { "asd", "asd", "asd" });

            Assert.AreEqual(1, returnCode, "More than 2 arguments should not be accepted.");
        }