public void TestDoesntExist() { using var tmpdir = new TemporaryDirectory(); string outputPath = Path.Join(tmpdir.Path, "DocTestSomeProgram.cs"); string programText = @" /// <code doctest=""true""> /// var x = 1; /// </code> "; var doctestsAndErrors = Extraction.Extract( CSharpSyntaxTree.ParseText( programText)); Assert.AreEqual(0, doctestsAndErrors.Errors.Count); var doctests = doctestsAndErrors.Doctests; // Test pre-condition Assert.IsFalse(File.Exists(outputPath)); var got = Process.Check(doctests, "SomeProgram.cs", outputPath); Assert.IsInstanceOf <Report.DoesntExist>(got); }
public void Test(string text, string[] expectedNamespaces) { var tree = CSharpSyntaxTree.ParseText(text); var doctestsAndErrors = Extraction.Extract(tree); Assert.That(doctestsAndErrors.Errors, Is.EquivalentTo(new List <Extraction.Error>())); var doctests = doctestsAndErrors.Doctests; var gotNamespaces = doctests.Select((doctest) => doctest.Namespace).ToList(); Assert.That(gotNamespaces, Is.EquivalentTo(expectedNamespaces)); }
public void TestOkNoDoctest() { using var tmpdir = new TemporaryDirectory(); string outputPath = Path.Join(tmpdir.Path, "DocTestSomeProgram.cs"); var doctestsAndErrors = Extraction.Extract( CSharpSyntaxTree.ParseText( "No doctest at all")); Assert.AreEqual(0, doctestsAndErrors.Errors.Count); var doctests = doctestsAndErrors.Doctests; var got = Process.Check(doctests, "SomeProgram.cs", outputPath); Assert.IsInstanceOf <Report.Ok>(got); }
public void TestOkNoDoctest() { using var tmpdir = new TemporaryDirectory(); string outputPath = Path.Join(tmpdir.Path, "Output.cs"); var doctestsAndErrors = Extraction.Extract( CSharpSyntaxTree.ParseText( "No doctest at all")); Assert.AreEqual(0, doctestsAndErrors.Errors.Count); var doctests = doctestsAndErrors.Doctests; Process.Report got = Process.Check(doctests, outputPath); Assert.AreEqual(Process.Report.Ok, got); }
public void TestNoDoctest() { using var tmpdir = new TemporaryDirectory(); string outputPath = Path.Join(tmpdir.Path, "DocTestSomeProgram.cs"); var doctestsAndErrors = Extraction.Extract( CSharpSyntaxTree.ParseText( "No doctest at all")); Assert.AreEqual(0, doctestsAndErrors.Errors.Count); var doctests = doctestsAndErrors.Doctests; bool got = Process.Generate(doctests, "SomeProgram.cs", outputPath); Assert.IsFalse(got); Assert.IsFalse(File.Exists(outputPath)); }
public void Extract(SelectionObjectData item) { ItemBase i = Extraction.Extract(item.item).GetComponent <ItemBase>(); ItemsDescription des = i.itemProperties.itemDescription; des.GetItemType(); //The extraction will take default information from the prefab object. //must check if the item type is already present. int phVal = des.pHValue; AddItem(i); //invenetory will take care of everything checking for ph if present. //IF the item type is already present, it's pH value in the description data must be checked. //If the pH is same, the extra volume must be added to the existing item slot }
public void TestShouldntExist() { using var tmpdir = new TemporaryDirectory(); string outputPath = Path.Join(tmpdir.Path, "DocTestSomeProgram.cs"); var doctestsAndErrors = Extraction.Extract( CSharpSyntaxTree.ParseText( "no doctest")); Assert.AreEqual(0, doctestsAndErrors.Errors.Count); var doctests = doctestsAndErrors.Doctests; File.WriteAllText(outputPath, "should not exist"); var got = Process.Check(doctests, "SomeProgram.cs", outputPath); Assert.IsInstanceOf <Report.ShouldNotExist>(got); }
public void TestOkDoctest() { using var tmpdir = new TemporaryDirectory(); string outputPath = Path.Join(tmpdir.Path, "DocTestSomeProgram.cs"); string programText = @" /// <code doctest=""true""> /// var x = 1; /// </code> "; var doctestsAndErrors = Extraction.Extract( CSharpSyntaxTree.ParseText( programText)); Assert.AreEqual(0, doctestsAndErrors.Errors.Count); var doctests = doctestsAndErrors.Doctests; File.WriteAllText(outputPath, @"// This file was automatically generated by doctest-csharp. // !!! DO NOT EDIT OR APPEND !!! using NUnit.Framework; namespace Tests { public class DocTest_SomeProgram_cs { [Test] public void AtLine1AndColumn4() { var x = 1; } } } // This file was automatically generated by doctest-csharp. // !!! DO NOT EDIT OR APPEND !!! "); var got = Process.Check(doctests, "SomeProgram.cs", outputPath); Assert.IsInstanceOf <Report.Ok>(got); }
public void TestDoctest() { using var tmpdir = new TemporaryDirectory(); string outputPath = Path.Join(tmpdir.Path, "DocTestSomeProgram.cs"); var doctestsAndErrors = Extraction.Extract( CSharpSyntaxTree.ParseText( @"/// <code doctest=""true""> /// var x = 1; /// </code>")); Assert.AreEqual(0, doctestsAndErrors.Errors.Count); var doctests = doctestsAndErrors.Doctests; bool got = Process.Generate(doctests, "SomeProgram.cs", outputPath); Assert.IsTrue(got); Assert.IsTrue(File.Exists(outputPath)); Assert.AreEqual(@"// This file was automatically generated by doctest-csharp. // !!! DO NOT EDIT OR APPEND !!! using NUnit.Framework; namespace Tests { public class DocTest_SomeProgram_cs { [Test] public void AtLine0AndColumn4() { var x = 1; } } } // This file was automatically generated by doctest-csharp. // !!! DO NOT EDIT OR APPEND !!! ", File.ReadAllText(outputPath)); }
void ExecuteSaveFileCommand() { SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.Title = "Valitse tallennettavan tiedoston polku"; saveDialog.Filter = "PDF (.pdf)|*.pdf"; saveDialog.InitialDirectory = Path.GetDirectoryName(FilePath); if (saveDialog.ShowDialog() != true) { return; } Extraction.Extract(FilePath, saveDialog.FileName, FileBookmarks); SelectedBookmark = null; var p = new Process(); p.StartInfo = new ProcessStartInfo(@saveDialog.FileName) { UseShellExecute = true }; p.Start(); }
public void TestDifferent() { using var tmpdir = new TemporaryDirectory(); string outputPath = Path.Join(tmpdir.Path, "Output.cs"); string programText = @" /// <code doctest=""true""> /// var x = 1; /// </code> "; var doctestsAndErrors = Extraction.Extract( CSharpSyntaxTree.ParseText( programText)); Assert.AreEqual(0, doctestsAndErrors.Errors.Count); var doctests = doctestsAndErrors.Doctests; File.WriteAllText(outputPath, "different content"); Process.Report got = Process.Check(doctests, outputPath); Assert.AreEqual(Process.Report.Different, got); }
public void TestMethodDoctest() { string text = @" namespace SomeNamespace { public static class SomeClass { /// <summary> /// Does something. /// </summary> /// <code doctest=""true""> /// using Microsoft.CodeAnalysis.SyntaxTree; /// // --- /// var x = 1; /// </code> public void SomeMethod() { // some implementation var y = 2; } /// <summary> /// Does something else. /// </summary> /// <code doctest=""true""> /// var y = 2; /// </code> public void AnotherMethod() { // another implementation var z = 3; } } } "; var expected = new List <Extraction.Doctest> { new Extraction.Doctest( ns: "SomeNamespace", usings: new List <Extraction.UsingDirective> { new Extraction.UsingDirective("Microsoft.CodeAnalysis.SyntaxTree", null) }, body: "var x = 1;", line: 8, column: 12), new Extraction.Doctest( ns: "SomeNamespace", usings: new List <Extraction.UsingDirective>(), body: "var y = 2;", line: 22, column: 12) }; var tree = CSharpSyntaxTree.ParseText(text); var doctestsAndErrors = Extraction.Extract(tree); Assert.That(doctestsAndErrors.Errors, Is.EquivalentTo(new List <Extraction.Error>())); var doctests = doctestsAndErrors.Doctests; Assert.AreEqual(expected.Count, doctests.Count); for (var i = 0; i < doctests.Count; i++) { Assert.AreEqual(expected[i].Namespace, doctests[i].Namespace); Assert.That(doctests[i].Usings, Is.EquivalentTo(expected[i].Usings)); Assert.AreEqual(expected[i].Body, doctests[i].Body); Assert.AreEqual(expected[i].Line, doctests[i].Line); Assert.AreEqual(expected[i].Column, doctests[i].Column); } }