コード例 #1
0
        public void CanParseEmptyLines()
        {
            string             comment;
            TeaboxDataLineType type;

            string[] data;

            TestReader.PublicParseLine("", out comment, out type, out data);

            Assert.That(comment, Is.EqualTo(""));
            Assert.That(type, Is.EqualTo(TeaboxDataLineType.Other));
            Assert.That(data.Length, Is.EqualTo(0));

            TestReader.PublicParseLine("    ", out comment, out type, out data);

            Assert.That(comment, Is.EqualTo(""));
            Assert.That(type, Is.EqualTo(TeaboxDataLineType.Other));
            Assert.That(data.Length, Is.EqualTo(0));

            TestReader.PublicParseLine("\t\t\t", out comment, out type, out data);

            Assert.That(comment, Is.EqualTo(""));
            Assert.That(type, Is.EqualTo(TeaboxDataLineType.Other));
            Assert.That(data.Length, Is.EqualTo(0));
        }
コード例 #2
0
        public void CanParseCommentedLines()
        {
            string             comment;
            TeaboxDataLineType type;

            string[] data;

            TestReader.PublicParseLine("// Hello", out comment, out type, out data);

            Assert.That(comment, Is.EqualTo(" Hello"));
            Assert.That(type, Is.EqualTo(TeaboxDataLineType.Other));
            Assert.That(data.Length, Is.EqualTo(0));

            TestReader.PublicParseLine("   // World", out comment, out type, out data);

            Assert.That(comment, Is.EqualTo(" World"));
            Assert.That(type, Is.EqualTo(TeaboxDataLineType.Other));
            Assert.That(data.Length, Is.EqualTo(0));

            TestReader.PublicParseLine("\t\t// Tab", out comment, out type, out data);

            Assert.That(comment, Is.EqualTo(" Tab"));
            Assert.That(type, Is.EqualTo(TeaboxDataLineType.Other));
            Assert.That(data.Length, Is.EqualTo(0));
        }
コード例 #3
0
    internal void SetTestName(string name)
    {
        TestsList testsList = TestReader.GetTestList(name);

        ResetTest();
        EditTest(testsList);
    }
コード例 #4
0
        public void WillNotTrimAwayEmptyColumn()
        {
            string             comment;
            TeaboxDataLineType type;

            string[] data;

            TestReader.PublicParseLine("\tData2\tData3   ", out comment, out type, out data);

            Assert.That(data.Length, Is.EqualTo(3));
            Assert.That(type, Is.EqualTo(TeaboxDataLineType.Data));
            Assert.That(data[0], Is.EqualTo(""));
            Assert.That(data[1], Is.EqualTo("Data2"));
            Assert.That(data[2], Is.EqualTo("Data3"));

            TestReader.PublicParseLine("\tData2\tData3\t", out comment, out type, out data);

            Assert.That(data.Length, Is.EqualTo(3));
            Assert.That(type, Is.EqualTo(TeaboxDataLineType.Data));
            Assert.That(data[0], Is.EqualTo(""));
            Assert.That(data[1], Is.EqualTo("Data2"));
            Assert.That(data[2], Is.EqualTo("Data3"));

            TestReader.PublicParseLine("\t  Data2\tData3   ", out comment, out type, out data);

            Assert.That(data.Length, Is.EqualTo(3));
            Assert.That(type, Is.EqualTo(TeaboxDataLineType.Data));
            Assert.That(data[0], Is.EqualTo(""));
            Assert.That(data[1], Is.EqualTo("Data2"));
            Assert.That(data[2], Is.EqualTo("Data3"));
        }
