public void Handle_NotFoundCategory_ShouldThrowArgException()
        {
            // Arrange
            var handler = new CreateIssueCommandHandler(GetCategoryRepository().Object, GetMapper());

            var request = new CreateIssueCommand
            {
                CategoryId = 2,
                IssueName  = "Clean up room"
            };

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

            // Assert
            Assert.ThrowsAsync <System.ArgumentException>(del);
        }
Beispiel #2
0
        public async Task Handle_ValidCommand_ShouldSaveEntriesSuccessfully(Domain.Entities.Issue Issue)
        {
            _fixture.RepeatCount = 0;
            // Arrange
            _mapperMock.Setup(m => m.Map <Domain.Entities.Issue>(It.IsAny <CreateIssueCommand>()))
            .Returns(Issue);                                                       // AutoMapper setup

            var sut = new CreateIssueCommandHandler(_context, _mapperMock.Object); // creating system under test

            var project = await ContextOperation.CreateEntity(_context, _fixture.Create <Project>());

            // Act
            await sut.Handle(new CreateIssueCommand { ProjectId = project.Id }, CancellationToken.None);

            // Assert
            _context.Issues.Count().ShouldBe(1);
        }
        public async Task Handle_NewIssue_ShouldSaveNewIssue()
        {
            // Arrange
            var categoryRepositoryMock = GetCategoryRepository();

            var handler = new CreateIssueCommandHandler(categoryRepositoryMock.Object, GetMapper());

            var request = new CreateIssueCommand
            {
                CategoryId = 1,
                IssueName  = "Clean out room"
            };

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

            // Assert
            categoryRepositoryMock.Verify(x => x.SaveCategory(It.IsAny <Category>()), Times.Once);
        }
Beispiel #4
0
        public async void CreateIssue_ShouldBe_Persisted()
        {
            var result = await _handler.Handle(_request, CancellationToken.None);

            result.ShouldNotBeNull();
        }