Beispiel #1
0
        public void Handle_NotFoundCategory_ShouldThrowArgException()
        {
            // Arrange
            var handler = new DeleteIssueCommandHandler(GetCategoryRepository().Object);

            var request = new DeleteIssueCommand
            {
                CategoryId = 2
            };

            // Act
            var del = new AsyncTestDelegate(() => handler.Handle(request, CancellationToken.None));

            // Assert
            Assert.ThrowsAsync <System.ArgumentException>(del);
        }
Beispiel #2
0
        public async Task Handle_ValidId_EntityShoulDeletedSuccessfully()
        {
            _fixture.RepeatCount = 0;

            //Create entity to inserted and delete it
            var temIssue = _fixture.Create <Domain.Entities.Issue>();

            // Arrange
            var Issue = await ContextOperation.CreateEntity(_context, temIssue);

            var sut = new DeleteIssueCommandHandler(_context);

            // Act
            await sut.Handle(new DeleteIssueCommand { Id = Issue.Id }, CancellationToken.None);

            // Assert
            _context.Issues.Count().ShouldBe(0);
        }
Beispiel #3
0
        public async Task Handle_DeletingIssue_ShouldSaveNewIssue()
        {
            // Arrange
            var categoryRepositoryMock = GetCategoryRepository();

            var handler = new DeleteIssueCommandHandler(categoryRepositoryMock.Object);

            var request = new DeleteIssueCommand
            {
                CategoryId = 1,
                IssueName  = "Clean up room"
            };

            // Act
            await handler.Handle(request, CancellationToken.None);

            // Assert
            categoryRepositoryMock.Verify(x => x.SaveCategory(It.IsAny <Category>()), Times.Once);
        }