コード例 #5
0
        public void SetUp()
        {
            XmlElement element = new XmlDocument().WithRoot("Test")
                                 .WithAtt("name", "the test name")
                                 .With(elem =>
            {
                elem.AddElement("Address").With(x =>
                {
                    x.AddElement("Grammar1").WithAttributes("name:Jeremy,email:[email protected],phone:555-555-5555");
                    x.AddElement("Grammar2").WithAttributes("name:Josh");
                    x.AddElement("AGrammar").WithAttributes("cost:123.4");
                });


                elem.AddElement("Site").With(x =>
                {
                    x.AddElement("SiteGrammar1").WithAttributes("a:1,b:2");
                    x.AddElement("SiteGrammar2").WithAttributes("a:1,b:2");
                });

                elem.AddElement("Contact").With(x =>
                {
                    x.AddElement("ContactGrammar1").WithAttributes("a:1,b:2");
                    x.AddElement("ContactGrammar2").WithAttributes("a:1,b:2");
                });
            });

            test = new TestReader().ReadTest(element);
        }
コード例 #6
0
        static TestReader CreateTestReader1()
        {
            TestReader reader = new TestReader(
                new long[] { 0, 4, 5, 6, 10, 15, 20, 30, 40, 50 });

            return(reader);
        }
コード例 #7
0
        public void CanParseTitles()
        {
            string             comment;
            TeaboxDataLineType type;

            string[] data;

            TestReader.PublicParseLine("!Title1\tTitle2\tTitle3", out comment, out type, out data);

            Assert.That(data.Length, Is.EqualTo(3));
            Assert.That(type, Is.EqualTo(TeaboxDataLineType.Titles));
            Assert.That(data[0], Is.EqualTo("Title1"));
            Assert.That(data[1], Is.EqualTo("Title2"));
            Assert.That(data[2], Is.EqualTo("Title3"));
            Assert.That(comment, Is.EqualTo(""));

            TestReader.PublicParseLine("!Title1\tTitle2\tTitle3 // World", out comment, out type, out data);

            Assert.That(data.Length, Is.EqualTo(3));
            Assert.That(type, Is.EqualTo(TeaboxDataLineType.Titles));
            Assert.That(data[0], Is.EqualTo("Title1"));
            Assert.That(data[1], Is.EqualTo("Title2"));
            Assert.That(data[2], Is.EqualTo("Title3"));
            Assert.That(comment, Is.EqualTo(" World"));
        }
コード例 #8
0
                public Parser(TestReader reader, long startPosition, LogJoint.FileRange.Range?range, MessagesParserDirection direction)
                {
                    this.reader    = reader;
                    this.range     = range;
                    this.direction = direction;

                    if (direction == MessagesParserDirection.Forward)
                    {
                        for (positionIndex = 0; positionIndex < reader.positions.Length; ++positionIndex)
                        {
                            if (reader.positions[positionIndex] >= startPosition)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        for (positionIndex = reader.positions.Length - 1; positionIndex >= 0; --positionIndex)
                        {
                            if (reader.positions[positionIndex] < startPosition)
                            {
                                break;
                            }
                        }
                    }
                }
コード例 #9
0
    internal void DeleteTest(EditTestEntry entry)
    {
        var name = entry.m_name.text;

        TestReader.DeleteTest(name);
        m_entries.Remove(entry);
        Destroy(entry.gameObject);
    }
コード例 #10
0
        public void the_test_should_now_be_saved_at_the_new_file_location()
        {
            File.Exists("New Name.xml");

            Test test2 = new TestReader().ReadFromFile("New Name.xml");

            test2.Parts[0].ShouldBeOfType <Comment>().Text.ShouldEqual("some comment");
        }
コード例 #11
0
ファイル: TestUtility.cs プロジェクト: larsw/storyteller
        public static Test ReadTest(string xml)
        {
            xml = xml.Replace("'", "\"");

            XmlDocument document = new XmlDocument().WithXmlText(xml);
            var         reader   = new TestReader();

            return(reader.ReadTest(document.DocumentElement));
        }
コード例 #12
0
        public Test Clone(string name)
        {
            XmlDocument document = new TestWriter().Write(this);
            Test        clone    = new TestReader().ReadTest(document.DocumentElement);

            clone.Name = name;

            return(clone);
        }
コード例 #13
0
        public virtual void TestFilterIndexReader()
        {
            Directory directory = NewDirectory();

            IndexWriter writer = new IndexWriter(directory, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)));

            Document d1 = new Document();

            d1.Add(NewTextField("default", "one two", Field.Store.YES));
            writer.AddDocument(d1);

            Document d2 = new Document();

            d2.Add(NewTextField("default", "one three", Field.Store.YES));
            writer.AddDocument(d2);

            Document d3 = new Document();

            d3.Add(NewTextField("default", "two four", Field.Store.YES));
            writer.AddDocument(d3);

            writer.Dispose();

            Directory target = NewDirectory();

            // We mess with the postings so this can fail:
            ((BaseDirectoryWrapper)target).CrossCheckTermVectorsOnDispose = false;

            writer = new IndexWriter(target, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)));
            IndexReader reader = new TestReader(DirectoryReader.Open(directory));

            writer.AddIndexes(reader);
            writer.Dispose();
            reader.Dispose();
            reader = DirectoryReader.Open(target);

            TermsEnum terms = MultiFields.GetTerms(reader, "default").GetEnumerator();

            while (terms.MoveNext())
            {
                Assert.IsTrue(terms.Term.Utf8ToString().IndexOf('e') != -1);
            }

            Assert.AreEqual(TermsEnum.SeekStatus.FOUND, terms.SeekCeil(new BytesRef("one")));

            DocsAndPositionsEnum positions = terms.DocsAndPositions(MultiFields.GetLiveDocs(reader), null);

            while (positions.NextDoc() != DocIdSetIterator.NO_MORE_DOCS)
            {
                Assert.IsTrue((positions.DocID % 2) == 1);
            }

            reader.Dispose();
            directory.Dispose();
            target.Dispose();
        }
