예제 #1
0
        public void FilterTest()
        {
            DataContext dataContext = new DataContext {
                SProducts = new List <SProduct>()
            };
            SProductRepository productRepository = new SProductRepository(dataContext);

            productRepository.Add(new SProduct
            {
                Id         = 1,
                MinimalAge = 19,
                Author     = "21Studios",
                Name       = "Game 1",
                Price      = 20.4f
            });


            productRepository.Add(new SProduct
            {
                Id         = 1,
                MinimalAge = 17,
                Author     = "12Studios",
                Name       = "Game 2",
                Price      = 20.4f
            });

            List <SProduct> products = productRepository.Get(c => c.MinimalAge == 19).ToList();

            Assert.AreEqual(1, products.Count());
        }
예제 #2
0
        public void UpdateTest()
        {
            DataContext dataContext = new DataContext {
                SProducts = new List <SProduct>()
            };
            SProductRepository productRepository = new SProductRepository(dataContext);

            productRepository.Add(new SProduct
            {
                Id         = 1,
                MinimalAge = 19,
                Author     = "21Studios",
                Name       = "Game 1",
                Price      = 20.4f
            });
            string newAuthor = "TSA";

            SProduct product2 = new SProduct
            {
                Id         = 1,
                MinimalAge = 19,
                Author     = newAuthor,
                Name       = "Game 1",
                Price      = 20.4f
            };

            productRepository.Update(1, product2);

            Assert.AreEqual(newAuthor, productRepository.Get(1).Author);
        }
예제 #3
0
        public void AddTest()
        {
            DataContext dataContext = new DataContext {
                SProducts = new List <SProduct>()
            };
            SProductRepository productRepository = new SProductRepository(dataContext);

            productRepository.Add(new SProduct
            {
                Id         = 1,
                MinimalAge = 19,
                Author     = "21Studios",
                Name       = "Game 1",
                Price      = 20.4f
            });

            Assert.IsNotNull(productRepository.Get(1));
        }