コード例 #1
0
        public void Update(UpdateEnrollmentCommand command)
        {
            if (command?.Id == null)
            {
                throw new InvalidEnrollmentRequestException();
            }
            command.Request.Validate();
            var enrollment = _getEnrollmentDomainService.Get(command.Id);

            if (enrollment == null)
            {
                throw new EnrollmentNotFoundException();
            }
            _updateEnrollmentDomainService.Update(command.Id, command.Request);
        }
        public void UpdateEnrollment_ValidRequest_Ok()
        {
            var sut = GetSut(out Mock <IUpdateEnrollmentDomainService> updateEnrollmentDomainServiceMock,
                             out Mock <IGetEnrollmentDomainService> getEnrollmentDomainServiceMock);

            updateEnrollmentDomainServiceMock.Setup(x => x.Update(It.IsAny <int>(), It.IsAny <EnrollmentRequest>()));
            getEnrollmentDomainServiceMock.Setup(x => x.Get()).Returns(new List <EnrollmentRequest>
            {
                new EnrollmentRequest {
                    Id = 1
                }
            });

            var command = new UpdateEnrollmentCommand
            {
                Id      = 1,
                Request = SharedMethods.GetEnrollmentRequest()
            };

            Assert.DoesNotThrow(() => sut.Update(command));

            updateEnrollmentDomainServiceMock.Verify(x => x.Update(It.IsAny <int>(), It.IsAny <EnrollmentRequest>()));
            getEnrollmentDomainServiceMock.Verify(x => x.Get());
        }
コード例 #3
0
 public void Put([FromBody] UpdateEnrollmentCommand command)
 {
     _updateEnrollmentAppService.Update(command);
 }