public void TestProgramClassTypeCollection_1() { ProgramClassTypeCollection collection = new ProgramClassTypeCollection(); ProgramClass testProgramClass; ProgramInterface testProgramInterface; List <string> list = new List <string>(); List <string> testClassModifiers = new List <string>(); List <string> testClassGenerics = new List <string>(); List <string> testInterfaceModifiers = new List <string>(); List <string> testInterfaceGenerics = new List <string>(); testClassModifiers.Add("x"); testClassGenerics.Add("y"); testInterfaceModifiers.Add("x"); testInterfaceGenerics.Add("y"); testProgramClass = new ProgramClass("item2", testClassModifiers, testClassGenerics); testProgramInterface = new ProgramInterface("item2", testInterfaceModifiers, testInterfaceGenerics); collection.Add(new ProgramClass("item0", list, list)); collection.Add(new ProgramInterface("item1", list, list)); collection.Add(new ProgramClass("item2", list, list)); collection.Add(new ProgramClass("item3", list, list)); Assert.AreEqual(collection[2], collection["item2"]); Assert.AreEqual(collection[2], testProgramClass); Assert.AreEqual(collection["item2"], testProgramClass); Assert.AreNotEqual(collection[2], testProgramInterface); Assert.AreNotEqual(collection["item2"], testProgramInterface); }
public void TestProgramClassType_1() { string name1 = "TestClass"; string name2 = "TestClass"; List <string> list = new List <string>(); List <string> modifiers1 = new List <string>(); List <string> modifiers2 = new List <string>(); List <string> returnTypes = new List <string>(); List <string> modifiers = new List <string>(); ProgramClass programClass1; ProgramClass programClass2; modifiers1.Add("class"); modifiers1.Add("1"); modifiers1.Add("modifiers"); modifiers2.Add("class"); modifiers2.Add("2"); modifiers2.Add("modifiers"); returnTypes.Add("int"); modifiers.Add("public"); programClass1 = new ProgramClass(name1, modifiers1, list); programClass2 = new ProgramClass(name2, modifiers2, list); programClass1.ChildList.Add(new ProgramFunction("FunctionName", list, returnTypes, list, list, list)); programClass2.OwnedClasses.Add(new ProgramClass("ClassName", modifiers, list)); Assert.AreEqual(programClass1, programClass2); Assert.AreEqual(programClass1.GetHashCode(), programClass2.GetHashCode()); }
// PUT: api/Program/5 public void Put(int id, [FromBody] ProgramClass program) { //System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt"); //file.WriteLine("inside put"); _programRepository.UpdateProgram(program); //file.WriteLine("finished put"); }
// Delete a ProgramClass from the database public void DeleteProgramClass(int id) { ProgramClass programClass = db.ProgramClasses.Find(id); db.ProgramClasses.Remove(programClass); db.SaveChanges(); }
public void TestFunctionSignature_F() { ProgramFile programFile = new ProgramFile("path", "name", "text"); ProgramClassTypeCollection expectedClassTypeCollection = new ProgramClassTypeCollection(); ProgramClassTypeCollection actualClassTypeCollection = new ProgramClassTypeCollection(); CodeProcessor codeProcessor = new CodeProcessor(programFile, actualClassTypeCollection); ProgramClass expectedProgramClass; ProgramClass actualProgramClass; ProgramFunction expectedProgramFunction; ProgramFunction actualProgramFunction; string[] fileTextDataArray = { "class", "ClassName", " ", "{", " ", "public", "virtual", "(", "List", "<", "int", ">", ",", "bool", ",", "float",")", "Test", "<", "Object", ">", "(", "double", "n", ",", "double", "m", ")", " ", "{", " ", "return", "(", "0", ",", "0",")", ";", " ", "}", " ", "}" }; programFile.FileTextData.AddRange(fileTextDataArray); string name = "Test"; List <string> empty = new List <string>(); List <string> ModF = new List <string>(); List <string> RetF = new List <string>(); List <string> GenF = new List <string>(); List <string> ParF = new List <string>(); ModF.Add("public"); ModF.Add("virtual"); RetF.Add("List"); RetF.Add("<"); RetF.Add("int"); RetF.Add(">"); RetF.Add(","); RetF.Add("bool"); RetF.Add(","); RetF.Add("float"); GenF.Add("Object"); ParF.Add("double"); ParF.Add("n"); ParF.Add(","); ParF.Add("double"); ParF.Add("m"); expectedProgramClass = new ProgramClass("ClassName", empty, empty); expectedProgramFunction = new ProgramFunction(name, ModF, RetF, GenF, ParF, empty); expectedProgramClass.ChildList.Add(expectedProgramFunction); expectedClassTypeCollection.Add(expectedProgramClass); codeProcessor.ProcessFileCode(); CollectionAssert.AreEqual(expectedClassTypeCollection, actualClassTypeCollection); actualProgramClass = (ProgramClass)actualClassTypeCollection[0]; Assert.AreEqual(expectedProgramClass.ChildList.Count, actualProgramClass.ChildList.Count); actualProgramFunction = (ProgramFunction)actualProgramClass.ChildList[0]; Assert.AreEqual(expectedProgramFunction.Name, actualProgramFunction.Name); CollectionAssert.AreEqual(expectedProgramFunction.Modifiers, actualProgramFunction.Modifiers); CollectionAssert.AreEqual(expectedProgramFunction.ReturnTypes, actualProgramFunction.ReturnTypes); CollectionAssert.AreEqual(expectedProgramFunction.Generics, actualProgramFunction.Generics); CollectionAssert.AreEqual(expectedProgramFunction.Parameters, actualProgramFunction.Parameters); }
protected void Page_Load(object sender, EventArgs e) { if (!AppLib.IsLoggedinSessionExists()) Response.Redirect(AppConfig.GetBaseSiteUrl() + "Welcome/main_frame.aspx", true); objPalClass = new PALClass(objSqlConnClass.OpenConnection()); objProgramClass = new ProgramClass(objSqlConnClass.sqlConnection); #region Insert visited log details AppLib.InsertVisitedSectionDetails("My Program"); #endregion }
protected void Page_Load(object sender, EventArgs e) { objPalClass = new PALClass(objSqlConnClass.OpenConnection()); objProgramClass = new ProgramClass(objSqlConnClass.sqlConnection); if (Request.QueryString["programID"] != null) { gsProgramID = Request.QueryString["programID"].ToString(); } else { gsProgramID = "801"; } }
public void TestFunctionSignature_B() { ProgramFile programFile = new ProgramFile("path", "name", "text"); ProgramClassTypeCollection expectedClassTypeCollection = new ProgramClassTypeCollection(); ProgramClassTypeCollection actualClassTypeCollection = new ProgramClassTypeCollection(); CodeProcessor codeProcessor = new CodeProcessor(programFile, actualClassTypeCollection); ProgramClass expectedProgramClass; ProgramClass actualProgramClass; ProgramFunction expectedProgramFunction; ProgramFunction actualProgramFunction; string[] fileTextDataArray = { "class", "ClassName", " ", "{", " ", "void", "Test", "<", "V", ",", "W", ">", "(", "int", "x", ")", " ", "{"," ","return", "(", "0", ",", "0", ")", ";", " ", "}", " ", "}" }; programFile.FileTextData.AddRange(fileTextDataArray); string name = "Test"; List <string> empty = new List <string>(); List <string> RetB = new List <string>(); List <string> GenB = new List <string>(); List <string> ParB = new List <string>(); RetB.Add("void"); GenB.Add("V"); GenB.Add(","); GenB.Add("W"); ParB.Add("int"); ParB.Add("x"); expectedProgramClass = new ProgramClass("ClassName", empty, empty); expectedProgramFunction = new ProgramFunction(name, empty, RetB, GenB, ParB, empty); expectedProgramClass.ChildList.Add(expectedProgramFunction); expectedClassTypeCollection.Add(expectedProgramClass); codeProcessor.ProcessFileCode(); CollectionAssert.AreEqual(expectedClassTypeCollection, actualClassTypeCollection); actualProgramClass = (ProgramClass)actualClassTypeCollection[0]; Assert.AreEqual(expectedProgramClass.ChildList.Count, actualProgramClass.ChildList.Count); actualProgramFunction = (ProgramFunction)actualProgramClass.ChildList[0]; Assert.AreEqual(expectedProgramFunction.Name, actualProgramFunction.Name); CollectionAssert.AreEqual(expectedProgramFunction.Modifiers, actualProgramFunction.Modifiers); CollectionAssert.AreEqual(expectedProgramFunction.ReturnTypes, actualProgramFunction.ReturnTypes); CollectionAssert.AreEqual(expectedProgramFunction.Generics, actualProgramFunction.Generics); CollectionAssert.AreEqual(expectedProgramFunction.Parameters, actualProgramFunction.Parameters); }
public ActionResult Create(string className = "") { if (ModelState.IsValid) { ProgramClass programClass = new ProgramClass { ClassName = className }; LMSRepo.AddProgramClass(programClass); return(RedirectToAction("Index", "ProgramClass")); } return(View()); }
public void TestFunctionSignature_O() { ProgramFile programFile = new ProgramFile("path", "name", "text"); ProgramClassTypeCollection expectedClassTypeCollection = new ProgramClassTypeCollection(); ProgramClassTypeCollection actualClassTypeCollection = new ProgramClassTypeCollection(); CodeProcessor codeProcessor = new CodeProcessor(programFile, actualClassTypeCollection); ProgramClass expectedProgramClass; ProgramClass actualProgramClass; ProgramFunction expectedProgramFunction; ProgramFunction actualProgramFunction; string[] fileTextDataArray = { "class", "ClassName", " ", "{", " ", "public", "static", "Test", ".", "NewType", "TestFunc", "(", ")", " ", "{"," ", "return", "(", "0", ",", "0", ")", ";", " ", "}", " ", "}" }; programFile.FileTextData.AddRange(fileTextDataArray); string name = "TestFunc"; List <string> empty = new List <string>(); List <string> ModO = new List <string>(); List <string> RetO = new List <string>(); ModO.Add("public"); ModO.Add("static"); RetO.Add("Test"); RetO.Add("."); RetO.Add("NewType"); expectedProgramClass = new ProgramClass("ClassName", empty, empty); expectedProgramFunction = new ProgramFunction(name, ModO, RetO, empty, empty, empty); expectedProgramClass.ChildList.Add(expectedProgramFunction); expectedClassTypeCollection.Add(expectedProgramClass); codeProcessor.ProcessFileCode(); CollectionAssert.AreEqual(expectedClassTypeCollection, actualClassTypeCollection); actualProgramClass = (ProgramClass)actualClassTypeCollection[0]; Assert.AreEqual(expectedProgramClass.ChildList.Count, actualProgramClass.ChildList.Count); actualProgramFunction = (ProgramFunction)actualProgramClass.ChildList[0]; Assert.AreEqual(expectedProgramFunction.Name, actualProgramFunction.Name); CollectionAssert.AreEqual(expectedProgramFunction.Modifiers, actualProgramFunction.Modifiers); CollectionAssert.AreEqual(expectedProgramFunction.ReturnTypes, actualProgramFunction.ReturnTypes); CollectionAssert.AreEqual(expectedProgramFunction.Generics, actualProgramFunction.Generics); CollectionAssert.AreEqual(expectedProgramFunction.Parameters, actualProgramFunction.Parameters); }
//update program public void UpdateProgram(ProgramClass program) { var sql = "UPDATE Programs set [PatientId] = @PatientId, [Status] = @Status, [StartDay] = @StartDay, [Duration]=@Duration, [CurrentWeek]=@CurrentWeek WHERE ProgramID = @ProgramID"; this.db.Query <string>(sql, new { PatientId = program.PatientId, Status = program.Status, StartDay = program.StartDay, Duration = program.Duration, CurrentWeek = program.CurrentWeek, ProgramID = program.ProgramID }); //delet all activities in the program var deleteActivities = "DELETE * FROM PatientActivities WHERE ProgramID = @ProgramID"; var deleteResponse = "DELETE * FROM ActivitiesResponse WHERE ProgramID = @ProgramID"; this.db.Query <string>(deleteActivities, new { ProgramID = program.ProgramID }); this.db.Query <string>(deleteResponse, new { ProgramID = program.ProgramID }); // add new activities to the program var insertActivities = "INSERT INTO PatientActivities ([ProgramID], [ActivityId], [ActivityRestponce]," + "[ActivityFeedback], [ActivityStatus],[ActivityName]," + "[ActivityType], [ActivityGroupAge], [ActivityNameParent], [Description]) VALUES " + " (@ProgramId, @ActivityId, @ActivityRestponce, @ActivityFeedback," + "@ActivityStatus, @ActivityName, @ActivityType, @ActivityGroupAge, @ActivityNameParent, @Description)"; foreach (var activity in program.PatientActivityList) { this.db.Query <string>(insertActivities, new { ProgramID = activity.ProgramId, ActivityId = activity.ActivityId, ActivityRestponce = activity.ActivityRestponce, ActivityFeedback = activity.ActivityFeedback, ActivityStatus = activity.ActivityStatus, ActivityName = activity.ActivityName, ActivityType = activity.ActivityType, ActivityGroupAge = activity.ActivityGroupAge, ActivityNameParent = activity.ActivityNameParent, Description = activity.Description }); } }
//create program public ProgramClass CreateProgram(ProgramClass program) { var sql = "INSERT INTO Programs ([PatientId], [Status], [StartDay], [Duration], [CurrentWeek]) " + "VALUES (@PatientId, @Status, @StartDay, @Duration, @CurrentWeek)"; var sqlId = "SELECT * From Programs WHERE PatientId = @PatientId"; var sqlGetActivities = "SELECT * From PatientActivities WHERE ProgramID = @ProgramID"; var newProgram = this.db.Query <ProgramClass>(sql, new { PatientId = program.PatientId, Status = program.Status, StartDay = program.StartDay, Duration = program.Duration, CurrentWeek = program.CurrentWeek }).FirstOrDefault(); var newP = this.db.Query <ProgramClass>(sqlId, new { PatientId = program.PatientId }).LastOrDefault(); program.ProgramID = newP.ProgramID; // add new activities to the program var insertActivities = "INSERT INTO PatientActivities ([ProgramID], [ActivityId], [ActivityRestponce]," + "[ActivityFeedback], [ActivityStatus],[ActivityName]," + "[ActivityType], [ActivityGroupAge], [ActivityNameParent], [Description]) VALUES " + " (@ProgramId, @ActivityId, @ActivityRestponce, @ActivityFeedback," + "@ActivityStatus, @ActivityName, @ActivityType, @ActivityGroupAge, @ActivityNameParent, @Description)"; foreach (var activity in program.PatientActivityList) { this.db.Query <string>(insertActivities, new { ProgramID = newP.ProgramID, ActivityId = activity.ActivityId, ActivityRestponce = activity.ActivityRestponce, ActivityFeedback = activity.ActivityFeedback, ActivityStatus = activity.ActivityStatus, ActivityName = activity.ActivityName, ActivityType = activity.ActivityType, ActivityGroupAge = activity.ActivityGroupAge, ActivityNameParent = activity.ActivityNameParent, Description = activity.Description }); } newP.PatientActivityList = this.db.Query <PatientActivityClass>(sqlGetActivities, new { ProgramID = newP.ProgramID }).ToList(); return(newP); }
public void TestProgramClassType_3() { string name = "TestName"; List <string> modifiers = new List <string>(); List <string> list = new List <string>(); ProgramClass programClass; ProgramInterface programInterface; ProgramClass subclass; modifiers.Add("private"); subclass = new ProgramClass("Subclass", list, list); programClass = new ProgramClass(name, modifiers, list); programInterface = new ProgramInterface(name, modifiers, list); programClass.SubClasses.Add(subclass); programInterface.SubClasses.Add(subclass); Assert.AreNotEqual(programClass, programInterface); Assert.AreNotEqual(programClass.GetHashCode(), programInterface.GetHashCode()); }
public void TestProgramClassTypeCollection_2() { ProgramClassTypeCollection collection = new ProgramClassTypeCollection(); List <string> list = new List <string>(); List <string> testClassModifiers = new List <string>(); ProgramClass testProgramClass; testClassModifiers.Add("x"); testProgramClass = new ProgramClass("item2", testClassModifiers, list); collection.Add(new ProgramClass("item0", list, list)); collection.Add(new ProgramInterface("item1", list, list)); collection.Add(new ProgramClass("item2", list, list)); collection.Add(new ProgramClass("item3", list, list)); collection[2].Name = "item2_newName"; Assert.ThrowsException <KeyNotFoundException>(() => collection["item2"]); Assert.AreEqual(collection[2], collection["item2_newName"]); Assert.AreNotEqual(collection[2], testProgramClass); Assert.AreNotEqual(collection["item2_newName"], testProgramClass); }
protected void Page_Load(object sender, EventArgs e) { objPalClass = new PALClass(objSqlConnClass.OpenConnection()); objProgramClass = new ProgramClass(objSqlConnClass.OpenConnection()); }
protected void Page_Load(object sender, EventArgs e) { imgProgramInfo.Src = AppConfig.GetBaseSiteUrl() + "images/icons/iconProgram.gif";//added by Netsmartz objPALClass = new PALClass(objSqlConnClass.OpenConnection()); objProgramClass = new ProgramClass(objSqlConnClass.sqlConnection); objBackofficeClass = new BackofficeClass(objSqlConnClass.sqlConnection); gsUserID = Membership.GetUser().ProviderUserKey.ToString(); if (ViewState["gsPalStartID"] != null) { gsPalStartID = ViewState["gsPalStartID"].ToString(); } }
public void Post([FromBody] ProgramClass program) { _programRepository.CreateProgram(program); }
public void TestRelationshipProcessor_ProcessRelationships() { ProgramFile programFile; CodeProcessor codeProcessor; FileProcessor fileProcessor; ProgramClassTypeCollection expectedProgramClassTypeCollection = new ProgramClassTypeCollection(); ProgramClassTypeCollection actualProgramClassTypeCollection = new ProgramClassTypeCollection(); List <string> empty = new List <string>(); string filePath = Path.GetFullPath("..\\..\\..\\CodeAnalyzerTests\\TestInputFiles\\TestInputFile.cs"); string fileName = "TestInputFile.cs"; string fileText = ""; if (File.Exists(filePath)) { fileText = File.ReadAllText(filePath); } ProgramInterface IAnimalActions = new ProgramInterface("IAnimalActions", empty, empty); ProgramInterface IHumanActions = new ProgramInterface("IHumanActions", empty, empty); ProgramClass Animal = new ProgramClass("Animal", empty, empty); ProgramClass Pet = new ProgramClass("Pet", empty, empty); ProgramClass Dog = new ProgramClass("Dog", empty, empty); ProgramClass Human = new ProgramClass("Human", empty, empty); ProgramClass Car = new ProgramClass("Car", empty, empty); IAnimalActions.SubClasses.Add(Dog); IAnimalActions.SubClasses.Add(Human); IHumanActions.SubClasses.Add(Human); Animal.SubClasses.Add(Pet); Animal.SubClasses.Add(Human); Pet.SuperClasses.Add(Animal); Pet.SubClasses.Add(Dog); Pet.OwnedByClasses.Add(Human); Pet.UsedByClasses.Add(Human); Dog.SuperClasses.Add(Pet); Dog.SuperClasses.Add(IAnimalActions); Dog.OwnedByClasses.Add(Human); Human.SuperClasses.Add(Animal); Human.SuperClasses.Add(IAnimalActions); Human.SuperClasses.Add(IHumanActions); Human.OwnedClasses.Add(Car); Human.OwnedClasses.Add(Pet); Human.OwnedClasses.Add(Dog); Human.UsedClasses.Add(Pet); Car.OwnedByClasses.Add(Human); expectedProgramClassTypeCollection.Add(IAnimalActions); expectedProgramClassTypeCollection.Add(IHumanActions); expectedProgramClassTypeCollection.Add(Animal); expectedProgramClassTypeCollection.Add(Pet); expectedProgramClassTypeCollection.Add(Dog); expectedProgramClassTypeCollection.Add(Human); expectedProgramClassTypeCollection.Add(Car); programFile = new ProgramFile(filePath, fileName, fileText); fileProcessor = new FileProcessor(programFile); codeProcessor = new CodeProcessor(programFile, actualProgramClassTypeCollection); fileProcessor.ProcessFile(); codeProcessor.ProcessFileCode(); foreach (ProgramClassType programClassType in actualProgramClassTypeCollection) { RelationshipProcessor relationshipProcessor = new RelationshipProcessor(programClassType, actualProgramClassTypeCollection); relationshipProcessor.ProcessRelationships(); } CollectionAssert.AreEquivalent(expectedProgramClassTypeCollection, actualProgramClassTypeCollection); foreach (ProgramClassType expectedProgramClassType in expectedProgramClassTypeCollection) { if (actualProgramClassTypeCollection.Contains(expectedProgramClassType.Name)) { ProgramClassType actualProgramClassType = actualProgramClassTypeCollection[expectedProgramClassType.Name]; CollectionAssert.AreEquivalent(expectedProgramClassType.SubClasses, actualProgramClassType.SubClasses); CollectionAssert.AreEquivalent(expectedProgramClassType.SuperClasses, actualProgramClassType.SuperClasses); if (expectedProgramClassType.GetType() == typeof(ProgramClass)) { ProgramClass expectedProgramClass = (ProgramClass)expectedProgramClassType; ProgramClass actualProgramClass = (ProgramClass)actualProgramClassType; CollectionAssert.AreEquivalent(expectedProgramClass.OwnedClasses, actualProgramClass.OwnedClasses); CollectionAssert.AreEquivalent(expectedProgramClass.OwnedByClasses, actualProgramClass.OwnedByClasses); CollectionAssert.AreEquivalent(expectedProgramClass.UsedClasses, actualProgramClass.UsedClasses); CollectionAssert.AreEquivalent(expectedProgramClass.UsedByClasses, actualProgramClass.UsedByClasses); } } } }
public void TestCodeProcessor_ProcessFileCode_Structure() { CodeProcessor codeProcessor; ProgramFile expectedProgramFile; ProgramClassTypeCollection expectedProgramClassTypeCollection = new ProgramClassTypeCollection(); FileProcessor fileProcessorForActual; ProgramFile actualProgramFile; ProgramClassTypeCollection actualProgramClassTypeCollection = new ProgramClassTypeCollection(); ProgramClassType tempProgramClassType; List <string> empty = new List <string>(); string filePath = Path.GetFullPath("..\\..\\..\\CodeAnalyzerTests\\TestInputFiles\\TestInputFile.cs"); string fileName = "TestInputFile.cs"; string fileText = ""; if (File.Exists(filePath)) { fileText = File.ReadAllText(filePath); } expectedProgramFile = new ProgramFile(filePath, fileName, fileText); tempProgramClassType = new ProgramInterface("IAnimalActions", empty, empty); expectedProgramFile.ChildList.Add(tempProgramClassType); expectedProgramClassTypeCollection.Add(tempProgramClassType); tempProgramClassType = new ProgramInterface("IHumanActions", empty, empty); expectedProgramFile.ChildList.Add(tempProgramClassType); expectedProgramClassTypeCollection.Add(tempProgramClassType); tempProgramClassType = new ProgramClass("Animal", empty, empty); tempProgramClassType.ChildList.Add(new ProgramFunction("Animal", empty, empty, empty, empty, empty)); tempProgramClassType.ChildList.Add(new ProgramFunction("Move", empty, empty, empty, empty, empty)); expectedProgramFile.ChildList.Add(tempProgramClassType); expectedProgramClassTypeCollection.Add(tempProgramClassType); tempProgramClassType = new ProgramClass("Pet", empty, empty); tempProgramClassType.ChildList.Add(new ProgramFunction("Pet", empty, empty, empty, empty, empty)); expectedProgramFile.ChildList.Add(tempProgramClassType); expectedProgramClassTypeCollection.Add(tempProgramClassType); tempProgramClassType = new ProgramClass("Dog", empty, empty); tempProgramClassType.ChildList.Add(new ProgramFunction("Dog", empty, empty, empty, empty, empty)); tempProgramClassType.ChildList.Add(new ProgramFunction("Talk", empty, empty, empty, empty, empty)); expectedProgramFile.ChildList.Add(tempProgramClassType); expectedProgramClassTypeCollection.Add(tempProgramClassType); tempProgramClassType = new ProgramClass("Human", empty, empty); tempProgramClassType.ChildList.Add(new ProgramFunction("Human", empty, empty, empty, empty, empty)); tempProgramClassType.ChildList.Add(new ProgramFunction("Talk", empty, empty, empty, empty, empty)); tempProgramClassType.ChildList.Add(new ProgramFunction("Move", empty, empty, empty, empty, empty)); tempProgramClassType.ChildList.Add(new ProgramFunction("GoToSchool", empty, empty, empty, empty, empty)); tempProgramClassType.ChildList.Add(new ProgramFunction("GraduateSchool", empty, empty, empty, empty, empty)); tempProgramClassType.ChildList.Add(new ProgramFunction("GoToWork", empty, empty, empty, empty, empty)); tempProgramClassType.ChildList.Add(new ProgramFunction("BuyPet", empty, empty, empty, empty, empty)); tempProgramClassType.ChildList.Add(new ProgramFunction("BuyDog", empty, empty, empty, empty, empty)); tempProgramClassType.ChildList.Add(new ProgramFunction("BuyCar", empty, empty, empty, empty, empty)); tempProgramClassType.ChildList.Add(new ProgramFunction("SellCar", empty, empty, empty, empty, empty)); tempProgramClassType.ChildList.Add(new ProgramFunction("FillCarFuelTank", empty, empty, empty, empty, empty)); expectedProgramFile.ChildList.Add(tempProgramClassType); expectedProgramClassTypeCollection.Add(tempProgramClassType); tempProgramClassType = new ProgramClass("Car", empty, empty); tempProgramClassType.ChildList.Add(new ProgramFunction("Car", empty, empty, empty, empty, empty)); tempProgramClassType.ChildList.Add(new ProgramFunction("FillTank", empty, empty, empty, empty, empty)); expectedProgramFile.ChildList.Add(tempProgramClassType); expectedProgramClassTypeCollection.Add(tempProgramClassType); actualProgramFile = new ProgramFile(filePath, fileName, fileText); fileProcessorForActual = new FileProcessor(actualProgramFile); fileProcessorForActual.ProcessFile(); codeProcessor = new CodeProcessor(actualProgramFile, actualProgramClassTypeCollection); codeProcessor.ProcessFileCode(); CheckAllChildLists(expectedProgramFile, actualProgramFile); CollectionAssert.AreEqual(expectedProgramClassTypeCollection, actualProgramClassTypeCollection); }
// Edit a ProgramClass in the database public void EditProgramClass(ProgramClass programClass) { db.Entry(programClass).State = EntityState.Modified; db.SaveChanges(); }
// Add a ProgramClass to the database public void AddProgramClass(ProgramClass programClass) { db.ProgramClasses.Add(programClass); db.SaveChanges(); }