Exemplo n.º 1
0
        public void Final_und_Future_Mocking() {
            var sut = new CustomerController();

            var mockRepository = Mock.Create<CustomerRepository>();
            Mock.Arrange(() => mockRepository.GetById("42")).IgnoreInstance().Returns(new Customer { Id = "x" });

            sut.ShowDetails("42");
        }
Exemplo n.º 2
0
        public void Static_Mocking() {
            var sut = new CustomerController();

            string argument = "";
            Mock.Arrange(() => MessageBox.Show(Arg.IsAny<string>())).DoInstead<string>(s => argument = s);

            sut.ShowDetails("10");

            Assert.That(argument, Is.EqualTo("Customer Id: 10"));
        }