Exemplo n.º 1
0
        static void Main(string[] args)
        {
            UserLogic userLogic = new UserLogic();

            if (userLogic.GetUser("abdul76").Count() > 0)
            {
                WebClient webClient = new WebClient();
                String    context   = webClient.DownloadString("http://localhost:8080/MyTobaccoShop.Java/username?username="******"abdul76");
                Console.WriteLine(context);
            }
            CustomerLogic customerLogic = new CustomerLogic();
            // userLogic.UpdateUserType(2, "Admin");
            var s = userLogic.GetAdminUsers();

            foreach (var item in s)
            {
                Console.WriteLine(item.Name + "Type : " + item.User_type);
            }

            //Console.WriteLine(userLogic.GetUser(1));
            //Console.WriteLine(userLogic.GetUser(2));
            Console.WriteLine(customerLogic.SumOfCustomers());

            ProductLogic productLogic = new ProductLogic();
            var          avgPrice     = productLogic.GetAveragePrices();

            foreach (var item in avgPrice)
            {
                Console.WriteLine(item);
            }
        }
Exemplo n.º 2
0
        public void TestGetAveragePrices()
        {
            Mock <IProductRepository> mock     = new Mock <IProductRepository>();
            List <ProductTable>       products = new List <ProductTable>()
            {
                new ProductTable()
                {
                    CATEGORY_ID = 1, P_PRICE = 400
                },
                new ProductTable()
                {
                    CATEGORY_ID = 2, P_PRICE = 500
                },
                new ProductTable()
                {
                    CATEGORY_ID = 3, P_PRICE = 1000
                },
            };

            List <GetAveragePrice> getAveragePrices = new List <GetAveragePrice>()
            {
                new GetAveragePrice()
                {
                    CategorytID = 1, AvgPrice = 400,
                },
                new GetAveragePrice()
                {
                    CategorytID = 2, AvgPrice = 500,
                },
                new GetAveragePrice()
                {
                    CategorytID = 3, AvgPrice = 1000,
                },
            };

            mock.Setup(repo => repo.GetAll()).Returns(products.AsQueryable());
            ProductLogic productLogic = new ProductLogic(mock.Object);
            var          actual       = productLogic.GetAveragePrices();

            Assert.That(actual, Is.EquivalentTo(getAveragePrices));
            mock.Verify(repo => repo.GetAll(), Times.Exactly(1));
        }