我觉得这对我来说可能真的是一个愚蠢的疏忽,但是我看不到为什么会出现我的构造函数没有2个参数的错误。看起来对我来说确实如此,我想我使用了正确的类和名称空间名称,在反复阅读并在此处搜索类似答案之后,我无法弄清楚。谁能识别我在做什么错?
型号:
using System;
using System.Collections.Generic;
namespace WordCounter.Models
{
public class WordBundle
{
private string _wordInput;
private string _sentenceInput;
public WordBundle (string wordInput, string sentenceInput)
{
_wordInput = wordInput;
_sentenceInput = sentenceInput;
}
}
}
测试:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WordCounter.Models;
using System;
using System.Collections.Generic;
namespace WordCounter.Tests
{
[TestClass]
public class WordBundleTest
{
[TestMethod]
public void WordBundleConstructor_CreatesInstanceOfWordBundle_WordBundle()
{
string testWord = "cat";
string testSentence = "Who let the cat out of the cathedral?";
WordBundle newWordBundle = new WordBundle(testWord, testSentence);
Assert.AreEqual(typeof(WordBundle), newWordBundle.GetType());
}
}
}
答案 0 :(得分:0)
好吧,在更多地关注项目之后,看起来我与另一个文件中的类名发生冲突,这正在劫持我的构造函数调用。感谢您的关注,João!