2017-05-17 6 views
0

ので(それはどんな違いがあれば、私はxUnitフレームを使用しています)私はTDDをしようとしていると私はテストファイルがあります:あなたが見ることができるように、クラスのカップルがここにあります日時はどこですか?

public class GatheringModuleTests 
{ 
    [Fact] 
    public void GathererGathersSourceCommunications() 
    { 
     GatheringClass thing = new GatheringClass(sourceStreamReader, targetStreamReader, ref sourceCommunications, ref targetCommunications); 

     thing.Process(TimeSpan.FromSeconds(10)); 

     Assert.True(sourceCommunications.Any()); 
    } 
} 

public class GatheringClass 
{ 
    private StreamReader sourceStreamReader; 
    private StreamReader targetStreamReader; 
    private List<Communication> sourceCommunications; 
    private List<Communication> targetCommunications; 

    public GatheringClass(StreamReader sourceStreamReader, StreamReader targetStreamReader, 
    ref List<Communication> sourceCommunications, ref List<Communication> targetCommunications) 
    { 
     this.sourceStreamReader = sourceStreamReader; 
     this.targetStreamReader = targetStreamReader; 
     this.sourceCommunications = sourceCommunications; 
     this.targetCommunications = targetCommunications; 
    } 

    public void Process(TimeSpan timeSpan) 
    { 
     var dt = new DateTime(); 
     var line = sourceStreamReader.ReadLine(); 

     var lineArray = line.Split('\0'); 
     var communication = new MatchCommunication(); 
     communication.PublishedDate = DateTime.Now; 
    } 
} 

を。私はまた、 "通信"オブジェクトで外部ライブラリを参照しています。 "Process"メソッドを見ると、コンパイラに問題がないダミーのDateTimeがあることがわかります。しかし、通信オブジェクトには、波線を生成しているDateTimeフィールド「PublishedDate」を持っている:

The type 'DateTime' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral... 

誰もが何が起こっているとどのようにそれを修正することです教えてもらえますか?

+0

このクラスはコンパイルされません。最後のコード行に ';'がありません。 – DigiFriend

+0

エラーメッセージに不満があるアセンブリへの参照を削除しましたか? – DigiFriend

+0

投稿したコードのどこにでも「オブジェクト」という言葉が表示されません。関連するコードでもう一度お試しいただけますか? – itsme86

答えて

0

私の推測では、クラスDateTimeの代替バージョンを定義したライブラリが含まれていると思います。あなたは

var dt = new DateTime() 

を言うとき

あなたはおそらく、新しいDateTimeクラスをインスタンス化しています。これをテストするには、デバッガで関連するコードにステップインする必要があります。あなたはおそらく、あなたはむしろ、提供日時より標準DateTime.Nowの関数を参照している

communication.PublishedDate = DateTime.Now; 

を言う

Howvever。

これは単なる推測ですが、その違いを説明します。

関連する問題