我試圖使該字段公開;我也嘗試過使用public get,即使按照我的理解,在屬性內部訪問修飾符只會在更嚴格的情況下才會起作用。但是我無法訪問TestUnit的'問題。點'(最後一行)屬性。我收到「獲取訪問者無法訪問」警報。請注意,我可以從同一名稱空間中的另一個類訪問它。我必須在這裏錯過一些非常基本的東西。C#公共屬性獲取訪問器無法從另一個命名空間訪問
namespace Coordinates_Path
{
public interface IProblem
{
abstract public List<Node> Points { get; set; }
abstract public Object GetStartState();
abstract public bool IsGoalState();
abstract public Object GetSuccessor();
}
public class ShortestPathThroughCoordinates : IProblem
{
private Node startState;
private List<Node> points;
public List<Node> Points { get { return points; } private set; }
//...
//...
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Coordinates_Path;
using System.Linq;
using System.Collections.Generic;
namespace CoordPathTest
{
[TestClass]
public class KruskalTest
{
[TestMethod]
public void TestMST()
{
// ...
IProblem problem = new ShortestPathThroughCoordinates("P1", coordDic);
MSTKruskal kruskal = new MSTKruskal(problem.Points)
錯誤信息究竟是什麼? 「Node」類型是公開的,還是至少對測試程序集可見? –
你是。而已。我全力檢查它,但不知怎的,沒有注意到** Node **並未公開。謝謝 –
把它變成了答案,然後:-) –