public void Test_Find_FindsRemedyInDatabase() { Remedy testRemedy = new Remedy("Herbal", "descriptionHerbal", "sideEffectHerbal", "website.com/photoOfRemedy.jpg", 1); testRemedy.Save(); Remedy foundRemedy = Remedy.Find(testRemedy.GetId()); Assert.Equal(testRemedy, foundRemedy); }
public void Test_Save_AssignsIdToRemedy() { Remedy testRemedy = new Remedy("Herbal", "descriptionHerbal", "sideEffectHerbal", "website.com/photoOfRemedy.jpg", 1); testRemedy.Save(); Remedy savedRemedy = Remedy.GetAll()[0]; int result = savedRemedy.GetId(); int testId = testRemedy.GetId(); Assert.Equal(testId, result); }
public override bool Equals(System.Object otherRemedy) { if (!(otherRemedy is Remedy)) { return(false); } else { Remedy newRemedy = (Remedy)otherRemedy; bool idEquality = this.GetId() == newRemedy.GetId(); bool nameEquality = this.GetName() == newRemedy.GetName(); bool descriptionEquality = this.GetDescription() == newRemedy.GetDescription(); bool sideEffect = this.GetSideEffect() == newRemedy.GetSideEffect(); bool imageEquality = this.GetImage() == newRemedy.GetImage(); bool categoryIdEquality = this.GetCategoryId() == newRemedy.GetCategoryId(); return(idEquality && nameEquality && descriptionEquality && sideEffect && imageEquality && categoryIdEquality); } }
public void AddRemedy(Remedy newRemedy) { SqlConnection conn = DB.Connection(); conn.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO diseases_remedies (diseases_id, remedies_id) VALUES (@DiseaseId, @RemedyId);", conn); SqlParameter DiseaseIdParameter = new SqlParameter("@DiseaseId", this.GetId()); SqlParameter RemedyIdParameter = new SqlParameter("@RemedyId", newRemedy.GetId()); cmd.Parameters.Add(DiseaseIdParameter); cmd.Parameters.Add(RemedyIdParameter); cmd.ExecuteNonQuery(); if (conn != null) { conn.Close(); } }