我已经构建了一个名为“MemoryDB”的类(其c'tor需要6个参数)并为她创建了单元测试。 直到今天一切都还可以 - 我尝试删除其中一个参数,所以它们保持为5.即使(在重新构建,保存,重新创建类MemoryDB等之后),单元测试也无法识别变化和出现错误消息: TimeTable.DB.MemoryDB does not contain a constructor that takes 5 arguments. 我也尝试重新创建单元测试,但由于某种原因,它创建的自动c'tor是旧的c'tor,有6个参数。
我是否以错误的方式删除了参数? 我怎样才能解决这个问题? 项目中的其他错误可能会导致这个奇怪的问题吗?
ps这里是旧的c'tor:
public MemoryDB(List<Grade> allGrades, List<Teacher> allTeachers, ForbiddenHours forbiddenHours, List<Group> allGroups, List<List<Teacher>> staffs, List<List<Group>> parallelGroups) { CheckParametersValidation(allGrades, allTeachers, forbiddenHours, allGroups, staffs, parallelGroups); this.allGrades = allGrades; this.allTeachers = allTeachers; this.forbiddenHours = forbiddenHours; this.allGroups = allGroups; this.staffs = staffs; this.parallelGroups = parallelGroups; }新的c'tor,删除“forbiddenHours”后:
public MemoryDB(List<Grade> allGrades, List<Teacher> allTeachers, List<Group> allGroups, List<List<Teacher>> staffs, List<List<Group>> parallelGroups) { CheckParametersValidation(allGrades, allTeachers, allGroups, staffs, parallelGroups); this.allGrades = allGrades; this.allTeachers = allTeachers; this.allGroups = allGroups; this.staffs = staffs; this.parallelGroups = parallelGroups; }I have built a class called "MemoryDB" (whose c'tor takes 6 arguments) and created unit-test for her. Everything was OK until today - I tried deleting one of the arguments, so they remain 5. Even though (after re-building, saving, re-creating the class MemoryDB, etc.), the unit-test does not recognize the change and the error message appears: TimeTable.DB.MemoryDB does not contain a constructor that takes 5 arguments. I also tried to re-create the unit-test, but for some reason the automatic c'tor it creates is the old c'tor, with 6 arguments.
Have I deleted the argument in a wrong way? How can I fix this? Do other errors in the project might cause this weird problem?
p.s. here is the old c'tor:
public MemoryDB(List<Grade> allGrades, List<Teacher> allTeachers, ForbiddenHours forbiddenHours, List<Group> allGroups, List<List<Teacher>> staffs, List<List<Group>> parallelGroups) { CheckParametersValidation(allGrades, allTeachers, forbiddenHours, allGroups, staffs, parallelGroups); this.allGrades = allGrades; this.allTeachers = allTeachers; this.forbiddenHours = forbiddenHours; this.allGroups = allGroups; this.staffs = staffs; this.parallelGroups = parallelGroups; }the new c'tor, after deleting "forbiddenHours":
public MemoryDB(List<Grade> allGrades, List<Teacher> allTeachers, List<Group> allGroups, List<List<Teacher>> staffs, List<List<Group>> parallelGroups) { CheckParametersValidation(allGrades, allTeachers, allGroups, staffs, parallelGroups); this.allGrades = allGrades; this.allTeachers = allTeachers; this.allGroups = allGroups; this.staffs = staffs; this.parallelGroups = parallelGroups; }最满意答案
很难说出为什么会发生这种情况,但在解决此类问题时需要注意以下事项:
如果库被引用为DLL,则可能是DLL尚未更新。 如果是这种情况,请重建库 - 如果有任何错误,则表示尚未构建。 修复错误。 重建后,删除现有的引用并重新添加(不是严格需要,您可以简单地替换文件系统上的DLL) 如果库被引用为项目: 确保库正在构建且没有错误。 可能会出现一些缓存问题。 重新启动Visual Studio。It is difficult to tell why this happens, but there are certain things to look for when troubleshooting such an issue:
If the library was referenced as a DLL, it is possible that the DLL has not been updated. If that's the case, rebuild the library - if there are any errors, it has not built. Fix the errors. Once rebuilt, remove the existing reference and re-add it (not strictly needed, you can simply replace the DLL on the file system) If the library was referenced as a project: Make sure the library is building without errors. It is possible that some caching issues are going on. Restart Visual Studio.更多推荐
发布评论