コード例 #1
0
        public void TestThatMethodStubCanBeOverwritten()
        {
            var stub = new StubIPhoneBook().GetContactPhoneNumber((p1, p2) => 12345678);

            stub.GetContactPhoneNumber((p1, p2) => 11122233, overwrite: true);

            IPhoneBook phoneBook = stub;

            Assert.AreEqual(11122233, phoneBook.GetContactPhoneNumber("John", "Smith"));
        }
コード例 #2
0
        public void TestMethod_WithReturnType_WithParameters()
        {
            long   number    = 6041234567;
            string firstName = null;
            string lastName  = null;
            var    stub      = new StubIPhoneBook();

            stub.GetContactPhoneNumber((fn, ln) =>
            {
                firstName = fn;
                lastName  = ln;
                return(number);
            });
            IPhoneBook phoneBook    = stub;
            long       actualNumber = phoneBook.GetContactPhoneNumber("John", "Smith");

            Assert.AreEqual(number, actualNumber);
            Assert.AreEqual("John", firstName);
            Assert.AreEqual("Smith", lastName);
        }