예제 #1
0
        public async Task DeleteCategory_Should_Throw_ArgumentException_If_CategoryId_Is_Empty()
        {
            Repository.IRepository        repository = new Mock <Repository.IRepository>().Object;
            Core.Infrastructure.IEventBus eventBus   = new Mock <Core.Infrastructure.IEventBus>().Object;

            Guid categoryId = Guid.Empty;

            var commands = new CategoryCommands(repository, eventBus);
            var ex       = await Assert.ThrowsAsync <ArgumentException>(() => commands.DeleteCategory(categoryId));

            Assert.Equal(nameof(categoryId), ex.ParamName);
        }
예제 #2
0
        public async Task DeleteCategory_Should_Mark_Category_As_Deleted()
        {
            var category = Category.Create("code", "name", "url");

            var repositoryMock = new Mock <Repository.IRepository>();

            repositoryMock.Setup(r => r.GetByKeyAsync <Category>(It.IsAny <Guid>()))
            .Returns(Task.FromResult(category));

            Repository.IRepository        repository = repositoryMock.Object;
            Core.Infrastructure.IEventBus eventBus   = new Mock <Core.Infrastructure.IEventBus>().Object;

            Guid categoryId = category.Id;

            var commands = new CategoryCommands(repository, eventBus);
            await commands.DeleteCategory(categoryId);

            Assert.True(category.Deleted);
        }