Delayed NUnit Assert message evaluation

后端 未结 3 1011
广开言路
广开言路 2021-02-20 10:09

I have this assert in my test code

Assert.That(() => eventData.Count == 0,
Is.True.After(notificationPollingDelay),
\"Received unexpected event with last even         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-20 10:30

    You may use this scheme:

    var constrain = Is.True.After(notificationPollingDelay);
    var condition = constrain.Matches(() => eventData.Count == 0);
    Assert.IsTrue(condition, 
                  "Received unexpected event with last event data" + 
                  eventData.Last().Description());
    

    This method is similar to the use Thread.Sleep

提交回复
热议问题