示例#1
0
            public void DoesNotThrowException()
            {
                bool methodCalled = false;

                Assert.DoesNotThrow(() => methodCalled = true);

                Assert.True(methodCalled);
            }
示例#2
0
        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);
        }
示例#3
0
        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; });
            }
        }
示例#4
0
 public void PassingTest()
 {
     Assert.DoesNotThrow(() => { });
 }
 protected override void When()
 {
     Assert.DoesNotThrow(() => SUT.ShouldContain(s => s.EndsWith("2")));
 }