Example #1
0
        public void Empty_Command_ShouldBe_Invalid()
        {
            var command = new RemoveCatalogProductCommand
            {
                CatalogId         = CatalogId.Empty,
                CatalogCategoryId = CatalogCategoryId.Empty,
                CatalogProductId  = CatalogProductId.Empty
            };
            var result = this._validator.TestValidate(command);

            result.ShouldHaveValidationErrorFor(x => x.CatalogId);
        }
Example #2
0
        public async Task Invalid_Command_ShouldThrow_ValidationException()
        {
            var command = new RemoveCatalogProductCommand
            {
                CatalogId         = CatalogId.Empty,
                CatalogCategoryId = CatalogCategoryId.Empty,
                CatalogProductId  = CatalogProductId.Empty
            };

            await Should.ThrowAsync <ValidationException>(async() =>
                                                          await this._requestHandler.Handle(command, this.CancellationToken));
        }
Example #3
0
        public async Task Remove_CatalogProduct_Successfully()
        {
            var command = new RemoveCatalogProductCommand
            {
                CatalogId         = this._catalog.Id,
                CatalogCategoryId = this._catalogCategory.Id,
                CatalogProductId  = this._catalogProduct.Id
            };

            await this._requestHandler.Handle(command, this.CancellationToken);

            this._mockDbContext.Verify(x => x.Update(this._catalog), Times.Once);
        }
Example #4
0
        public void CatalogProduct_NotFound_ShouldBe_Invalid()
        {
            var command = new RemoveCatalogProductCommand
            {
                CatalogId         = this._catalog.Id,
                CatalogCategoryId = this._catalogCategory.Id,
                CatalogProductId  = CatalogProductId.New
            };

            var result = this._validator.TestValidate(command);

            result.ShouldHaveValidationErrorFor(x => x.CatalogProductId);
            result.ShouldNotHaveValidationErrorFor(x => x.CatalogId);
            result.ShouldNotHaveValidationErrorFor(x => x.CatalogCategoryId);
        }
        public void CatalogCategory_NotFound_ShouldBe_Invalid()
        {
            var command = new RemoveCatalogProductCommand
            {
                CatalogId         = this._catalog.CatalogId,
                CatalogCategoryId = IdentityFactory.Create <CatalogCategoryId>(),
                CatalogProductId  = IdentityFactory.Create <CatalogProductId>()
            };

            var result = this._validator.TestValidate(command);

            result.ShouldHaveValidationErrorFor(x => x.CatalogCategoryId);
            result.ShouldNotHaveValidationErrorFor(x => x.CatalogId);
            result.ShouldNotHaveValidationErrorFor(x => x.CatalogProductId);
        }