0
所以我是一个新的C#的Java开发人员,我似乎无法得到这个微不足道的工作。我有一个测试类在另一个类中测试方法。为了方便起见,我使这些静态的,以便不依赖任何实例化。不过由于某些原因,我的Tests类似乎无法找到我的Kata类。C#调用一个静态方法
namespace Codewars
{
public class Program
{
static void Main(string[] args)
{
}
public static string HoopCount(int n)
{
if (n >= 10)
{
return "Great, now move on to tricks";
}
else
{
return "Keep at it until you get it";
}
}
}
}
测试:
using NUnit.Framework;
namespace Codewars
{
[TestFixture]
class Tests
{
[Test]
public static void FixedTest()
{
Assert.AreEqual("Keep at it until you get it", Kata.HoopCount(6), "Should work for 6");
Assert.AreEqual("Great, now move on to tricks", Kata.HoopCount(22), "Should work for 22");
}
}
}
要调用Kata.HoopCount,但你的类被命名为计划,而不是卡塔。你将不得不使用Program.HoopCount。您的FixedTest方法也没有任何理由是静态的。 –
哦,那真是愚蠢!我确实使用了内置的重命名工具,它不应该自动重命名所有引用吗? – snutte
它应该,除非你做得对。也许你没有确认重命名,只是重命名了这个类并在编辑器中单击了(只是猜测) –