예제 #1
0
        public async Task Test7()
        {
            var client = new LinnworksClient(new HttpClient(), Token);

            var category = await client.CreateCategoryAsync("Test category");

            Assert.NotNull(category);

            category.Name = "Updated test";
            var updateException = await Record.ExceptionAsync(async() => await client.UpdateCategoryAsync(category));

            Assert.Null(updateException);

            var deleteResult = await Record.ExceptionAsync(async() => await client.DeleteCategoryAsync(category.Id));

            Assert.Null(deleteResult);

            var categories = await client.GetCategoriesAsync();

            Assert.NotEmpty(categories);

            var deleted = categories.SingleOrDefault(item => item.Name == category.Name);

            Assert.Null(deleted);
        }
        public async Task TestAddValidCategory(string categoryName)
        {
            var linnworksClient = new LinnworksClient(this.baseUrl, this.authSession);
            var category        = await linnworksClient.CreateCategory(categoryName);

            Assert.NotNull(linnworksApiMock.FindCategoryById(category.Id));
        }
 public void TestConstructor(string baseUrl, string authSession)
 {
     Assert.Throws <InvalidOperationException>(() =>
     {
         var linnworksClient = new LinnworksClient(baseUrl, authSession);
     });
 }
예제 #4
0
        public async Task Test5()
        {
            var client = new LinnworksClient(new HttpClient(), Token);
            var number = await client.GetNewItemNumber();

            Assert.NotEmpty(number);
        }
예제 #5
0
        public async Task Test3()
        {
            var client   = new LinnworksClient(new HttpClient(), Token);
            var category = await client.CreateCategoryAsync(Guid.NewGuid().ToString());

            Assert.NotNull(category);
        }
예제 #6
0
        public async Task Test2()
        {
            var client     = new LinnworksClient(new HttpClient(), Token);
            var categories = await client.GetCategoriesAsync();

            Assert.NotEmpty(categories);
        }
예제 #7
0
        public async Task Test8()
        {
            var client = new LinnworksClient(new HttpClient(), Guid.NewGuid().ToString());
            var script = @"SELECT 1";
            var ex     = await Record.ExceptionAsync(async() => await client.ExecuteCustomScriptAsync(script));

            Assert.IsAssignableFrom <ApiException>(ex);
        }
            internal Task <Category> Create(LinnworksClient LinnworksClient)
            {
                if (CategoryName == null)
                {
                    throw new NullReferenceException(CategoryName);
                }


                return(LinnworksClient.CreateCategory(CategoryName));
            }
예제 #9
0
        public async Task Test4()
        {
            var client = new LinnworksClient(new HttpClient(), Token);
            var script = @"SELECT p.CategoryId, Count(*) as StockItemCount
FROM StockItem AS S
INNER JOIN ProductCategories AS P ON P.CategoryId = S.CategoryId
GROUP BY P.CategoryId";
            var result = await client.ExecuteCustomScriptAsync <CategoryResponse>(script);

            Assert.NotNull(result);
        }
        public async Task TestGetAllCategories()
        {
            const string expectedFirstCategoryName = "Default";
            const int    expectedFirstProductCount = 10;

            const string expectedLastCategoryName = "New Category";
            const int    expectedLastProductCount = 0;

            var linnworksClient = new LinnworksClient(this.baseUrl, this.authSession);
            var result          = (await linnworksClient.GetCategories()).ToList();
            var defaultCategory = result.Find(r => r.Name == "Default");
            var newCategory     = result.Find(r => r.Name == "New Category");


            Assert.Equal(linnworksApiMock.Categories.Count, result.Count);
            Assert.Equal(expectedFirstCategoryName, defaultCategory.Name);
            Assert.Equal(expectedFirstProductCount, defaultCategory.ProductsCount);
            Assert.Equal(expectedLastCategoryName, newCategory.Name);
            Assert.Equal(expectedLastProductCount, newCategory.ProductsCount);
        }
 public CategoriesController(LinnworksClient linnworksClient)
 {
     LinnworksClient = linnworksClient;
 }