Skip to content

Commit

Permalink
Refactoring to get rid of xml all around the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Terje Sandstrom committed Jan 24, 2020
1 parent 5c9bd67 commit 8ec9370
Show file tree
Hide file tree
Showing 20 changed files with 833 additions and 156 deletions.
79 changes: 79 additions & 0 deletions .gitignore
Expand Up @@ -332,3 +332,82 @@ tools/
.history
/Dump
/src/NUnitTestAdapterTests/Dump
*.rsuser
# Mono auto generated files
mono_crash.*
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
# Visual Studio 2017 auto generated files
Generated\ Files/
# NUnit
nunit-*.xml
# Benchmark Results
BenchmarkDotNet.Artifacts/
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_h.h
*.iobj
*.ipdb
*_wpftmp.csproj
# Visual Studio Trace Files
*.e2e
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*[.json, .xml, .info]
# Note: Comment the next line if you want to checkin your web deploy settings,
# NuGet Symbol Packages
*.snupkg
**/[Pp]ackages/*
!**/[Pp]ackages/build/
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.appx
*.appxbundle
*.appxupload
!?*.[Cc]ache/
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
ServiceFabricBackup/
*.rptproj.bak
*.ndf
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# CodeRush personal settings
.cr/personal
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
1 change: 1 addition & 0 deletions NUnit3TestAdapter.sln
Expand Up @@ -5,6 +5,7 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7CE30108-5D81-4850-BE6B-C8BCA35D3592}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
appveyor.yml = appveyor.yml
build.cake = build.cake
build.cmd = build.cmd
Expand Down
2 changes: 1 addition & 1 deletion build.cake
Expand Up @@ -13,7 +13,7 @@ var configuration = Argument("configuration", "Release");
//////////////////////////////////////////////////////////////////////

var version = "3.17.0";
var modifier = "";
var modifier = "-1";

var dbgSuffix = configuration.ToLower() == "debug" ? "-dbg" : "";
var packageVersion = version + modifier + dbgSuffix;
Expand Down
1 change: 1 addition & 0 deletions src/NUnitTestAdapter/NUnit.TestAdapter.csproj
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<AssemblyName>NUnit3.TestAdapter</AssemblyName>
<!--<AssemblyName>NUnit3.TestAdapterDebug</AssemblyName>-->
<RootNamespace>NUnit.VisualStudio.TestAdapter</RootNamespace>
<!--<TargetFramework>net35</TargetFramework>--><!-- For testing and debugging-->
<TargetFrameworks>net35;netcoreapp2.1</TargetFrameworks>
Expand Down
30 changes: 0 additions & 30 deletions src/NUnitTestAdapter/NUnitEngine/NUnitResults.cs
Expand Up @@ -47,34 +47,4 @@ public XmlNodeList TestCases()
return TopNode.SelectNodes("//test-case");
}
}

public class NUnitTestCase
{
public XmlNode Node { get; }

public bool IsNull => Node == null;

public bool IsTestCase => !IsNull && Node.Name == "test-case";

public bool IsParameterizedMethod => Type == "ParameterizedMethod";

public string Id => Node.GetAttribute("id");

public string FullName => Node.GetAttribute("fullname");

public string Type => Node.GetAttribute("type");

public string Name => Node.GetAttribute("name");

public string ClassName => Node.GetAttribute("classname");

public string MethodName => Node.GetAttribute("methodname");

public NUnitTestCase(XmlNode testCase)
{
Node = testCase;
}

public NUnitTestCase Parent() => new NUnitTestCase(Node.ParentNode);
}
}
59 changes: 59 additions & 0 deletions src/NUnitTestAdapter/NUnitEngine/NUnitTestCase.cs
@@ -0,0 +1,59 @@
// ***********************************************************************
// Copyright (c) 2020-2020 Charlie Poole, Terje Sandstrom
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************

using System.Xml;
using NUnit.VisualStudio.TestAdapter.Dump;

namespace NUnit.VisualStudio.TestAdapter.NUnitEngine
{
public abstract class NUnitTestNode
{
public XmlNode Node { get; protected set; }
public string Id => Node.GetAttribute("id");
public string FullName => Node.GetAttribute("fullname");
public string Name => Node.GetAttribute("name");
public bool IsNull => Node == null;

protected NUnitTestNode(XmlNode node)
{
Node = node;
}
}



public class NUnitTestCase : NUnitTestNode
{
public bool IsTestCase => !IsNull && Node.Name == "test-case";
public bool IsParameterizedMethod => Type == "ParameterizedMethod";
public string Type => Node.GetAttribute("type");
public string ClassName => Node.GetAttribute("classname");
public string MethodName => Node.GetAttribute("methodname");

public NUnitTestCase(XmlNode testCase) : base(testCase)
{
}

public NUnitTestCase Parent() => new NUnitTestCase(Node.ParentNode);
}
}

0 comments on commit 8ec9370

Please sign in to comment.