0
不一致のアクセシビリティエラーについて以前の記事を見たことがありますが、私の場合ほど具体的ではありませんでした。ここでC#:単体テストクラス内の一貫性のないアクセシビリティエラー
は私の2つのエラーです:
'ConsoleApplication1.Reader' is inaccessible due to its protection level
Inconsistent accessibility: field type 'ConsoleApplication1.Reader' is less
accessible than field 'UnitTestProject1.ReaderTest.reader'
リーダークラスはpublicですので、私は、なぜテストクラスがそれを見ていないことを確認していません。私はこの同じ問題を抱えていない複数の他のテストを持っており、すべて同じように設定されています。 2番目のエラーについては、結果として解決される最初のエラーを修正すると信じています。以下では、Readerクラスとテストクラスを添付します。アドバイスをいただければ幸いです。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
/// <summary>
/// Created and tested by Alexander James Bochel.
/// Last Updated: 6/7/2017
/// </summary>
class Program
{
/// <summary>
/// This will call the rest of the classes in the program.
/// </summary>
/// <param name="args"> Command line arguments. </param>
static void Main(string[] args)
{
openFile();
}
public static void openFile()
{
Reader reader = new Reader(@"C:\Users\abochel\Desktop\TEST.xlsx", 0);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
public class Reader
{
public Reader()
{
// TODO - Default constructor.
}
}
}
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections;
using System.Collections.Generic;
using ConsoleApplication1;
namespace AutomationProgramTests
{
[TestClass]
public class ReaderTest
{
Reader reader;
[TestMethod]
public void testCreateSales()
{
reader = new Reader(); // TODO add path and sheet.
}
}
}
[mcve]を投稿してVisual Studioにコピーして同じエラーを表示することはできますか?あなたが見たことから、すべてがうまく見えますが、 'Reader'が入っている名前空間のような欠けている部分があります。 –
@BJMyersコード全体を追加しました!ありがとう –
これはまだMCVEではありません。コードをコピーしてIDEにコピーしてコンパイルすることはできません。クラスメソッド、外部ライブラリへの参照(Excel interopなど)など、問題を再現する必要のないものはすべて削除してください。 –