Exemple #1
0
        public void TestInsertDataInDB()
        {
            try
            {
                using (var context = new DBContext())
                {
                    Type table1 = ManageAssembly.GetType("table1");

                    var data = context.InvokeMethod_Set(table1);

                    // New instance of table1
                    dynamic instance = Activator.CreateInstance(table1);

                    // add title property
                    instance.Title = "Test1";

                    // add new
                    data.Add(instance);

                    // save to DB
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Exemple #2
0
        public void TestGetType()
        {
            try
            {
                var types = ManageAssembly.GetAllDynamicAssemblyTypes();

                Assert.AreEqual(1, types.Where(x => x.Name == "table1").Count());
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Exemple #3
0
        public void TestCreateDll()
        {
            try
            {
                string sourceLocation = "";
                string targetLocation = "";
                string location       = "";

                ManageAssembly.GetWorkPaths(out sourceLocation, out targetLocation, out location);

                ManageAssembly.CreateAssemblies();

                Assert.IsTrue(File.Exists(Path.Combine(targetLocation, "table1.dll")));
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Exemple #4
0
        private static void GetDynamicEFAssemblies()
        {
            string sourceLocation = "";
            string targetLocation = "";
            string location       = "";

            ManageAssembly.GetWorkPaths(out sourceLocation, out targetLocation, out location);

            ManageAssembly.CreateAssemblies();

            //New table1 With {.Title = "Ehab"}
            // Add Classes to our domain
            var assemblyNames = ManageAssembly.GetAllDynamicAssemblyNames();

            foreach (var item in assemblyNames)
            {
                //var asm = Assembly.LoadFrom(item);
                AppDomain.CurrentDomain.Load(AssemblyName.GetAssemblyName(item));
            }
        }
Exemple #5
0
        public void TestGetDataFromDB()
        {
            try
            {
                using (var context = new DBContext())
                {
                    Type table1 = ManageAssembly.GetType("table1");

                    #region Invoke "Set" from context and then Invoke "FirstOrDefault"
                    // Get DBSet
                    dynamic data_Queryable = context.InvokeMethod_Set(table1);

                    dynamic data = context.Invoke_Generic("FirstOrDefault", table1, data_Queryable);
                    #endregion

                    Assert.AreEqual("Test1", data.Title);
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }