Exemplo n.º 1
0
        public async Task SaveCheckListSucess()
        {
            var appointment = new Appointment()
            {
                Id = 10,
                DateTimeCollected = new DateTime(2020, 2, 15)
            };
            var checkList = new CheckList()
            {
                Id = 5
            };
            await _repository.Add(appointment);

            Exception exception = null;

            try
            {
                await _service.Execute(checkList, 10, new DateTime(2020, 2, 19));
            }catch (Exception ex)
            {
                exception = ex;
            }

            Assert.AreEqual(exception, null);
        }
        public async Task NotRegisterAppointmentCarNotColleted()
        {
            var client = new Client()
            {
                Id = 12,
            };
            var car = new Car()
            {
                Id = 12,
            };
            var car2 = new Car()
            {
                Id = 15,
            };
            var op = new Operator()
            {
                Id = 12,
            };
            await _repositoryCar.Add(car);

            await _repositoryCar.Add(car2);

            await _repositoryClient.Add(client);

            await _repositoryOperator.Add(op);

            var appointment = new Appointment()
            {
                Id = 0,
                DateTimeExpectedCollected = DateTime.Now.AddDays(1),
                DateTimeExpectedDelivery  = DateTime.Now.AddDays(10),
                DateTimeCollected         = null,
                HourPrice    = 15,
                HourLocation = 15,
                Subtotal     = 15,
                Amount       = 15,
                IdCar        = 12,
                IdClient     = 12,
                IdOperator   = 12
            };
            Exception exception = null;
            await _repository.Add(appointment);

            appointment.IdCar = 15;
            try
            {
                await _service.Execute(new Appointment()
                {
                    Id = 0,
                    DateTimeExpectedCollected = DateTime.Now.AddDays(1),
                    DateTimeExpectedDelivery  = DateTime.Now.AddDays(10),
                    DateTimeCollected         = null,
                    HourPrice    = 15,
                    HourLocation = 15,
                    Subtotal     = 15,
                    Amount       = 15,
                    IdCar        = 15,
                    IdClient     = 12,
                    IdOperator   = 12
                });
            }catch (CarNotAvalabityException ex)
            {
                exception = ex;
            }

            Assert.AreNotEqual(exception, null);
        }