Пример #1
0
        public async Task Return_Success_When_Category_Is_Updated()
        {
            //Arrange
            var logic = Create();
            //Act
            var result = await logic.Update(Category);

            //Assert
            result.Should()
            .BeSuccess(Category);
            CategoryValidator.Verify(v => v.ValidateAsync(Category, It.IsAny <CancellationToken>()), Times.Once);
            Repository.Verify(r => r.SaveChanges(), Times.Once);
        }
Пример #2
0
        public async Task Return_Errors_When_Validation_Fails()
        {
            //Arrange
            const string warning = "You cannot update Category";
            var          logic   = Create();
            await CategoryValidator.SetValidatorFailure(warning);

            //Act
            var result = await logic.Update(Category);

            //Assert
            result.Should()
            .BeFailure(warning);
            CategoryValidator.Verify(v => v.ValidateAsync(Category, It.IsAny <CancellationToken>()), Times.Once());
            Repository.Verify(r => r.SaveChanges(), Times.Never);
        }