コード例 #14
0
        public DataBinderBenchmarks()
        {
            var schema = Schema.Parse("B:Boolean,D:DateTime,V:Double,G:Guid,I:Int32,S:String");
            var record = new TestReader(1);

            this.item         = new Record();
            this.compiled     = DataBinder.Create <Record>(schema);
            this.dapperBinder = record.GetRowParser <Record>();
            this.testReader   = new TestReader(Count);
        }
コード例 #15
0
        public virtual void  TestFilterIndexReader_Renamed()
        {
            RAMDirectory directory = new MockRAMDirectory();
            IndexWriter  writer    = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);

            Document d1 = new Document();

            d1.Add(new Field("default", "one two", Field.Store.YES, Field.Index.ANALYZED));
            writer.AddDocument(d1);

            Document d2 = new Document();

            d2.Add(new Field("default", "one three", Field.Store.YES, Field.Index.ANALYZED));
            writer.AddDocument(d2);

            Document d3 = new Document();

            d3.Add(new Field("default", "two four", Field.Store.YES, Field.Index.ANALYZED));
            writer.AddDocument(d3);

            writer.Close();

            IndexReader reader = new TestReader(IndexReader.Open(directory));

            Assert.IsTrue(reader.IsOptimized());

            TermEnum terms = reader.Terms();

            while (terms.Next())
            {
                Assert.IsTrue(terms.Term().Text().IndexOf('e') != -1);
            }
            terms.Close();

            TermPositions positions = reader.TermPositions(new Term("default", "one"));

            while (positions.Next())
            {
                Assert.IsTrue((positions.Doc() % 2) == 1);
            }

            int NUM_DOCS = 3;

            TermDocs td = reader.TermDocs(null);

            for (int i = 0; i < NUM_DOCS; i++)
            {
                Assert.IsTrue(td.Next());
                Assert.AreEqual(i, td.Doc());
                Assert.AreEqual(1, td.Freq());
            }
            td.Close();
            reader.Close();
            directory.Close();
        }
コード例 #16
0
        public void Path_Always_ReturnsPath()
        {
            // Setup
            string testFile = Path.Combine(testDataPath, "empty.sqlite");

            // Call
            var reader = new TestReader(testFile);

            // Assert
            Assert.AreEqual(testFile, reader.Path);
        }
