forked from ScottPlot/ScottPlot
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: test cookbook using new generator
- Loading branch information
Showing
2 changed files
with
11 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
src/cookbook/output | ||
nuget.exe | ||
|
||
## Ignore Visual Studio temporary files, build results, and | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,32 @@ | ||
using NUnit.Framework; | ||
using ScottPlot.Cookbook; | ||
using ScottPlot.Cookbook.Website; | ||
using ScottPlot.Cookbook.Website.Pages; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ScottPlotTests.Cookbook | ||
{ | ||
class Generate | ||
{ | ||
/// <summary> | ||
/// Source folder containing the original .cs files that will be parsed to get recipe source code | ||
/// </summary> | ||
const string SourceFolder = "../../../../cookbook/ScottPlot.Cookbook"; | ||
|
||
/// <summary> | ||
/// The folder that will store isolated code example text files | ||
/// </summary> | ||
const string RecipeFolder = "./cookbook/source"; | ||
|
||
/// <summary> | ||
/// The folder to put the website into | ||
/// </summary> | ||
const string WebsitePath = "./website"; | ||
const string COOKBOOK_PROJECT_FOLDER = "../../../../cookbook/ScottPlot.Cookbook"; | ||
const string COOKBOOK_OUTPUT_FOLDER = "../../../../cookbook/output"; | ||
|
||
[OneTimeSetUp] | ||
public void Setup() | ||
{ | ||
CreateFolder(RecipeFolder); | ||
CreateFolder(WebsitePath); | ||
} | ||
|
||
private static void CreateFolder(string path) | ||
{ | ||
if (!Directory.Exists(path)) | ||
Directory.CreateDirectory(path); | ||
} | ||
|
||
[Test] | ||
public void Test_Cookbook_ImagesAndCode() | ||
{ | ||
Chef.CreateCookbookImages(Path.Join(WebsitePath, "images")); | ||
Chef.CreateCookbookSource(SourceFolder, RecipeFolder); | ||
} | ||
|
||
[Test] | ||
public void Test_Webpage_CookbookCategoryPages() | ||
{ | ||
string cookbookFolder = Path.Combine(WebsitePath, "category"); | ||
CreateFolder(cookbookFolder); | ||
foreach (var categoryName in Locate.GetCategories()) | ||
{ | ||
var page = new CookbookCategoryPage(categoryName); | ||
|
||
string categoryFolder = Path.Combine(cookbookFolder, Page.Sanitize(categoryName)); | ||
CreateFolder(categoryFolder); | ||
string mdFilePath = Path.Combine(categoryFolder, "index.md"); | ||
page.SaveMarkdown(mdFilePath); | ||
Console.WriteLine(Path.GetFullPath(mdFilePath)); | ||
} | ||
} | ||
|
||
[Test] | ||
public void Test_Webpage_CookIndexPage() | ||
public void OneTimeSetup() | ||
{ | ||
var page = new CookbookHomePage(); | ||
string mdPath = Path.Combine(WebsitePath, "index.md"); | ||
page.SaveMarkdown(mdPath); | ||
Console.WriteLine(Path.GetFullPath(mdPath)); | ||
if (Directory.Exists(COOKBOOK_OUTPUT_FOLDER)) | ||
Directory.Delete(COOKBOOK_OUTPUT_FOLDER, recursive: true); | ||
Directory.CreateDirectory(COOKBOOK_OUTPUT_FOLDER); | ||
} | ||
|
||
[Test] | ||
public void Test_Webpage_PlotApi() | ||
public void Test_Generate_RecipeImages() | ||
{ | ||
var page = new PlotApiPage(); | ||
string mdFilePath = Path.Combine(WebsitePath, "api/plot/index.md"); | ||
CreateFolder(Path.GetDirectoryName(mdFilePath)); | ||
page.SaveMarkdown(mdFilePath); | ||
Console.WriteLine(); | ||
Console.WriteLine(Path.GetFullPath(mdFilePath)); | ||
Chef.CreateCookbookImages(Path.Join(COOKBOOK_OUTPUT_FOLDER, "images")); | ||
} | ||
|
||
[Test] | ||
public void Test_Webpage_ForEveryPlottable() | ||
public void Test_Generate_RecipeSourceJson() | ||
{ | ||
string plottableFolder = WebsitePath + "/api/plottable"; | ||
CreateFolder(plottableFolder); | ||
foreach (var plottableType in Locate.GetPlottableTypes()) | ||
{ | ||
var page = new PlottableApiPage(plottableType); | ||
string thisPlottableFolder = plottableFolder + "/" + Page.Sanitize(plottableType.Name); | ||
CreateFolder(thisPlottableFolder); | ||
string mdPath = thisPlottableFolder + "/index.md"; | ||
//CreateFolder(thisPlottableFolder); | ||
page.SaveMarkdown(mdPath); | ||
Console.WriteLine(Path.GetFullPath(mdPath)); | ||
} | ||
Chef.CreateRecipesJson(COOKBOOK_PROJECT_FOLDER, Path.Join(COOKBOOK_OUTPUT_FOLDER, "recipes.json")); | ||
} | ||
} | ||
} |