Пример #1
0
        public void PermiteAdicionarUmSegundoAgendamentoDeDescarregamentoParaMesmaPlacaSeOPrimeiroEstiverRealizado()
        {
            Quota quota = DefaultObjects.ObtemQuotaDeDescarregamento();
            AgendamentoDeDescarregamento agendamentoDeDescarregamento = quota.InformarAgendamento(new AgendamentoDeDescarregamentoSalvarVm()
            {
                IdQuota       = quota.Id,
                IdAgendamento = 0,
                Placa         = "IMN2420",
                NotasFiscais  = new List <NotaFiscalVm>
                {
                    DefaultObjects.ObtemNotaFiscalVmComPesoEspecifico(50),
                    DefaultObjects.ObtemNotaFiscalVmComPesoEspecifico(51)
                }
            });

            agendamentoDeDescarregamento.Realizar();

            quota.InformarAgendamento(new AgendamentoDeDescarregamentoSalvarVm()
            {
                IdQuota       = quota.Id,
                IdAgendamento = 0,
                Placa         = "IMN2420",
                NotasFiscais  = new List <NotaFiscalVm>
                {
                    DefaultObjects.ObtemNotaFiscalVmComPesoEspecifico(52),
                    DefaultObjects.ObtemNotaFiscalVmComPesoEspecifico(53)
                }
            });

            Assert.AreEqual(2, quota.Agendamentos.Count);
            Assert.AreEqual(2, quota.Agendamentos.Count(x => x.Placa == "IMN2420"));
        }
        public AgendamentoDeCarga Construir(Quota quota, string placa)
        {
            if (_notasFiscais.Count == 0)
            {
                throw new AgendamentoDeDescarregamentoSemNotaFiscalException();
            }
            var agendamento = new AgendamentoDeDescarregamento(quota, placa);

            foreach (var notaFiscalVm in _notasFiscais)
            {
                agendamento.AdicionarNotaFiscal(notaFiscalVm);
            }

            return(agendamento);
        }