Esempio n. 1
0
 private void SetupCategoryTreeService()
 {
     CategoryTreeService = new CategoryTreeService(new CategoryNameServiceSettings()
     {
         CategoriesFilePath = "./queries_functional_test_categories.xml",
         SchemaFilePath     = "./_Categories-xml-data/categories.xsd"
     });
     CategoryTreeService.Init();
 }
Esempio n. 2
0
        public void Init_when_invalid_categories_checks_xsd_and_throws(string testFileName)
        {
            var service = new CategoryTreeService(new CategoryNameServiceSettings()
            {
                CategoriesFilePath = testFileName,
                SchemaFilePath     = "_Categories-xml-data/categories.xsd"
            });

            Assert.Throws <XmlSchemaValidationException>(() => service.Init());
        }
Esempio n. 3
0
        public async Task ApiCreateAuction_when_session_started_creates_auction()
        {
            var fixture = new Fixture();

            var categoryTreeService = new CategoryTreeService(new CategoryNameServiceSettings()
            {
                CategoriesFilePath = "_Categories-xml-data/categories.xml",
                SchemaFilePath     = "_Categories-xml-data/categories.xsd"
            });

            categoryTreeService.Init();
            List <string> categories = new List <string>()
            {
                categoryTreeService.GetCategoriesTree().SubCategories[0].CategoryName,
                          categoryTreeService.GetCategoriesTree().SubCategories[0].SubCategories[1].CategoryName,
                          categoryTreeService.GetCategoriesTree().SubCategories[0].SubCategories[1].SubCategories[2].CategoryName,
            };


            CreateAuctionCommandDto createAuctionCmd = fixture.Build <CreateAuctionCommandDto>()
                                                       .With(dto => dto.Category, categories)
                                                       .With(dto => dto.StartDate, DateTime.UtcNow)
                                                       .With(dto => dto.EndDate, DateTime.UtcNow.AddMonths(1))
                                                       .With(dto => dto.Tags, new[] { "tag1", "tag2" })
                                                       .Create();

            var startSessionReq = new HttpRequestMessage(HttpMethod.Post, "/api/startCreateSession")
                                  .AddUserAuthHeader(_factory);
            var startSessionResponse = await client.SendAsync(startSessionReq);

            startSessionResponse.StatusCode.Should().Be(HttpStatusCode.OK);

            var req = new HttpRequestMessage(HttpMethod.Post, "/api/createAuction")
                      .AddUserAuthHeader(_factory)
                      .AddJsonBody(createAuctionCmd);
            var response = await client.SendAsync(req);


            response.StatusCode.Should().Be(HttpStatusCode.OK);

            var requestStatus = await response.GetRequestStatus();

            requestStatus.CorrelationId.Should().NotBeEmpty();
            requestStatus.Status.Should().Be("COMPLETED");
        }
Esempio n. 4
0
        public void GetCategoryTree_when_called_returns_valid_category_tree()
        {
            var serviceSettings = new CategoryNameServiceSettings()
            {
                CategoriesFilePath = "./test_categories.xml",
                SchemaFilePath     = "_Categories-xml-data/categories.xsd"
            };
            var testService = new CategoryTreeService(serviceSettings);

            testService.Init();

            var categories         = new[] { "Fashion", "Electronics", "Sports, Hobbies & Leisure" };
            var subCategoriesCount = new[] { 11, 8, 8 };
            var categoryIds        = new[] { 0, 1, 2 };
            var root = testService.GetCategoriesTree();

            for (int i = 0; i < root.SubCategories.Count; i++)
            {
                var category = root.SubCategories[i];

                category.CategoryId.Should().Be(categoryIds[i]);
                category.CategoryName.Should().Be(categories[i]);
                category.SubCategories.Count.Should().Be(subCategoriesCount[i]);
                for (int j = 0; j < category.SubCategories.Count; j++)
                {
                    var subCategory = category.SubCategories[j];
                    subCategory.CategoryName.Should().NotBeNullOrEmpty();
                    subCategory.SubCategories.Count.Should().Be(2);
                    for (int k = 0; k < subCategory.SubCategories.Count; k++)
                    {
                        var subSubCat = subCategory.SubCategories[k];
                        subSubCat.CategoryName.Should().NotBeNullOrEmpty();
                    }
                }
            }

            root.SubCategories.Count.Should().Be(3);
            root.CategoryName.Should().BeNull();
        }