public void TestMethod_WithReturnType_IncludesOutParameter_MockBehavior_Loose() { var stub = new StubIContainer(MockBehavior.Loose); IContainer container = stub; object outParam; Assert.AreEqual(false, container.GetElement(1, out outParam)); Assert.AreEqual(null, outParam); }
public void TestGenericMethod_WithReturnType_WithParameter() { int value = -1; var stub = new StubIContainer() .GetElement <int>(index => value) .SetElement <int>((i, v) => { value = v; }); IContainer container = stub; container.SetElement(0, 5); Assert.AreEqual(5, container.GetElement <int>(1)); }
public async Task TestGenericMethod_WithReturnType_WithParameter_Async() { int value = -1; var stub = new StubIContainer() .GetElementAsync <int>(async(index) => await Task.FromResult(value)) .SetElementAsync <int>(async(i, v) => { await Task.Run(() => value = v); }); IContainer container = stub; await container.SetElementAsync(0, 5); Assert.AreEqual(5, await container.GetElementAsync <int>(1)); }
public void TestMethod_WithReturnType_IncludesOutParameter() { object someObj = "test"; var stub = new StubIContainer() .GetElement((int index, out object value) => { value = someObj; return(true); }); IContainer container = stub; object result; container.GetElement(0, out result); Assert.AreEqual(someObj, result); }