Esempio n. 1
0
            public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                SectionAppointment sectionAppointment = await _arpaContext.SectionAppointments
                                                        .FirstOrDefaultAsync(sa => sa.SectionId == request.SectionId && sa.AppointmentId == request.Id, cancellationToken);

                _arpaContext.SectionAppointments.Remove(sectionAppointment);

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

                throw new Exception("Problem removing section appointment");
            }
Esempio n. 2
0
        public async Task Should_Remove_Section()
        {
            // Arrange
            DbSet <SectionAppointment> mockData           = MockDbSets.SectionAppointments;
            SectionAppointment         sectionAppointment = AppointmentSeedData.AfterShowParty.SectionAppointments.First();

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

            // Act
            Unit result = await _handler.Handle(new RemoveSection.Command(
                                                    sectionAppointment.AppointmentId,
                                                    sectionAppointment.SectionId), new CancellationToken());

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