public void QuandoCriarUmAgendamentoSemNotaDeveGerarExcecao()
        {
            Quota quota   = DefaultObjects.ObtemQuotaDeDescarregamento();
            var   factory = new AgendamentoDeDescarregamentoFactory();

            factory.Construir(quota, "IOQ5338");
        }
Пример #2
0
        public static AgendamentoDeDescarregamento ObtemAgendamentoDeDescarregamento(Quota quota)
        {
            var factory = new AgendamentoDeDescarregamentoFactory();

            factory.AdicionarNotaFiscal(ObtemNotaFiscalVmPadrao());
            return((AgendamentoDeDescarregamento)factory.Construir(quota, "IOQ5338"));
        }
        public void QuandoCrioUmAgendamentoAsPropriedadesFicamCorretas()
        {
            Quota quota   = DefaultObjects.ObtemQuotaDeDescarregamento();
            var   factory = new AgendamentoDeDescarregamentoFactory();

            factory.AdicionarNotaFiscal(DefaultObjects.ObtemNotaFiscalVmPadrao());
            var agendamento = (AgendamentoDeDescarregamento)factory.Construir(quota, "IOQ5338");

            Assert.AreEqual(DateTime.Today.AddDays(1), agendamento.Quota.Data);
            Assert.AreEqual("1000", agendamento.Quota.CodigoTerminal);
            Assert.AreEqual("IOQ5338", agendamento.Placa);
            Assert.AreEqual(1, agendamento.NotasFiscais.Count);
        }
        public void PesoTotalDoDescarregamentoEaSomaDosPesosDasNotas()
        {
            Quota        quota   = DefaultObjects.ObtemQuotaDeDescarregamento();
            var          factory = new AgendamentoDeDescarregamentoFactory();
            NotaFiscalVm nota1   = DefaultObjects.ObtemNotaFiscalVmPadrao();

            nota1.Peso = 120;
            NotaFiscalVm nota2 = DefaultObjects.ObtemNotaFiscalVmPadrao();

            nota2.Peso = 140;

            factory.AdicionarNotaFiscal(nota1);
            factory.AdicionarNotaFiscal(nota2);
            var agendamento = (AgendamentoDeDescarregamento)factory.Construir(quota, "IOQ5338");

            Assert.AreEqual(260, agendamento.PesoTotal);
        }
Пример #5
0
        public virtual AgendamentoDeDescarregamento InformarAgendamento(AgendamentoDeDescarregamentoSalvarVm agendamentoDeDescarregamentoSalvarVm)
        {
            AgendamentoDeDescarregamento agendamento;

            if (agendamentoDeDescarregamentoSalvarVm.IdAgendamento == 0)
            {
                var factory = new AgendamentoDeDescarregamentoFactory();
                foreach (var notaFiscal in agendamentoDeDescarregamentoSalvarVm.NotasFiscais)
                {
                    factory.AdicionarNotaFiscal(notaFiscal);
                }
                agendamento = (AgendamentoDeDescarregamento)factory.Construir(this, agendamentoDeDescarregamentoSalvarVm.Placa);
                Agendamentos.Add(agendamento);
            }
            else
            {
                agendamento = (AgendamentoDeDescarregamento)Agendamentos.Single(x => x.Id == agendamentoDeDescarregamentoSalvarVm.IdAgendamento);

                agendamento.Atualizar(agendamentoDeDescarregamentoSalvarVm);
            }
            VerificaSeExisteApenasUmAgendamentoParaCadaPlaca();
            CalculaPesoAgendado();
            return(agendamento);
        }