I'm trying to make a simple test so I can practice. I don't know what I'm doing wrong, but I get
The name 'Program' does not exist in the current context [/dir/unitTestTest/unitTestTest.csproj]
And I don't know why. Here is my code.
I have a Program.cs
using System;
namespace unitTestDotNet
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
int yy = Add(2,1);
Console.WriteLine(yy);
Console.WriteLine(IsOdd(5));
}
public static int Add(int x, int y)
{
return x + y;
}
public static bool IsOdd(int value)
{
return value % 2 == 1;
}
}
}
testclass.cs
using Xunit;
public class testclass
{
[Fact]
public void PassingAddTest()
{
Assert.Equal(4, Program.Add(2,2));
}
}
And in the unitTestProject.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1"/>
<PackageReference Include="xunit" Version="2.4.1"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1"/>
</ItemGroup>
</Project>
I'm new to ASP.net core and I don't know what I'm doing wrong