コード例 #17
0
        public void SetUp()
        {
            XmlElement element = new XmlDocument().WithRoot("Address").With(x =>
            {
                x.AddElement("Grammar1").WithAttributes("name:Jeremy,email:[email protected],phone:555-555-5555");
                x.AddElement("Grammar2").WithAttributes("name:Josh");
                x.AddElement("AGrammar").WithAttributes("cost:123.4");
            });

            section = new TestReader().ReadSection(element);
        }
コード例 #18
0
    private void InitTests()
    {
        string[] filePaths = Directory.GetFiles(TestReader.GetTestFolderPath(), "*" + TestReader.JSON_TYPE);
        m_dropdown.ClearOptions();
        List <string> result = new List <string>();

        foreach (var path in filePaths)
        {
            result.Add(Path.GetFileNameWithoutExtension(path));
        }
        m_dropdown.AddOptions(result);
    }
コード例 #19
0
        public async Task LocateDateBound_LowerRevBound_Test1()
        {
            TestReader reader = CreateTestReader1();

            Assert.IsTrue(await PositionedMessagesUtils.LocateDateBound(reader, TestReader.PositionToDate(30), ValueBound.LowerReversed) == 30);
            Assert.IsTrue(await PositionedMessagesUtils.LocateDateBound(reader, TestReader.PositionToDate(8), ValueBound.LowerReversed) == 6);
            Assert.IsTrue(await PositionedMessagesUtils.LocateDateBound(reader, TestReader.PositionToDate(0), ValueBound.LowerReversed) == 0);
            Assert.IsTrue(await PositionedMessagesUtils.LocateDateBound(reader, TestReader.PositionToDate(-1), ValueBound.LowerReversed) == -1);
            Assert.IsTrue(await PositionedMessagesUtils.LocateDateBound(reader, TestReader.PositionToDate(-5), ValueBound.LowerReversed) == -1);
            Assert.IsTrue(await PositionedMessagesUtils.LocateDateBound(reader, TestReader.PositionToDate(50), ValueBound.LowerReversed) == 50);
            Assert.IsTrue(await PositionedMessagesUtils.LocateDateBound(reader, TestReader.PositionToDate(55), ValueBound.LowerReversed) == 50);
        }
コード例 #20
0
        private void showResultsGeneratedWithTestLog(Dictionary <string, string> testInfo, string fileContent)
        {
            TestReader testCaseReader = new TestReader();

            TestResultDecipher result = testCaseReader.runTest(testInfo, fileContent);

            result.assesTestResult();

            outputText.Invoke(new Action(() =>
            {
                resultToScreen(result);
            }));
        }
コード例 #21
0
        public void Constructor_WithParameter_OpensConnection()
        {
            // Setup
            string testFile = Path.Combine(testDataPath, "empty.sqlite");

            // Call
            using (var reader = new TestReader(testFile))
            {
                // Assert
                Assert.IsInstanceOf <SqLiteDatabaseReaderBase>(reader);
                Assert.AreEqual(ConnectionState.Open, reader.TestConnection.State);
            }
        }
コード例 #22
0
ファイル: UnitTest1.cs プロジェクト: Letractively/henoch
        public void CheckValidFile()
        {
            // arrange 
            var fileName = "test.txt";
            var content = "test";
            File.WriteAllText(fileName, content);
            
            // act 
            var test = new TestReader();
            test.LoadFile(fileName);

            // assert
            Assert.AreEqual(content, test.Content);
        }
コード例 #23
0
        private Counts running(string name)
        {
            Test test = hierarchy.GetAllTests().FirstOrDefault(x => x.Name == name);

            string json  = new TestWriter().WriteToJson(test);
            Test   test2 = new TestReader().ReadFromJson(json);

            test2.ShouldNotBeNull();
            test2.LastResult = runner.RunTest(test2);

            //runner.WriteResults(test).OpenInBrowser();

            return(test2.LastResult.Counts);
        }
