예제 #1
0
        public void simple_check_call_count_sub()
        {
            var dataSource = Substitute.For<IDataSource<Customer>>();

            dataSource.Get(Arg.Any<int>()).ReturnsForAnyArgs(x => new Customer { Id = x.Arg<int>(), Name = "skippy" });

            var repo = new CustomerRepository(dataSource);

            var result = repo.Get(99);

            result.ShouldNotBeNull();
            result.Id.ShouldEqual(99);

            dataSource.Received(1).Get(Arg.Any<int>());
        }
예제 #2
0
        public void simple_subs()
        {
            var dataSource = Substitute.For<IDataSource<Customer>>();

            dataSource.Get(1).Returns(new Customer
            {
                Id = 1,
                Name = "Skippy"
            });

            var repo = new CustomerRepository(dataSource);

            var result = repo.Get(1);

            result.ShouldNotBeNull();
        }