public void GetDonatorTest() { Donator donator1 = donatorService.GetDonator("Dmihai"); Assert.AreNotEqual(donator1, null); try { Donator donator2 = donatorService.GetDonator("DmihaiGresit"); } catch (Exception exc) { Assert.AreNotEqual(exc, null); } }
public void testAddAnalize() { // NU RULATI , nu este delete DonatorService srvDon = new DonatorService(); Donator donator = srvDon.GetDonator("Dmihai"); CentruService service = new CentruService(); PungaSange punga = service.GetPunga(1); service.AddAnaliza(BIII, Pozitiv, false, false, true, false, false, -774, punga, donator); Assert.AreEqual(srvDon.GetAllAnalizeByIdDonator("Dmihai").Where(x => x.NivelALT == -774), 1); //serivice.DeleteAnaliza(analiza) }
public void testAddPungaSange() { DonatorService srvDon = new DonatorService(); srvDon.RegisterDonator("test", "test", "testNume", "testPrenume", "M", Convert.ToDateTime("04-02-1997"), "testDomiciliu", "testLocalitate", "testJudet", "", "", "", "1935647856", "*****@*****.**"); Donator donator = srvDon.GetDonator("test"); CentruService service = new CentruService(); CentruTransfuzie centru = new CentruTransfuzie("test", "test", "test", "test"); PungaSange punga = new PungaSange(); punga.CantitateSange = 0.5F; punga.CantitatePlasma = 0.275F; punga.CantitateGlobuleRosii = -1; punga.CantitateTrombocite = 150; service.AddPungaSange(punga, donator, centru.Nume); Assert.AreNotEqual(service.GetAllPungiSange().Where(x => x.CantitateGlobuleRosii == -1), null); }
private void btnUpdate_Click(object sender, EventArgs e) { Donator donator = service.GetDonator(Username); UserDonator user = service.GetUserDonator(Username); string message = string.Empty; if (textBoxUserName.Text != null && textBoxUserName.Text != "") { if (textBoxUserName.Text != user.Username) { try { service.GetUserDonator(textBoxUserName.Text); message += ",username"; } catch (Exception ex) { user.Username = textBoxUserName.Text; } } } else { message += ",username"; } if (textBoxSetariNume.Text != null && textBoxSetariNume.Text != "") { donator.Nume = textBoxSetariNume.Text; } else { message += ",nume"; } if (textBoxSetariPrenume.Text != null && textBoxSetariPrenume.Text != "") { donator.Prenume = textBoxSetariPrenume.Text; } else { message += ",prenume"; } if (textAdresa.Text != null && textAdresa.Text != "") { donator.Domiciliu = textAdresa.Text; } else { message += ",adresa"; } if (cmbLoc.Text != null && cmbLoc.Text != "") { donator.Localitate = cmbLoc.Text; } else { message += ",localitate"; } if (cmbJud.Text != null && cmbJud.Text != "") { donator.Judet = cmbJud.Text; } else { message += ",judet"; } if (textEmail.Text != null && textEmail.Text != "" && textEmail.Text.Contains("@") && textEmail.Text.Contains(".")) { donator.Email = textEmail.Text; } else { message += ",E-mail"; } try { Int64.Parse(textTelefon.Text); if (donator.Telefon != textTelefon.Text) { donator.Telefon = textTelefon.Text; } } catch (Exception ex) { message += ",telefon"; } if (service.Encrypt(textBoxParola.Text) == user.Parola) { if (textPswNew.Text == textPswNewR.Text) { user.Parola = service.Encrypt(textPswNew.Text); } } else { message += ",parola"; } if (message == string.Empty) { service.UpdateDonator(donator); service.UpdateUserDonator(user); this.Username = textBoxUserName.Text; MessageBox.Show("Modificarile au avut loc cu succes"); textBoxParola.Clear(); textPswNew.Clear(); textPswNewR.Clear(); } else { MessageBox.Show($"Am gasit probleme la: {message}"); var msg = message.Split(','); foreach (var i in msg) { switch (i) { case "username": textBoxUserName.Text = user.Username; break; case "nume": textBoxSetariNume.Text = donator.Nume; break; case "prenume": textBoxSetariPrenume.Text = donator.Prenume; break; case "adresa": textAdresa.Text = donator.Domiciliu; break; case "judet": cmbJud.Text = donator.Judet; break; case "localitate": cmbLoc.Text = donator.Localitate; break; case "telefon": textTelefon.Text = donator.Telefon; break; case "E-mail": textEmail.Text = donator.Email; break; } } } }