public async Task AddLodgmentAsync_Norestrictions_ShouldReturnTheLodgment()
        {
            // Arrange

            //Act
            var actualLodgment = await repository.AddLodgmentAsync(expectedLodgment);

            //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);
        }