How to write unit tests with TPL and TaskScheduler

后端 未结 5 1551
离开以前
离开以前 2021-02-01 06:50

Imagine a function like this:

private static ConcurrentList list = new ConcurrentList();
public void Add(object x)
{
   Task.Factory.         


        
      
      
      
5条回答
  •  北海茫月
    2021-02-01 07:28

    What about making a public property for the list?

    public ConcurrentList List { get; set; }
    
    
    

    or maybe make it a public field when in DEBUG build:

    #if DEBUG
    public static ConcurrentList list = new ConcurrentList();
    #else
    private static ConcurrentList list = new ConcurrentList();
    #endif
    
        

    提交回复
    热议问题