public void ValidateRequestCustom_When_wrong_categoryId_Then_fail_validation_And_add_ArgumentError() { var request = ProductFindRequestBuilder.Create() .WithStoreId(1) .WithCriteria(ProductCriteriaDtoBuilder.Create() .WithCategoryId(10) .WithSortField1(SortFieldDtoBuilder.Create() .WithField("Name") .Build()) .Build()) .Build(); SetupMocks(request); CommandMock.Object.ValidateRequestCustom(); ValidatorMock.Verify( s => s.ValidateCategoryId(It.IsAny <IDbContext>(), It.IsAny <ProductFindRequest>(), It.IsAny <ArgumentErrorsCollection>()), Times.Once); DbContextMock.VerifyGet(c => c.ProductCategories, Times.Once); Assert.IsTrue(ErrorsMock.Object.HasArgument("Criteria.CategoryId")); }
public void ValidateRequestCustom_When_correct_storeId_Then_success_validation() { var request = ProductFindRequestBuilder.Create() .WithStoreId(1) .WithCriteria(ProductCriteriaDtoBuilder.Create() .WithCategoryId(1) .WithSortField1(SortFieldDtoBuilder.Create() .WithField("Name") .Build()) .Build()) .Build(); SetupMocks(request); CommandMock.Object.ValidateRequestCustom(); ValidatorMock.Verify( s => s.ValidateStoreId(It.IsAny <IDbContext>(), It.IsAny <ProductFindRequest>(), It.IsAny <ArgumentErrorsCollection>()), Times.Once); DbContextMock.VerifyGet(c => c.Stores, Times.Once); Assert.IsFalse(ErrorsMock.Object.HasArgument("StoreId")); }
public void Execute_When_correct_request_Then_gets_products_And_returns_success_response() { var request = ProductFindRequestBuilder.Create() .WithStoreId(1) .WithCriteria(ProductCriteriaDtoBuilder.Create() .WithCategoryId(1) .WithPageIndex(1) .WithPageSize(10) .WithSortField1(SortFieldDtoBuilder.Create() .WithField("Name") .Build()) .Build()) .Build(); SetupMocks(request); CommandMock.Object.Execute(request); DbContextMock.VerifyGet(c => c.Products, Times.Once); Assert.IsTrue(ResponseMock.Object.IsSuccess); }