Ejemplo n.º 1
0
            public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                ProjectAppointment projectAppointment = await _arpaContext.ProjectAppointments
                                                        .FirstOrDefaultAsync(pa => pa.ProjectId == request.ProjectId && pa.AppointmentId == request.Id, cancellationToken);

                _arpaContext.ProjectAppointments.Remove(projectAppointment);

                if (await _arpaContext.SaveChangesAsync(cancellationToken) > 0)
                {
                    _arpaContext.ClearChangeTracker();
                    return(Unit.Value);
                }

                throw new Exception("Problem removing project appointment");
            }
Ejemplo n.º 2
0
        public async Task Should_Remove_Project()
        {
            // Arrange
            DbSet <ProjectAppointment> mockData           = MockDbSets.ProjectAppointments;
            ProjectAppointment         projectAppointment = AppointmentSeedData.RockingXMasRehearsal.ProjectAppointments.First();

            _arpaContext.ProjectAppointments.Returns(mockData);
            _arpaContext.SaveChangesAsync(Arg.Any <CancellationToken>()).Returns(1);

            // Act
            Unit result = await _handler.Handle(new RemoveProject.Command(
                                                    projectAppointment.AppointmentId,
                                                    projectAppointment.ProjectId), new CancellationToken());

            // Assert
            result.Should().BeEquivalentTo(Unit.Value);
        }