我无法获取测试文件运行。我看不到我需要做不同的事情。这是C#的第一个练习项目。我想我已经解决了这个问题,但是我无法让测试文件在Microsoft Visual Studio中成功运行。目标是制定一个函数来测试年度是闰年。从练习C运行测试文件#
我想使用类年度在下面这个文件中,在我的项目是名为的Class1.cs
文件带班一年:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Exercism
{
public class Year
{ public bool IsLeap(int year)
{
if (year % 4 == 0)
if (year % 100 == 0)
if (year % 400 == 0)
return true;
else
return false;
else
return true;
else
return false;
}
}
}
测试文件如下。当我尝试运行它时,我在下面的每个测试函数中收到'The name'Year'在当前上下文中不存在'的消息。
using NUnit.Framework;
using Exercism;
[TestFixture]
public class LeapTest
{
[Test]
public void Valid_leap_year()
{
Assert.That(Year.IsLeap(1996), Is.True);
}
[Ignore]
[Test]
public void Invalid_leap_year()
{
Assert.That(Year.IsLeap(1997), Is.False);
}
[Ignore]
[Test]
public void Turn_of_the_20th_century_is_not_a_leap_year()
{
Assert.That(Year.IsLeap(1900), Is.False);
}
[Ignore]
[Test]
public void Turn_of_the_25th_century_is_a_leap_year()
{
Assert.That(Year.IsLeap(2400), Is.True);
}
}
我知道这是一个基本的问题,但任何帮助,将不胜感激