public async Task TestA2Async() { IThing thing = GetInstance(true); string result = await thing.GetNumberAsTextAsync(Data.Number); Assert.AreEqual(Data.NumberAsText, result); }
protected static IThing GetInstance(bool mock) { IThing GetMockedInstance() { IThing thing = Substitute.For <IThing>(); thing.GetNumberAsTextAsync(Data.Number).Returns(Task.FromResult(Data.NumberAsText)); return(thing); } return(mock ? GetMockedInstance() : new Thing()); }
public static async Task TestB2Async(IThing thing) { string result = await thing.GetNumberAsTextAsync(Data.Number); Assert.AreEqual(Data.NumberAsText, result); }