Example #1
0
        private void btnAddTemplate_Click(object sender, System.EventArgs e)
        {
            var     microwave = Wrap(() => _service.GetMicroWave());
            Int16   timeleft  = microwave.TimeLeft;
            Potency potency   = microwave.Potency;

            if (microwave.CurrentJob != null)
            {
                timeleft = microwave.CurrentJob.Template.TimeLeft;
                potency  = microwave.CurrentJob.Template.Potency;
            }

            var newJobTemplate = new JobTemplate(timeleft, potency)
            {
                CanDelete    = true,
                Default      = false,
                Instructions = txtOutput.Text,
                Name         = txtSearchTemplate.Text,
                MealKind     = GetSelectedMealKind(),
                Dot          = txtSearchTemplate.Text[0]
            };

            var ds = Wrap(() => _service.SaveTemplate(newJobTemplate));

            if (ds != null)
            {
                txtSearchTemplate.Text = String.Empty;
                lbxTemplate.DataSource = ds;
            }
        }
        public void TestAddCustomTemplate()
        {
            JobTemplate newTemplate = GetNewTemplate();

            _service.SaveTemplate(newTemplate);
            var actual = _service.GetTemplateByNameKind(newTemplate.Name, newTemplate.MealKind).First();

            Assert.AreEqual(newTemplate, actual);
        }