public void Add_New_RunTest()
 {
     EF_RunDataRepository target = new EF_RunDataRepository();
     string name = "this was a new run";
     List<DataLabel> labels = new List<DataLabel>() { new DataLabel(name) };
     target.Add_New_Run(name, labels);
     Assert.IsNotNull(target.Get_RunData_object(name).DataLabels[0]);
     target.Delete_RunData_object(name);
 }
        public void Test_deletion_of_Data_when_RunData_is_deleted()
        {
            SolarsplashEntities db = new SolarsplashEntities();
            EF_RunDataRepository target = new EF_RunDataRepository(db, true );

            string name = "this should be deleted";
            save_RunData_to_db(make_dummy_RunData_object(name), db);
            int id = target.Get_RunData_object(name).Runs[0].Data[0].id_Data;

            Assert.IsNotNull(db.Data.Find(id));
            target.Delete_RunData_object(name);    //delete the RunData object
            Assert.IsNull(db.Data.Find(id));
        }
 public void Add_RunElement_to_RunDataTest()
 {
     EF_RunDataRepository target = new EF_RunDataRepository();
     string name = "Test Run";
     int runNumber = 43;
     target.Add_New_Run(name, new List<DataLabel>());// add object to db
     RunElement element = new RunElement(new List<float>(), runNumber);
     bool expected = true;
     bool actual;
     actual = target.Add_RunElement_to_RunData(name, element);
     Assert.AreEqual(expected, actual);
     Assert.AreEqual(runNumber, target.Get_RunData_object(name).Runs[0].Number);
     actual = target.Delete_RunData_object(name);    //delect the object
     Assert.IsTrue(actual);
 }
        public void Delete_RunData_objectTest()
        {
            SolarsplashEntities db = new SolarsplashEntities();
            EF_RunDataRepository target = new EF_RunDataRepository(db, true);
            RunData item = new RunData();
            string name = "this should be deleted";
            item.Name = name;
            bool expected = true;
            bool actual;

            target.Add_New_Run(name, new List<DataLabel> {new DataLabel(name) });// add object to db
            int DataLabel_id = target.Get_RunData_object(name).DataLabels[0].id_DataLabel;

            Assert.IsNotNull(target.Get_RunData_base_object(name));
            actual = target.Delete_RunData_object(item);    //delete the object
            Assert.AreEqual(expected, actual);
            Assert.IsNull(target.Get_RunData_base_object(name));
            Assert.IsNull(db.DataLabel.Find(DataLabel_id)); // test to make sure child object got deleted as well
        }
        public void Get_RunData_objectTest()
        {
            SolarsplashEntities db = new SolarsplashEntities();
            EF_RunDataRepository target = new EF_RunDataRepository(db, true);
            string name = "this object does not exist";
            RunData expected = null;
            RunData actual;

            // test return of null object
            actual = target.Get_RunData_object(name);
            Assert.IsNull(actual);

            // test return of seeded object
            name="Get_RunData_objectTest";
            expected = new RunData();
            expected.Name = name;
            expected.Runs.Add(new RunElement(new List<float> { 2.3F, 21.2F, 3F }, 1));
            db.RunData.Add(expected);
            db.SaveChanges();
            actual = target.Get_RunData_object(name);
            Assert.AreEqual(21.2F, actual.Runs[0].Data[1].Value);
        }
        public void Get_RunData_base_objectTest()
        {
            SolarsplashEntities db = new SolarsplashEntities();
            EF_RunDataRepository target = new EF_RunDataRepository(db, true);
            string name = "this object does not exist";
            RunData expected = null;
            RunData actual;

            // test return of null object
            actual = target.Get_RunData_base_object(name);
            Assert.IsNull(actual);

            // test return of seeded object
            name = "Get_RunData_base_objectTest";
            expected = new RunData();
            expected.Name = name;
            expected.Runs.Add(new RunElement(new List<float> { 2.3F, 21.2F, 3F }, 1));
            expected.DataLabels.AddRange(DataLabel.MakeRange(new List<string> { "SVOL", "TEST" }));
            db.RunData.Add(expected);
            db.SaveChanges();
            actual = target.Get_RunData_base_object(name);
            Assert.AreEqual(name, actual.Name);
            //Assert.AreEqual(0, actual.Runs.Count);  //should have not loaded any of the run
            Assert.AreEqual("TEST", actual.DataLabels[1].LabelName);
        }