public async Task UpdateEpicAsync_DescriptionTooLong_ThrowsValidationException(string name, string description)
        {
            //arrange
            Guid    publicProjectId = Guid.NewGuid();
            Project expectedProject = new Project()
            {
                ProjectId       = 1,
                PublicProjectId = publicProjectId,
                Name            = "name",
                Description     = null,
                DateTimeCreated = DateTime.UtcNow.AddMinutes(-60)
            };
            var projectRepositoryMock = new Mock <IProjectRepository>(MockBehavior.Strict);

            projectRepositoryMock.Setup(x => x.GetProjectAsync(publicProjectId))
            .ReturnsAsync(expectedProject);

            Guid publicEpicId = Guid.NewGuid();
            Epic expectedEpic = new Epic()
            {
                EpicId          = 1,
                PublicEpicId    = publicEpicId,
                ProjectId       = 1,
                Project         = expectedProject,
                Name            = name,
                Description     = description,
                DateTimeCreated = DateTime.UtcNow.AddMinutes(-60)
            };
            var epicRepositoryMock = new Mock <IEpicRepository>(MockBehavior.Strict);

            epicRepositoryMock.Setup(x => x.GetEpicAsync(publicEpicId))
            .ReturnsAsync(expectedEpic);
            epicRepositoryMock.Setup(x => x.UpdateEpicAsync(publicEpicId,
                                                            expectedEpic.Name,
                                                            expectedEpic.Description))
            .ReturnsAsync(expectedEpic);

            var epicManager = new EpicManager(projectRepositoryMock.Object, epicRepositoryMock.Object);

            //act/assert
            ValidationException exception = await Assert.ThrowsAsync <ValidationException>(async() =>
            {
                _ = await epicManager.UpdateEpicAsync(publicProjectId, publicEpicId, name, description);
            });

            //assert
            Assert.True(exception.ValidationErrors.Count == 1);
            Assert.True(exception.ValidationErrors.Single().Property == "description");
            Assert.True(exception.ValidationErrors.Single().ErrorMessage == "Must be shorter than 512 characters.");
        }
        public async Task UpdateEpicAsync_ValidInput_ReturnsEpic(string name, string description)
        {
            //arrange
            Guid    publicProjectId = Guid.NewGuid();
            Project expectedProject = new Project()
            {
                ProjectId       = 1,
                PublicProjectId = publicProjectId,
                Name            = "name",
                Description     = null,
                DateTimeCreated = DateTime.UtcNow.AddMinutes(-60)
            };
            var projectRepositoryMock = new Mock <IProjectRepository>(MockBehavior.Strict);

            projectRepositoryMock.Setup(x => x.GetProjectAsync(publicProjectId))
            .ReturnsAsync(expectedProject);

            Guid publicEpicId = Guid.NewGuid();
            Epic expectedEpic = new Epic()
            {
                EpicId          = 1,
                PublicEpicId    = publicEpicId,
                ProjectId       = 1,
                Project         = expectedProject,
                Name            = name,
                Description     = description,
                DateTimeCreated = DateTime.UtcNow.AddMinutes(-60)
            };
            var epicRepositoryMock = new Mock <IEpicRepository>(MockBehavior.Strict);

            epicRepositoryMock.Setup(x => x.GetEpicAsync(publicEpicId))
            .ReturnsAsync(expectedEpic);
            epicRepositoryMock.Setup(x => x.UpdateEpicAsync(publicEpicId,
                                                            expectedEpic.Name,
                                                            expectedEpic.Description))
            .ReturnsAsync(expectedEpic);

            var epicManager = new EpicManager(projectRepositoryMock.Object, epicRepositoryMock.Object);

            //act
            Epic createdEpic = await epicManager.UpdateEpicAsync(publicProjectId,
                                                                 publicEpicId,
                                                                 name,
                                                                 description);

            //assert
            Assert.Equal(expectedEpic, createdEpic);
        }
        public async Task UpdateEpicAsync_FiciticiousProjectId_ThrowsNotFoundException()
        {
            //arrange
            Guid    publicProjectId       = Guid.NewGuid();
            Project expectedProject       = null;
            var     projectRepositoryMock = new Mock <IProjectRepository>(MockBehavior.Strict);

            projectRepositoryMock.Setup(x => x.GetProjectAsync(publicProjectId))
            .ReturnsAsync(expectedProject);

            Guid publicEpicId = Guid.NewGuid();
            Epic expectedEpic = new Epic()
            {
                EpicId          = 1,
                PublicEpicId    = publicEpicId,
                ProjectId       = 1,
                Project         = expectedProject,
                Name            = "name",
                Description     = null,
                DateTimeCreated = DateTime.UtcNow.AddMinutes(-60)
            };
            var epicRepositoryMock = new Mock <IEpicRepository>(MockBehavior.Strict);

            epicRepositoryMock.Setup(x => x.GetEpicAsync(publicEpicId))
            .ReturnsAsync(expectedEpic);
            epicRepositoryMock.Setup(x => x.UpdateEpicAsync(publicEpicId,
                                                            expectedEpic.Name,
                                                            expectedEpic.Description))
            .ReturnsAsync(expectedEpic);

            var epicManager = new EpicManager(projectRepositoryMock.Object, epicRepositoryMock.Object);

            //act/assert
            _ = await Assert.ThrowsAsync <NotFoundException>(async() =>
            {
                _ = await epicManager.UpdateEpicAsync(publicProjectId,
                                                      publicEpicId,
                                                      expectedEpic.Name,
                                                      expectedEpic.Description);
            });
        }