Exemple #1
0
        public void NaoDeveValidarCapsulaSemPreencherPropriedades()
        {
            CapsulaBUS sut       = FactoryBUS.CreateCapsulaBUS();
            Capsula    sutObjeto = new Capsula();

            Assert.False(sut.ValidarCampos(sutObjeto));
        }
Exemple #2
0
        private void DataGridView2_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataRow toDelete       = null;
            Capsula toDeleteGlobal = new Capsula();
            int     rowIndex       = e.RowIndex;

            if (rowIndex < 0)
            {
                MessageBox.Show("Escolha uma capsula");
                return;
            }
            DataGridViewRow row = dataGridView2.Rows[rowIndex];

            foreach (DataRow r in _table.Rows)
            {
                if (r.Field <int>("Capsula") == (int)row.Cells["Capsula"].Value)
                {
                    toDelete = r;
                    foreach (Capsula capsula in _criarReceita.Capsulas)
                    {
                        if (capsula.Id == r.Field <int>("Capsula"))
                        {
                            toDeleteGlobal = capsula;
                        }
                    }
                }
            }
            if (toDelete != null)
            {
                _table.Rows.Remove(toDelete);
                _criarReceita.Capsulas.Remove(toDeleteGlobal);
            }
        }
Exemple #3
0
        public void NaoDeveValidarCapsulaSemForca()
        {
            CapsulaBUS sut       = FactoryBUS.CreateCapsulaBUS();
            Capsula    sutObjeto = new Capsula();

            sutObjeto.Descricao = "Café";

            Assert.False(sut.ValidarCampos(sutObjeto));
        }
Exemple #4
0
        public void DeveValidarCapsulaComDescricaoEForca()
        {
            CapsulaBUS sut       = FactoryBUS.CreateCapsulaBUS();
            Capsula    sutObjeto = new Capsula();

            sutObjeto.Descricao = "Café";
            sutObjeto.Forca     = 8;

            Assert.True(sut.ValidarCampos(sutObjeto));
        }
Exemple #5
0
        public async Task <JsonResult> PegarLast()
        {
            HttpResponseMessage resposta = await httpClient.GetAsync("capsules/past");

            var conteudo = await resposta.Content.ReadAsStringAsync();

            IEnumerable <Capsula> ObjetoCapsulas = JsonConvert.DeserializeObject <IEnumerable <Capsula> >(conteudo);

            Capsula UltimaCapsula  = ObjetoCapsulas.OrderBy(x => x.DataLancamento).FirstOrDefault();
            var     FormatCapsulas = JsonConvert.SerializeObject(UltimaCapsula, Formatting.Indented);

            return(Json(FormatCapsulas));
        }
Exemple #6
0
        private void AbrirFormEditor(Capsula capsula = null)
        {
            FormEditorCapsulas formEditor;

            if (capsula == null)
            {
                formEditor = new FormEditorCapsulas();
            }
            else
            {
                formEditor = new FormEditorCapsulas(capsula);
            }

            formEditor.ShowDialog();
        }
Exemple #7
0
        public void CapsulaForca_IncluirCapsula_RetornarOK()
        {
            //arrange
            Capsula capsula = new Capsula();

            capsula.Forca     = 5;
            capsula.Descricao = "Nescafé Expresso";
            string resultadoEsperado = "ok";

            //Act
            string resultadoAtual = capsula.IncluirCapsula(capsula);

            //Assert

            Assert.AreEqual(resultadoEsperado, resultadoAtual);
        }
Exemple #8
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            int capsulaID = PegarIDCapsula();

            if (capsulaID > 0)
            {
                Capsula capsula = capsulaBUS.SelecionarPorID(capsulaID);

                AbrirFormEditor(capsula);

                AtualizarView();
            }
            else
            {
                MessageBox.Show("Nenhuma cápsula selecionada", "Erro");
                return;
            }
        }
Exemple #9
0
        private void DataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int rowIndex = e.RowIndex;

            if (rowIndex < 0)
            {
                MessageBox.Show("Escolha uma capsula");
                return;
            }
            DataGridViewRow row = dataGridView1.Rows[rowIndex];

            Capsula newCapsula = new Capsula();

            newCapsula.Id          = Convert.ToInt32(row.Cells["cod_capsula"].Value.ToString());
            newCapsula.Descricao   = row.Cells["descricao"].Value.ToString();
            newCapsula.Intensidade = Convert.ToInt32(row.Cells["intensidade"].Value.ToString());
            newCapsula.Estoque     = Convert.ToInt32(row.Cells["estoque"].Value.ToString());

            _criarReceita.Capsulas.Add(newCapsula);

            AtualizaGridViewCapsulasReceitas();
        }