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);
        }
Exemple #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            lastUserId = AdministratorController.AddOrUpdateUser((lastUserId == -1 ? 0 : lastUserId), textBox10.Text,
                                                                 textBox11.Text, textBox12.Text, UserType.Chemist).Id;

            RefreshTab2List();
            RefreshTab2Fields();
        }
        public void TestDeleteUser()
        {
            var user = AdministratorController.AddOrUpdateUser(0, "user", "name", "password", UserType.Administrator);

            AdministratorController.DeleteUser(user.Id);

            Assert.Throws <InvalidOperationException>(() => AdministratorController.GetUser(user.Id));
        }
        public void TestAddUserAndLogin()
        {
            var user = AdministratorController.AddOrUpdateUser(0, "user", "name", "password", UserType.Chemist);

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

            Assert.True(LoginController.TryLogin("user", "password"));
            Assert.False(LoginController.TryLogin("user", "pwd"));
            Assert.False(LoginController.TryLogin("something", "something"));

            Assert.DoesNotThrow(() => LoginController.GetUserLevelAndId("user"));
            Assert.Throws <InvalidOperationException>(() => LoginController.GetUserLevelAndId("something"));
        }