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 ValidateRequestCustom_When_newIds_Then_success_validation() { ProductCreateRequest request = ProductCreateRequestBuilder.Create() .WithProduct(ProductDtoBuilder.Create() .WithName("TEST") .WithCategoryId(1) .WithDescription("TEST DESCRIPTION") .WithOption(ProductOptionDtoBuilder.Create() .WithIndex(1) .WithName("TEST") .Build()) .WithVariant(ProductVariantDtoBuilder.Create() .WithPrice(10) .WithQuantity(10) .WithOptionValue(ProductVariantOptionValueDtoBuilder.Create() .WithIndex(1) .WithValue("TEST") .Build()) .Build()) .Build()) .Build(); SetupMocks(request); CommandMock.Object.ValidateRequestCustom(); ValidatorMock.Verify(s => s.ValidateNewIds(It.IsAny <IDbContext>(), It.IsAny <ProductCreateRequest>(), It.IsAny <ArgumentErrorsCollection>()), Times.Once); }
public void ValidateRequestCustom_When_correct_storeId_Then_success_validation() { var request = new ProductDeleteRequest { StoreId = 1, ProductId = 1 }; SetupMocks(request); CommandMock.Object.ValidateRequestCustom(); ValidatorMock.Verify( s => s.ValidateStoreId(It.IsAny <IDbContext>(), It.IsAny <ProductDeleteRequest>(), It.IsAny <ArgumentErrorsCollection>()), Times.Once); Assert.IsFalse(ErrorsMock.Object.HasArgument("StoreId")); }
public void ValidatorSinks() { ValidatorMock.Verify(m => m.Validate(It.IsAny <object>()), Times.Once); }