public void DoesNotThrowException() { bool methodCalled = false; Assert.DoesNotThrow(() => methodCalled = true); Assert.True(methodCalled); }
public void CorrectExceptionType() { DoesNotThrowException ex = Assert.Throws <DoesNotThrowException>( () => Assert.DoesNotThrow( () => { throw new NotImplementedException("Exception Message"); })); Assert.Equal("Assert.DoesNotThrow() failure", ex.UserMessage); Assert.Equal("(No exception)", ex.Expected); Assert.Equal("System.NotImplementedException: Exception Message", ex.Actual); }
void CanSerializeAndDeserializeObjectsInATest() { BinaryFormatter bf = new BinaryFormatter(); using (Stream ms = new MemoryStream()) { bf.Serialize(ms, new SerializableObject()); ms.Position = 0; object o = bf.Deserialize(ms); Assert.IsType(typeof(SerializableObject), o); Assert.DoesNotThrow(delegate { SerializableObject o2 = (SerializableObject)o; }); } }
public void PassingTest() { Assert.DoesNotThrow(() => { }); }
protected override void When() { Assert.DoesNotThrow(() => SUT.ShouldContain(s => s.EndsWith("2"))); }