I have a project in .NET 6 with a one-class simple console app, that I want to test. I wish to create a second class with xUnit test, but they do not run.
dotnet test prints only
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Additionally, path to test adapters can be specified using /TestAdapterPath command. Example /TestAdapterPath:<pathToCustomAdapters>.
Tests.cs
using Xunit;
namespace b;
public class Tests
{
[Fact]
public void One()
{
Assert.True(Parser.Check("{}{}{}"));
}
}
Program.cs
using b;
do
{
string line = Console.ReadLine();
Console.WriteLine(Parser.Check(line));
}while(true);
Parser.cs
namespace b;
public class Parser
{
static Stack<char> s = new Stack<char>();
public Parser()
{ }
static public bool Check(string stringToCheck)
{
int i = 0;
do
{
if(i < stringToCheck.Length - 1)
{
do
{
s.Push(stringToCheck[i++]);
} while (stringToCheck[i] != ')' && stringToCheck[i] != '}' && stringToCheck[i] != ']');
} else
s.Push(stringToCheck[i]);
if (stringToCheck[i] == ')')
{
if (s.Peek() == '(')
s.Pop();
else
return false;
} else if (stringToCheck[i] == '}')
{
if (s.Peek() == '{')
s.Pop();
else
return false;
} else if (stringToCheck[i] == ']')
{
if (s.Peek() == '[')
s.Pop();
else
return false;
}
i++;
} while (i < stringToCheck.Length);
return true;
}
}
Do I need to bulid entire solution and create two separate projects - one for current application, second for tests? Is there a simpler way?