public void TestAddMedicationAndSaveOrder()
        {
            var user = AdministratorController.AddOrUpdateUser(0, "user", "name", "password", UserType.Chemist);

            var medication =
                AdministratorController.AddOrUpdateMedication(0, "medication", "manufacturer", "a,b,c", 10, 10);

            Assert.True(medication.Id != 0);

            medication = AdministratorController.GetMedication(medication.Id);

            Dictionary <int, int> contents = new Dictionary <int, int>()
            {
                { medication.Id, 9 }
            };

            var invoice = RegularUserController.SaveOrder(user.Id, "client", contents);

            medication = RegularUserController.GetMedication(medication.Id);

            Assert.True(invoice.Id != 0);
            Assert.True(invoice.Issuer.Id == user.Id);
            Assert.True(medication.Stock == 1);
            Assert.True(invoice.Medications.Count == 1);
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            lastMedicationId = AdministratorController.AddOrUpdateMedication(
                (lastMedicationId == -1 ? 0 : lastMedicationId), textBox5.Text, textBox6.Text,
                textBox7.Text, (int)numericUpDown1.Value, (int)numericUpDown2.Value).Id;

            RefreshTab1List();
            RefreshTab1Fields();
        }
        public void TestDeleteMedication()
        {
            var medication =
                AdministratorController.AddOrUpdateMedication(0, "medication", "manufacturer", "a,b,c", 10, 10);

            AdministratorController.DeleteMedication(medication.Id);

            Assert.Throws <InvalidOperationException>(() => AdministratorController.GetMedication(medication.Id));
        }