示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void acceptsRelationshipsMetadata() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void AcceptsRelationshipsMetadata()
        {
            File            homeDir             = _testDir.directory("home");
            ImporterFactory mockImporterFactory = mock(typeof(ImporterFactory));
            Importer        importer            = mock(typeof(Importer));

            when(mockImporterFactory.GetImporterForMode(eq("csv"), any(typeof(Args)), any(typeof(Config)), any(typeof(OutsideWorld)))).thenReturn(importer);

            ImportCommand importCommand = new ImportCommand(homeDir.toPath(), _testDir.directory("conf").toPath(), new RealOutsideWorld(System.out, System.err, new MemoryStream(new sbyte[0])), mockImporterFactory);

            string[] arguments = new string[] { "--database=foo", "--from=bar", "--relationships:LIKES:HATES=mock.csv" };

            importCommand.Execute(arguments);

            verify(mockImporterFactory).getImporterForMode(eq("csv"), any(typeof(Args)), any(typeof(Config)), any(typeof(OutsideWorld)));
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void defaultsToCsvWhenModeNotSpecified() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void DefaultsToCsvWhenModeNotSpecified()
        {
            File            homeDir             = _testDir.directory("home");
            ImporterFactory mockImporterFactory = mock(typeof(ImporterFactory));
            Importer        importer            = mock(typeof(Importer));

            when(mockImporterFactory.GetImporterForMode(eq("csv"), any(typeof(Args)), any(typeof(Config)), any(typeof(OutsideWorld)))).thenReturn(importer);

            using (RealOutsideWorld outsideWorld = new RealOutsideWorld(System.out, System.err, new MemoryStream(new sbyte[0])))
            {
                ImportCommand importCommand = new ImportCommand(homeDir.toPath(), _testDir.directory("conf").toPath(), outsideWorld, mockImporterFactory);

                string[] arguments = new string[] { "--database=foo", "--from=bar" };

                importCommand.Execute(arguments);

                verify(mockImporterFactory).getImporterForMode(eq("csv"), any(typeof(Args)), any(typeof(Config)), any(typeof(OutsideWorld)));
            }
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void letImporterDecideAboutDatabaseExistence() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void LetImporterDecideAboutDatabaseExistence()
        {
            File          report        = _testDir.file("report");
            Path          homeDir       = _testDir.directory("home").toPath();
            PrintStream   nullOutput    = new PrintStream(NULL_OUTPUT_STREAM);
            OutsideWorld  outsideWorld  = new RealOutsideWorld(nullOutput, nullOutput, new MemoryStream(new sbyte[0]));
            Path          confPath      = _testDir.directory("conf").toPath();
            ImportCommand importCommand = new ImportCommand(homeDir, confPath, outsideWorld);
            File          nodesFile     = CreateTextFile("nodes.csv", ":ID", "1", "2");

            string[] arguments = new string[] { "--mode=csv", "--database=existing.db", "--nodes=" + nodesFile.AbsolutePath, "--report-file=" + report.AbsolutePath };

            // First run an import so that a database gets created
            importCommand.Execute(arguments);

            // When
            ImporterFactory importerFactory = mock(typeof(ImporterFactory));
            Importer        importer        = mock(typeof(Importer));

            when(importerFactory.GetImporterForMode(any(), any(), any(), any())).thenReturn(importer);
            (new ImportCommand(homeDir, confPath, outsideWorld, importerFactory)).Execute(arguments);

            // Then no exception about database existence should be thrown
        }