Пример #1
0
        public void CreateDelegateMockTest()
        {
            var mock = new Mock<Func<int, string>>();

            mock.ExpectCall(m => m(2)).Returns("2").Once();

            var value = mock.Object(2);

            mock.Verify();

            Assert.That(value, Is.EqualTo("2"));
        }
Пример #2
0
        public void CreateInterfaceMockTest()
        {
            var mock = new Mock<IMocked>();

            mock.ExpectCall(m => m.Method(2)).Returns("2").Once();
            mock.ExpectGet(m => m.Property).Gets(2).Never();
            mock.ExpectSet(m => m.Property).Sets(2).Never();

            var value = mock.Object.Method(2);

            mock.Verify();

            Assert.That(value, Is.EqualTo("2"));
        }