GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ModuleManager/ModuleManager/ModuleManagerTestRunner.cs at master · sarbian/ModuleManager

Expand file tree

/

ModuleManagerTestRunner.cs

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
75 lines (69 loc) · 2.95 KB
/

ModuleManagerTestRunner.cs

Copy path

File metadata and controls

75 lines (69 loc) · 2.95 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ModuleManager.Extensions;
using ModuleManager.Logging;
namespace ModuleManager
{
public class InGameTestRunner
{
private readonly IBasicLogger logger;
public InGameTestRunner(IBasicLogger logger)
{
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public void RunTestCases(UrlDir gameDatabaseRoot)
{
if (gameDatabaseRoot == null) throw new ArgumentNullException(nameof(gameDatabaseRoot));
logger.Info("Running tests...");
foreach (UrlDir.UrlConfig expect in gameDatabaseRoot.GetConfigs("MMTEST_EXPECT"))
{
// So for each of the expects, we expect all the configs before that node to match exactly.
UrlDir.UrlFile parent = expect.parent;
if (parent.configs.Count != expect.config.CountNodes + 1)
{
logger.Error("Test " + parent.name + " failed as expected number of nodes differs expected: " +
expect.config.CountNodes + " found: " + (parent.configs.Count - 1));
for (int i = 0; i < parent.configs.Count; ++i)
logger.Info(parent.configs[i].config.ToString());
continue;
}
for (int i = 0; i < expect.config.CountNodes; ++i)
{
ConfigNode gotNode = parent.configs[i].config;
ConfigNode expectNode = expect.config.nodes[i];
if (!CompareRecursive(expectNode, gotNode))
{
logger.Error("Test " + parent.name + "[" + i +
"] failed as expected output and actual output differ.\nexpected:\n" + expectNode +
"\nActually got:\n" + gotNode);
}
}
// Purge the tests
parent.configs.Clear();
}
logger.Info("tests complete.");
}
private static bool CompareRecursive(ConfigNode expectNode, ConfigNode gotNode)
{
if (expectNode.values.Count != gotNode.values.Count || expectNode.nodes.Count != gotNode.nodes.Count)
return false;
for (int i = 0; i < expectNode.values.Count; ++i)
{
ConfigNode.Value eVal = expectNode.values[i];
ConfigNode.Value gVal = gotNode.values[i];
if (eVal.name != gVal.name || eVal.value != gVal.value)
return false;
}
for (int i = 0; i < expectNode.nodes.Count; ++i)
{
ConfigNode eNode = expectNode.nodes[i];
ConfigNode gNode = gotNode.nodes[i];
if (!CompareRecursive(eNode, gNode))
return false;
}
return true;
}
}
}
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.