コード例 #24
0
        public virtual void TestFilterIndexReader()
        {
            Directory directory = NewDirectory();

            IndexWriter writer = new IndexWriter(directory, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())));

            Document d1 = new Document();
            d1.Add(NewTextField("default", "one two", Field.Store.YES));
            writer.AddDocument(d1);

            Document d2 = new Document();
            d2.Add(NewTextField("default", "one three", Field.Store.YES));
            writer.AddDocument(d2);

            Document d3 = new Document();
            d3.Add(NewTextField("default", "two four", Field.Store.YES));
            writer.AddDocument(d3);

            writer.Dispose();

            Directory target = NewDirectory();

            // We mess with the postings so this can fail:
            ((BaseDirectoryWrapper)target).CrossCheckTermVectorsOnClose = false;

            writer = new IndexWriter(target, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())));
            IndexReader reader = new TestReader(DirectoryReader.Open(directory));
            writer.AddIndexes(reader);
            writer.Dispose();
            reader.Dispose();
            reader = DirectoryReader.Open(target);

            TermsEnum terms = MultiFields.GetTerms(reader, "default").Iterator(null);
            while (terms.Next() != null)
            {
                Assert.IsTrue(terms.Term().Utf8ToString().IndexOf('e') != -1);
            }

            Assert.AreEqual(TermsEnum.SeekStatus.FOUND, terms.SeekCeil(new BytesRef("one")));

            DocsAndPositionsEnum positions = terms.DocsAndPositions(MultiFields.GetLiveDocs(reader), null);
            while (positions.NextDoc() != DocIdSetIterator.NO_MORE_DOCS)
            {
                Assert.IsTrue((positions.DocID() % 2) == 1);
            }

            reader.Dispose();
            directory.Dispose();
            target.Dispose();
        }
コード例 #25
0
    // This is called from start and will run each phase of the game one after another. ONLY ON SERVER (as Start is only called on server)
    private IEnumerator GameLoop()
    {
        while (m_Players.Count < 1)//LobbyManager.s_Singleton.numPlayers)
        {
            yield return(null);
        }

        while (!AllPlayersReady())
        {
            RpcCheckReady();
            yield return(m_LoadingWait);
        }

        //Hack_SetupTestList();
        //TestReader.SaveTestList("test", m_currentTestList);
        //PlayFab.Internal.
        m_currentTestList = TestReader.GetTestList(m_testListName);
        if (m_currentTestList == null)
        {
            RpcShowMessageAll(FILE_NOT_FOUND);
            yield return(new WaitForSeconds(m_endGameWaitingTime));

            LobbyManager.s_Singleton.ServerReturnToLobby();
        }
        m_currentTestList.InitTests();

        RpcSetupGame(m_currentTestList.m_countOfRounds);

        while (m_currentTestList.IsRoundAvaliable())
        {
            // Start off by running the 'RoundStarting' coroutine but don't return until it's finished.
            yield return(StartCoroutine(RoundStarting()));

            // Once the 'RoundStarting' coroutine is finished, run the 'RoundPlaying' coroutine but don't return until it's finished.
            yield return(StartCoroutine(RoundPlaying()));

            // Once execution has returned here, run the 'RoundEnding' coroutine.
            yield return(StartCoroutine(RoundEnding()));

            m_currentTestList.SetTestsForNextRound();
        }

        m_GameWinnerId = GetGameWinnerId();
        RpcEndGame(m_GameWinnerId);
        UpdatePlayfabScore();
        yield return(new WaitForSeconds(m_endGameWaitingTime));

        ShowResultScreen();
    }
コード例 #26
0
ファイル: UnitTest1.cs プロジェクト: Letractively/henoch
        public void CheckValidFile2()
        {
            // arrange 
            string fileName = "test.txt";
            var content = "test";
            var fs = new MockFileSystem();
            fs.Content = content;

            // act 
            var test = new TestReader();
            test.LoadFile(fileName);

            // assert 
            Assert.AreEqual(content, test.Content);
        }
