Exemplo n.º 1
0
        public void Should_add_new_product()
        {
            // Arrange
            Product inputProduct = new Product
            {
                Id    = "6004",
                Name  = "Monitor Samsung 2",
                Price = 200
            };
            // Act
            var result = productHandle.AddProductAsync(inputProduct).Result;

            // Assert
            Assert.IsTrue(result);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            /*try
             * {
             *  Program p = new Program();
             *  p.AsycnGetProducts().Wait();
             * }
             * catch (DocumentClientException de)
             * {
             *  Exception baseException = de.GetBaseException();
             *  Console.WriteLine("{0} error occurred: {1}, Message: {2}", de.StatusCode, de.Message, baseException.Message);
             * }
             * catch (Exception e)
             * {
             *  Exception baseException = e.GetBaseException();
             *  Console.WriteLine("Error: {0}, Message: {1}", e.Message, baseException.Message);
             * }
             * finally
             * {
             *  Console.WriteLine("End of demo, press any key to exit.");
             *  Console.ReadKey();
             * }*/

            //ListDBs();
            client = DocumentDBClientConfig.GetClientInstance;
            ProductHandle productHandle = new ProductHandle();

            /*Console.WriteLine("Show list of products!!!");
             * Console.WriteLine("==============================================================\n\n");
             * foreach (var item in productHandle.GetProducts())
             * {
             *  Console.WriteLine($"product {item.name}  price:{item.price}");
             * }
             *
             *
             * Console.WriteLine("[Async Fashion] Show list of products!!!");
             * Console.WriteLine("==============================================================\n\n");
             * var data = productHandle.GetProductsAsync();
             * foreach (var item in data.Result)
             * {
             *  Console.WriteLine($"product {item.name}  price:{item.price}");
             * }
             */
            /* var productName = "iPad";
             * Console.WriteLine($"[Async Fashion] Get products that match with {productName}!!!");
             * Console.WriteLine("==============================================================\n\n");
             * var data = productHandle.GetProductsByNameAsync(productName);
             * foreach (var item in data.Result)
             * {
             *   Console.WriteLine($"product {item.name}  price:{item.price}");
             * }
             * Console.WriteLine("List products is done!!!!");*/

            Console.WriteLine($"[Async Fashion] Add Product !!!");
            Console.WriteLine("==============================================================\n\n");
            Product p = new Product
            {
                Id    = "1013",
                Name  = "iPhone x",
                Price = 300
            };

            productHandle.AddProductAsync(p);

            /*
             * Task t = Task.Run(() =>
             * {
             *  var data = productHandle.GetProductsByNameAsync(productName);
             *  foreach (var item in data.Result)
             *  {
             *      Console.WriteLine($"product {item.name}  price:{item.price}");
             *  }
             * });
             *
             * t.Wait();*/


            // Accessing documents

            /*var dbName = "InventoryDB";
             * var collectionId = "products";
             * ListProducts(client,dbName, collectionId);
             *
             * GetProductByName(client, dbName, collectionId, "iPad");
             * GetProductWhichLowerThan(client, dbName, collectionId, 500);*/

            Console.ReadKey();
        }