public void TestAddProj() { // Create a test object Project newProj = new Project { projectName = "TEST", defconScale = 1, dueDate = Convert.ToDateTime("1-1-1999") }; // Call the method - await so that the following query isn't run first EngineUnderTest.AddProj(newProj); Project testAgainst = EngineUnderTest.GetProj("TEST"); // check if the project was added properly DataTable testProjTable = new DataTable(); Assert.AreEqual(newProj.projectName, testAgainst.projectName); Assert.AreEqual(newProj.defconScale, testAgainst.defconScale); Assert.AreEqual(newProj.dueDate, testAgainst.dueDate); // Remove the project string query = "DELETE FROM Project WHERE projectName = 'TEST';"; EngineUnderTest.ExecuteSQLCommand(query); }
public async void CreateProject() { int check; try { using (var streamReader = new HttpRequestStreamReader(Request.Body, Encoding.UTF8)) using (var jsonReader = new JsonTextReader(streamReader)) { var json = await JObject.LoadAsync(jsonReader); var nameHolder = json["projectName"]; var DateHolder = json["launchDate"]; Project newProject = new Project(nameHolder.ToString(), 5, DateTime.Parse(DateHolder.ToString())); //"minimum" or lowest DEFCON value is 5 check = engine.AddProj(newProject); } } catch (Exception e) { // handle exception } }