コード例 #27
0
    void SetupTests()
    {
        foreach (var entry in m_entries)
        {
            Destroy(entry.gameObject);
        }

        m_entries.Clear();
        List <TestInfo> infos = TestReader.GetAllTestsInfo();

        foreach (var info in infos)
        {
            AddTest(info);
        }
    }
コード例 #28
0
        public async Task ReadNearestDate_Test1()
        {
            TestReader reader = CreateTestReader1();

            // Exact hit to a position
            Assert.AreEqual(TestReader.PositionToDate(5), (await PositionedMessagesUtils.ReadNearestMessageTimestamp(reader, 5)).Value.ToLocalDateTime());

            // Needing to move forward to find the nearest position
            Assert.AreEqual(TestReader.PositionToDate(10), (await PositionedMessagesUtils.ReadNearestMessageTimestamp(reader, 7)).Value.ToLocalDateTime());

            // Over-the-end position
            Assert.AreEqual(new MessageTimestamp?(), await PositionedMessagesUtils.ReadNearestMessageTimestamp(reader, 55));

            //Begore the begin position
            Assert.AreEqual(TestReader.PositionToDate(0), (await PositionedMessagesUtils.ReadNearestMessageTimestamp(reader, -5)).Value.ToLocalDateTime());
        }
コード例 #29
0
        public async Task NormalizeMessagePosition_Test1()
        {
            TestReader reader = CreateTestReader1();

            Assert.IsTrue(await PositionedMessagesUtils.NormalizeMessagePosition(reader, 0) == 0);
            Assert.IsTrue(await PositionedMessagesUtils.NormalizeMessagePosition(reader, 4) == 4);
            Assert.IsTrue(await PositionedMessagesUtils.NormalizeMessagePosition(reader, 2) == 4);
            Assert.IsTrue(await PositionedMessagesUtils.NormalizeMessagePosition(reader, 3) == 4);
            Assert.IsTrue(await PositionedMessagesUtils.NormalizeMessagePosition(reader, -1) == 0);
            Assert.IsTrue(await PositionedMessagesUtils.NormalizeMessagePosition(reader, -5) == 0);
            Assert.IsTrue(await PositionedMessagesUtils.NormalizeMessagePosition(reader, 16) == 20);
            Assert.IsTrue(await PositionedMessagesUtils.NormalizeMessagePosition(reader, 50) == 50);
            Assert.IsTrue(await PositionedMessagesUtils.NormalizeMessagePosition(reader, 51) == 51);
            Assert.IsTrue(await PositionedMessagesUtils.NormalizeMessagePosition(reader, 52) == 51);
            Assert.IsTrue(await PositionedMessagesUtils.NormalizeMessagePosition(reader, 888) == 51);
        }
コード例 #30
0
 public TestOrchestrator(QuestionService questionService,
                         TestService testService,
                         GroupService groupService,
                         TestReader testReader,
                         TestServiceMapper testMapper,
                         IUserContext userContext,
                         IDateTimeProvider dateTimeProvider)
 {
     this.questionService  = questionService;
     this.testService      = testService;
     this.groupService     = groupService;
     this.testReader       = testReader;
     this.testMapper       = testMapper;
     this.userContext      = userContext;
     this.dateTimeProvider = dateTimeProvider;
 }
コード例 #31
0
        private static object DeserializeObject(byte[] rawData, IFormatter formatter)
        {
            using (MemoryStream ms = new MemoryStream(rawData))
            {
                BinaryReader br = null;
                BinarySerializationFormatter bsf = formatter as BinarySerializationFormatter;
                if (dumpDetails && bsf != null)
                {
                    br = new TestReader(ms, dumpDetails);
                }
                object result = br != null?bsf.DeserializeByReader(br) : formatter.Deserialize(ms);

                Assert.AreEqual(ms.Length, ms.Position, "Stream was not read until the end");
                return(result);
            }
        }
