Ejemplo n.º 1
0
        public void test_repository_usage()
        {
            var repositoryTest             = new RepositoryTestClass();
            IEnumerable <Product> Products = repositoryTest.GetProducts();

            Assert.IsTrue(Products != null);
        }
Ejemplo n.º 2
0
        public void test_repository_mocking()
        {
            var products = new List <Product>
            {
                new Product {
                    ProductId = 1, Name = "Mustang"
                },
                new Product {
                    ProductId = 2, Name = "Corvette"
                }
            };

            Product[] array = products.ToArray();
            var       mockedProductRepository = Substitute.For <IProductRepository>();

            mockedProductRepository.GetAll().Returns(products.ToArray());


            var repositoryTest = new RepositoryTestClass(mockedProductRepository);

            Product[] retProducts = repositoryTest.GetProducts();
            Assert.IsTrue(retProducts == array);
        }