Esempio n. 1
0
        public double CalculateValueTotal(Accommodation accommodation)
        {
            Validator.Validate(accommodation);

            accommodation.CalculateValueTotal();

            return(accommodation.ValueTotal);
        }
Esempio n. 2
0
        public Accommodation Create(Accommodation accommodation)
        {
            accommodation.CalculateValueTotal();

            Validator.Validate(accommodation);

            //CalculateValueTotal(accommodation);

            var savedAccommodation = _accommodationRepository.Save(accommodation);

            return(savedAccommodation);
        }
        public void UpdateAccommodationRepositoryTest()
        {
            //Arrange
            IAccommodationRepository repository  = new AccommodationRepository();
            ICustomerRepository      _repository = new CustomerRepository();

            Customer customer = _repository.Get(2);

            customer.Name  = "Luiz Fernando Lemos Lima";
            customer.Phone = "0996879594";
            customer.Email = "*****@*****.**";
            customer.City  = "Lages";

            Accommodation accommodation = repository.Get(2);

            accommodation.DateChekIn        = DateTime.Now;
            accommodation.DateCheckOut      = DateTime.Now.AddDays(2);
            accommodation.AmountPeopleAdult = 2;
            accommodation.ValueAdult        = 130;
            accommodation.AmountPeopleChild = 0;
            accommodation.ValueChild        = 65;
            accommodation.AmountChalets     = 1;
            accommodation.Obs = "bla bla bla";
            accommodation.CalculateValueTotal();
            accommodation.Customer = customer;

            //Action
            var updatedAccommodation = repository.Update(accommodation);

            //Assert
            var persistedAccommodation = repository.Get(2);

            Assert.IsNotNull(updatedAccommodation);
            Assert.AreEqual(updatedAccommodation.Id, persistedAccommodation.Id);
            Assert.AreEqual(updatedAccommodation.DateChekIn, persistedAccommodation.DateChekIn);
            Assert.AreEqual(updatedAccommodation.DateCheckOut, persistedAccommodation.DateCheckOut);
            Assert.AreEqual(updatedAccommodation.AmountPeopleAdult, persistedAccommodation.AmountPeopleAdult);
            Assert.AreEqual(updatedAccommodation.ValueAdult, persistedAccommodation.ValueAdult);
            Assert.AreEqual(updatedAccommodation.AmountPeopleChild, persistedAccommodation.AmountPeopleChild);
            Assert.AreEqual(updatedAccommodation.ValueChild, persistedAccommodation.ValueChild);
            Assert.AreEqual(updatedAccommodation.AmountChalets, persistedAccommodation.AmountChalets);
            Assert.AreEqual(updatedAccommodation.Obs, persistedAccommodation.Obs);
            Assert.AreEqual(updatedAccommodation.ValueTotal, persistedAccommodation.ValueTotal);
            Assert.AreEqual(updatedAccommodation.Customer, persistedAccommodation.Customer);

            //Assert - utilizando o Framework FluentAssertions
            //Apenas um exemplo didático (NÃO CAI NA PROVA)
            // updatedBlog.Should().NotBeNull();
            //updatedBlog.ShouldBeEquivalentTo(persistedBlog);
        }
Esempio n. 4
0
        //[ExpectedException(typeof(Exception))]
        public void CalculateAccommodationValueTotalTest()
        {
            Accommodation accommodation = new Accommodation();

            accommodation.DateChekIn        = DateTime.Now;
            accommodation.DateCheckOut      = DateTime.Now.AddDays(2);
            accommodation.ValueAdult        = 130;
            accommodation.AmountPeopleAdult = 2;
            accommodation.ValueChild        = 65;
            accommodation.AmountPeopleChild = 2;

            accommodation.CalculateValueTotal();

            Assert.AreEqual(780, accommodation.ValueTotal);
        }
        public static Accommodation GetAccommodation()
        {
            Customer customer = new Customer();

            customer.Name  = "Luiz Fernando Lemos Lima";
            customer.Phone = "4999332297";
            customer.Email = "*****@*****.**";
            customer.City  = "Lages";

            Accommodation accommodation = new Accommodation();

            accommodation.DateChekIn        = DateTime.Now;
            accommodation.DateCheckOut      = DateTime.Now.AddDays(2);
            accommodation.AmountPeopleAdult = 2;
            accommodation.ValueAdult        = 130;
            accommodation.AmountPeopleChild = 0;
            accommodation.ValueChild        = 65;
            accommodation.AmountChalets     = 1;
            accommodation.Obs = "bla bla bla";
            accommodation.CalculateValueTotal();
            accommodation.Customer = customer;

            return(accommodation);
        }