コード例 #32
0
        public void read_a_comment_from_directly_under_the_test_node()
        {
            string commentText = "some text in the comment";

            XmlDocument doc = new XmlDocument().Configure(x =>
            {
                x.WithRoot("Test").WithAtt("name", "something")
                .AddElement("Comment").InnerText = commentText;
            });

            var  reader = new TestReader();
            Test test   = reader.ReadTest(doc.DocumentElement);

            var comment = test.Parts[0].ShouldBeOfType <Comment>();

            comment.Text.ShouldEqual(commentText);
        }
コード例 #33
0
ファイル: TestDiscovererTests.cs プロジェクト: xyongy/PTVS
        public void TestDiscover()
        {
            var ctx    = new MockDiscoveryContext(new MockRunSettings(_runSettings));
            var sink   = new MockTestCaseDiscoverySink();
            var logger = new MockMessageLogger();

            const string projectPath  = @"C:\Visual Studio 2015\Projects\PythonApplication107\PythonApplication107\PythonApplication107.pyproj";
            const string testFilePath = @"C:\Visual Studio 2015\Projects\PythonApplication107\PythonApplication107\test1.py";

            new TestDiscoverer().DiscoverTests(
                new[] { testFilePath },
                ctx,
                logger,
                sink
                );

            PrintTestCases(sink.Tests);

            var expectedTests = new[] {
                TestInfo.FromRelativePaths("Test_test1", "test_A", projectPath, testFilePath, 17, TestOutcome.Passed),
                TestInfo.FromRelativePaths("Test_test1", "test_B", projectPath, testFilePath, 21, TestOutcome.Passed),
                TestInfo.FromRelativePaths("Test_test2", "test_C", projectPath, testFilePath, 48, TestOutcome.Passed)
            };

            Assert.AreEqual(expectedTests.Length, sink.Tests.Count);

            foreach (var expectedTest in expectedTests)
            {
                var expectedFullyQualifiedName = TestReader.MakeFullyQualifiedTestName(expectedTest.RelativeClassFilePath, expectedTest.ClassName, expectedTest.MethodName);
                var actualTestCase             = sink.Tests.SingleOrDefault(tc => tc.FullyQualifiedName == expectedFullyQualifiedName);
                Assert.IsNotNull(actualTestCase, expectedFullyQualifiedName);
                Assert.AreEqual(expectedTest.MethodName, actualTestCase.DisplayName, expectedFullyQualifiedName);
                Assert.AreEqual(new Uri(PythonConstants.TestExecutorUriString), actualTestCase.ExecutorUri);
                Assert.AreEqual(expectedTest.SourceCodeLineNumber, actualTestCase.LineNumber, expectedFullyQualifiedName);
                Assert.IsTrue(IsSameFile(expectedTest.SourceCodeFilePath, actualTestCase.CodeFilePath), expectedFullyQualifiedName);

                sink.Tests.Remove(actualTestCase);
            }

            Debug.WriteLine("");
            Debug.WriteLine("");
            Debug.WriteLine("");
            Debug.WriteLine("");

            PrintTestCases(sink.Tests);
        }
コード例 #34
0
ファイル: UnitTest1.cs プロジェクト: Letractively/henoch
        public void CheckValidFileWithMoles()
        {
            // arrange 
            var fileName = "test.txt";
            var content = "test";
            MFileSystem.ReadAllTextString = (string f) =>
                                                {
                                                    Assert.IsTrue(f == fileName);
                                                    return content;
                                                };

            // act 
            var test = new TestReader();
            test.LoadFile(fileName);

            // assert 
            Assert.AreEqual(content, test.Content);
        }
