public async Task GetLodgmentByNameAsync_LodgmentExists_ShouldReturnTheLodgment()
        {
            // Arrange
            expectedLodgment.Name      = lodgmentName;
            expectedLodgment.IsActive  = true;
            expectedLodgment.IsDeleted = false;
            context.Add(expectedLodgment);
            context.SaveChanges();

            //Act
            var actualLodgment = await repository.GetLodgmentByNameAsync(lodgmentName);

            //Assert
            Assert.AreEqual(expectedLodgment, actualLodgment);
        }
Exemplo n.º 2
0
        public async Task <Lodgment> AddLodgmentAsync(Lodgment lodgmentModel, Spot spotModel)
        {
            if (lodgmentModel == null)
            {
                throw new ArgumentException("Debe proveer un alojamiento.");
            }

            if (spotModel == null)
            {
                throw new ArgumentException("Debe proveer una punto turístico.");
            }

            if (lodgmentModel.SpotId != spotModel.Id)
            {
                throw new ArgumentException(
                          "El punto turístico para el alojamiento es distinto del punto turístico actual.");
            }

            var lodgment = await repository.GetLodgmentByNameAsync(lodgmentModel.Name);

            if (lodgment != null)
            {
                throw new DuplicateNameException("El hospedaje ya existe.");
            }

            lodgment = await repository.AddLodgmentAsync(lodgmentModel);

            return(lodgment);
        }