Exemple #1
0
        public void MethodNameTest()
        {
            var testsGenerator = new NUnitTestsGenerator();
            var waiter         = testsGenerator.GenerateTests(new [] { _fileForTest }, _folderForTests, 8, 8, 8);

            waiter.Wait();
            var testFile = Directory.GetFiles(_folderForTests).First(file => Path.GetFileName(file) == "BarClassTests.cs");
            var text     = GetText(testFile);
            var tree     = CSharpSyntaxTree.ParseText(text);
            var root     = tree.GetRoot();
            var method   = root.DescendantNodes().OfType <MethodDeclarationSyntax>().First();

            Assert.AreEqual("MyPublicMethodTest", method.Identifier.ValueText);
        }
Exemple #2
0
        public void SyntaxErrorTest()
        {
            ClearFolder(_folderForTests);
            var testsGenerator = new NUnitTestsGenerator();
            var waiter         = testsGenerator.GenerateTests(new[] { _fileForTest }, _folderForTests, 8, 8, 8);

            waiter.Wait();
            var testFile    = Directory.GetFiles(_folderForTests).First(file => Path.GetFileName(file) == "BarClassTests.cs");
            var text        = GetText(testFile);
            var tree        = CSharpSyntaxTree.ParseText(text);
            var diagnostics = tree.GetDiagnostics().FirstOrDefault(n => n.Severity == DiagnosticSeverity.Error);

            Assert.IsNull(diagnostics);
        }
Exemple #3
0
        public void FileNameTest()
        {
            var testsGenerator = new NUnitTestsGenerator();
            var waiter         = testsGenerator.GenerateTests(new [] { _fileForTest }, _folderForTests, 8, 8, 8);

            waiter.Wait();
            var testFiles  = Directory.GetFiles(_folderForTests).Select(Path.GetFileName);
            var contains   = false;
            var cs         = "BarClassTests.cs";
            var enumerable = testFiles as string[] ?? testFiles.ToArray();

            foreach (var file in enumerable)
            {
                if (Equals(file, cs))
                {
                    contains = true;
                    break;
                }
            }

            Assert.IsTrue(contains);
            Assert.IsTrue(enumerable.Contains("FooClassTests.cs"));
            Assert.AreEqual(2, enumerable.ToArray().Length);
        }