Ejemplo n.º 1
0
        public async Task Invalid_Search_Request_Should_Throw_ValidationException(int pageIndex, int pageSize)
        {
            var request = new GetCatalogCollectionRequest
            {
                PageSize  = pageSize,
                PageIndex = pageIndex
            };

            await Should.ThrowAsync <ValidationException>(async() =>
                                                          await this._testFixture.ExecuteTestRequestHandler <GetCatalogCollectionRequest, GetCatalogCollectionResult>(request, result => { }));
        }
Ejemplo n.º 2
0
        public async Task Should_Validate_Search_Request_Correctly(int pageIndex, int pageSize)
        {
            var request = new GetCatalogCollectionRequest
            {
                PageSize  = pageSize,
                PageIndex = pageIndex
            };

            await this._testFixture.ExecuteValidationTest(request, result =>
            {
                if (pageIndex < 0 || pageIndex == int.MaxValue)
                {
                    result.ShouldHaveValidationErrorFor(x => x.PageIndex);
                }

                if (pageSize < 0 || pageSize == int.MaxValue)
                {
                    result.ShouldHaveValidationErrorFor(x => x.PageSize);
                }
            });
        }
Ejemplo n.º 3
0
        public async Task Should_GetCatalogCollection_With_SearchTerm_Correctly()
        {
            var randomIndex          = GenFu.GenFu.Random.Next(0, this._testFixture.Catalogs.Count);
            var catalogAtRandomIndex = this._testFixture.Catalogs[randomIndex];
            var searchTerm           = catalogAtRandomIndex.DisplayName;

            var request = new GetCatalogCollectionRequest
            {
                SearchTerm = searchTerm
            };

            await this._testFixture.ExecuteTestRequestHandler <GetCatalogCollectionRequest, GetCatalogCollectionResult>(request, (result) =>
            {
                result.ShouldNotBeNull();
                result.TotalCatalogs.ShouldBe(1);
                var catalog =
                    result.CatalogItems.SingleOrDefault(x => x.CatalogId == catalogAtRandomIndex.Id.Id);
                catalog.ShouldNotBeNull();
                catalog.DisplayName.ShouldBe(catalogAtRandomIndex.DisplayName);
                catalog.TotalCategories.ShouldBe(catalogAtRandomIndex.Categories.Count());
            });
        }
Ejemplo n.º 4
0
        public async Task Should_GetCatalogCollection_WithPaging_Correctly(int pageIndex, int pageSize)
        {
            var catalogs = this._testFixture.Catalogs.ToList();
            var request  = new GetCatalogCollectionRequest
            {
                PageIndex = pageIndex,
                PageSize  = pageSize
            };

            await this._testFixture.ExecuteTestRequestHandler <GetCatalogCollectionRequest, GetCatalogCollectionResult>(request, (result) =>
            {
                result.ShouldNotBeNull();
                result.TotalCatalogs.ShouldBe(catalogs.Count);
                foreach (var catalogItem in result.CatalogItems)
                {
                    var catalogId = catalogItem.CatalogId;
                    var catalog   = catalogs.SingleOrDefault(x => x.Id == catalogId);
                    catalog.ShouldNotBeNull(() => $"Assert{catalogId} in {string.Join(",", catalogs.Select(x => x.Id.Id.ToString()).ToArray())}");
                    catalogItem.DisplayName.ShouldBe(catalog.DisplayName);
                    catalogItem.TotalCategories.ShouldBe(catalog.Categories.Count());
                }
            });
        }