public async Task GetLodgmentByIdAsync_LodgmentExists_ShouldReturnTheLodgment()
        {
            // Arrange
            expectedLodgment.Id          = lodgmentId;
            expectedLodgment.IsActive    = true;
            expectedLodgment.IsDeleted   = false;
            expectedLodgment.Spot        = fixture.Create <Spot>();
            expectedLodgment.Spot.Region = fixture.Create <Region>();
            context.Add(expectedLodgment);
            context.SaveChanges();

            //Act
            var actualLodgment = await repository.GetLodgmentByIdAsync(lodgmentId);

            //Assert
            Assert.AreEqual(expectedLodgment, actualLodgment);
        }
Exemplo n.º 2
0
        public async Task <Lodgment> DeleteLodgmentAsync(int id)
        {
            var lodgment = await repository.GetLodgmentByIdAsync(id);

            if (lodgment == null)
            {
                throw new KeyNotFoundException("El hospedaje no existe.");
            }

            lodgment = await repository.DeleteLodgmentAsync(id);

            return(lodgment);
        }