예제 #1
0
        public void TestInit()
        {
            EJBContainer c = EJBContainer.Instance;

            c.Configuration.SetDBContextCreationFuncForEntityManager(() => new UniversityContext());
            c.Init();
        }
예제 #2
0
        public void EntityManagerGotFromEJBContainer_NoDefinedDataContext_ShouldThrowExceptionOnContainerInitMethod()
        {
            EJBContainer c = EJBContainer.Instance;

            c.Configuration.SetDBContextCreationFuncForEntityManager(null);
            c.Init();
        }
예제 #3
0
        public void TestInit()
        {
            Trace.WriteLine("Executing EntityManagerTests::TestInit()");

            EJBContainer c = EJBContainer.Instance;

            c.Configuration.SetDBContextCreationFuncForEntityManager(() => new UniversityContext());
            c.Init();

            using (UniversityContext context = new UniversityContext())
            {
                foreach (Student s in context.Students)
                {
                    context.Students.Remove(s);
                }
                context.SaveChanges();
            }

            using (UniversityContext context = new UniversityContext())
            {
                Student s = new Student()
                {
                    Id        = 1,
                    BirthDay  = new DateTime(1980, 05, 05),
                    FirstName = "Petras",
                    LastName  = "Petraitis"
                };

                context.Students.Add(s);

                context.SaveChanges();
            }
        }
예제 #4
0
        public void GetEntityManager_ReturnNotNull()
        {
            EJBContainer c = EJBContainer.Instance;

            c.Configuration.SetFullAssebliesNamesForSessionBeans(new[] { "abc" });
            c.Init();
            Assert.IsNotNull(c.EntityManager);
        }
예제 #5
0
        public static void TestClassInit(TestContext textContext)
        {
            Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));

            Trace.WriteLine("Executing EntityManagerTests::TestClassInit()");

            Database.SetInitializer(new UniversityInitializer());

            EJBContainer c = EJBContainer.Instance;

            c.Configuration.SetDBContextCreationFuncForEntityManager(() => new UniversityContext());
            c.Init();

            //using (UniversityContext context = new UniversityContext())
            //{
            //    foreach (Student s in context.Students)
            //    {
            //        context.Students.Remove(s);
            //    }
            //    context.SaveChanges();
            //}
        }
예제 #6
0
        public void TestsInit()
        {
            Trace.WriteLine("Executing ContainerManagedTransactions::TestsInit(..)");

            EJBContainer c = EJBContainer.Instance;

            c.Configuration.SetDBContextCreationFuncForEntityManager(() => new UniversityContext());
            c.Init();

            using (UniversityContext context = new UniversityContext())
            {
                foreach (Student s in context.Students)
                {
                    context.Students.Remove(s);
                }

                foreach (Log l in context.Logs)
                {
                    context.Logs.Remove(l);
                }

                context.SaveChanges();
            }
        }
예제 #7
0
        public static void TestClassInit(TestContext textContext)
        {
            Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));

            EJBContainer c = EJBContainer.Instance;

            c.Configuration.SetDBContextCreationFuncForEntityManager(() => new UniversityContext());
            c.Init();

            using (UniversityContext context = new UniversityContext())
            {
                foreach (Student s in context.Students)
                {
                    context.Students.Remove(s);
                }

                foreach (Log l in context.Logs)
                {
                    context.Logs.Remove(l);
                }

                context.SaveChanges();
            }
        }