コード例 #35
0
		public virtual void  TestFilterIndexReader_Renamed_Method()
		{
			RAMDirectory directory = new MockRAMDirectory();
			IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true);
			
			Lucene.Net.Documents.Document d1 = new Lucene.Net.Documents.Document();
			d1.Add(new Field("default", "one two", Field.Store.YES, Field.Index.TOKENIZED));
			writer.AddDocument(d1);
			
			Lucene.Net.Documents.Document d2 = new Lucene.Net.Documents.Document();
			d2.Add(new Field("default", "one three", Field.Store.YES, Field.Index.TOKENIZED));
			writer.AddDocument(d2);
			
			Lucene.Net.Documents.Document d3 = new Lucene.Net.Documents.Document();
			d3.Add(new Field("default", "two four", Field.Store.YES, Field.Index.TOKENIZED));
			writer.AddDocument(d3);
			
			writer.Close();
			
			IndexReader reader = new TestReader(IndexReader.Open(directory));
			
			Assert.IsTrue(reader.IsOptimized());
			
			TermEnum terms = reader.Terms();
			while (terms.Next())
			{
				Assert.IsTrue(terms.Term().Text().IndexOf('e') != - 1);
			}
			terms.Close();
			
			TermPositions positions = reader.TermPositions(new Term("default", "one"));
			while (positions.Next())
			{
				Assert.IsTrue((positions.Doc() % 2) == 1);
			}
			
			reader.Close();
			directory.Close();
		}
コード例 #36
0
		public virtual void  TestFilterIndexReader_()
		{
			RAMDirectory directory = new RAMDirectory();
			IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true);
			
			Document d1 = new Document();
			d1.Add(Field.Text("default", "one two"));
			writer.AddDocument(d1);
			
			Document d2 = new Document();
			d2.Add(Field.Text("default", "one three"));
			writer.AddDocument(d2);
			
			Document d3 = new Document();
			d3.Add(Field.Text("default", "two four"));
			writer.AddDocument(d3);
			
			writer.Close();
			
			IndexReader reader = new TestReader(IndexReader.Open(directory));
			
			TermEnum terms = reader.Terms();
			while (terms.Next())
			{
				Assert.IsTrue(terms.Term().Text().IndexOf((System.Char) 'e') != - 1);
			}
			terms.Close();
			
			TermPositions positions = reader.TermPositions(new Term("default", "one"));
			while (positions.Next())
			{
				Assert.IsTrue((positions.Doc() % 2) == 1);
			}
			
			reader.Close();
		}
コード例 #37
0
		public virtual void  TestFilterIndexReader_Renamed()
		{
			RAMDirectory directory = new MockRAMDirectory();
			IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
			
			Document d1 = new Document();
			d1.Add(new Field("default", "one two", Field.Store.YES, Field.Index.ANALYZED));
			writer.AddDocument(d1);
			
			Document d2 = new Document();
			d2.Add(new Field("default", "one three", Field.Store.YES, Field.Index.ANALYZED));
			writer.AddDocument(d2);
			
			Document d3 = new Document();
			d3.Add(new Field("default", "two four", Field.Store.YES, Field.Index.ANALYZED));
			writer.AddDocument(d3);
			
			writer.Close();
			
			IndexReader reader = new TestReader(IndexReader.Open(directory));
			
			Assert.IsTrue(reader.IsOptimized());
			
			TermEnum terms = reader.Terms();
			while (terms.Next())
			{
				Assert.IsTrue(terms.Term().Text().IndexOf('e') != - 1);
			}
			terms.Close();
			
			TermPositions positions = reader.TermPositions(new Term("default", "one"));
			while (positions.Next())
			{
				Assert.IsTrue((positions.Doc() % 2) == 1);
			}
			
			int NUM_DOCS = 3;
			
			TermDocs td = reader.TermDocs(null);
			for (int i = 0; i < NUM_DOCS; i++)
			{
				Assert.IsTrue(td.Next());
				Assert.AreEqual(i, td.Doc());
				Assert.AreEqual(1, td.Freq());
			}
			td.Close();
			reader.Close();
			directory.Close();
		}