Пример #1
0
        public void WhenInnerRequestNewIsCalled_ItShouldBeCommitedIndependentlyOfTheOutterTransaction2()
        {
            DummyManagerForTesting m = new DummyManagerForTesting();

            m.Required_RequiredNew_InsertNewStudent2();

            //Also tests:

            /*
             * [ ] New test: //patikrinti ar kai naudojamas request ir requestNew, request irgi veikia teisingai.
             *      Request_InsertNewStudent
             *           RequestNew_InsertNewStudent (id:2)
             *           should not exist id:2             *
             *      should exist id:2
             *      student (id:3) inserted
             *      Should not exist id3
             *  should exist id:3*/

            UniversityContext uc = new UniversityContext();

            Assert.IsNotNull(uc.Students.SingleOrDefault(e => e.Id == 3 &&
                                                         e.FirstName == "Vardenis3" &&
                                                         e.LastName == "Pavardenis3" &&
                                                         e.BirthDay == new DateTime(1991, 01, 01)));
        }
Пример #2
0
        public void InsertNewStudentInRequestTransactionScope_ShouldExistInDbAfterMethodCall()
        {
            Trace.WriteLine("Executing ContainerManagedTransactions::InsertNewStudentInRequestTransactionScope_ShouldExistInDbAfterMethodCall()");

            try
            {
                //EJBContainer c = EJBContainer.Instance;
                //c.Configuration.SetDBContextCreationFuncForEntityManager(() => new UniversityContext());
                //c.Init();

                DummyManagerForTesting m = new DummyManagerForTesting();
                m.Required_InsertNewStudent();

                Assert.IsNull(System.Transactions.Transaction.Current);

                UniversityContext uc = new UniversityContext();
                Assert.IsNotNull(uc.Students.SingleOrDefault(e => e.Id == 2 &&
                                                             e.FirstName == "Vardenis" &&
                                                             e.LastName == "Pavardenis" &&
                                                             e.BirthDay == new DateTime(1990, 01, 01)));
            }
            catch (Exception exc)
            {
                throw;
            }
        }
Пример #3
0
        public void RequestNew_Active_transaction_should_exist_insideTheMethod()
        {
            //Kviečiamas metodas su requestNew atributu. viduj patikrinama ar yra aktyvi tranzakcija.
            DummyManagerForTesting m = new DummyManagerForTesting();

            m.RequiredNew();

            Assert.IsNull(System.Transactions.Transaction.Current);
        }
Пример #4
0
        public void InsertNewStudentWithNotSupport_WithAmbientTransaction_ShouldInsertButWithoutActiveTransaction()
        {
            DummyManagerForTesting m = new DummyManagerForTesting();

            m.Requried_NotSupports_InsertNewStudent();

            UniversityContext uc = new UniversityContext();

            Assert.IsNotNull(uc.Students.SingleOrDefault(e => e.Id == 3 &&
                                                         e.FirstName == "Vardenis3" &&
                                                         e.LastName == "Pavardenis3" &&
                                                         e.BirthDay == new DateTime(1990, 01, 03)));
        }
Пример #5
0
        public void WhenInsertsStudentWithSupportAttribute_JoinsAmbientTransactionIfItExists()
        {
            DummyManagerForTesting m = new DummyManagerForTesting();

            m.Required_Supports_InsertNewStudent();

            UniversityContext uc = new UniversityContext();

            Assert.IsNotNull(uc.Students.SingleOrDefault(e => e.Id == 2 &&
                                                         e.FirstName == "Vardenis" &&
                                                         e.LastName == "Pavardenis" &&
                                                         e.BirthDay == new DateTime(1990, 01, 01)));
        }
Пример #6
0
        public void InsertNewStudentInSecondRequestTransactionMethod()
        {
            //iškviečiamas metodas su request atributu. sukuriama tranzakcija.
            //iškviečiam request metodas, jis įrašo duomenis. grįžus iš metodo, pirmame metode patikriname ar objektas egzistuoja DB - turi neegzistuot.
            //Po to kai grįžtama iš antrojo metodo, tuomet turi jau būti objektas įrašytas į DB.
            DummyManagerForTesting m = new DummyManagerForTesting();

            m.Required_Required_InsertNewStudent();


            Assert.IsNull(System.Transactions.Transaction.Current);

            UniversityContext uc = new UniversityContext();

            Assert.IsNotNull(uc.Students.SingleOrDefault(e => e.Id == 2 &&
                                                         e.FirstName == "Vardenis" &&
                                                         e.LastName == "Pavardenis" &&
                                                         e.BirthDay == new DateTime(1990, 01, 01)));
        }
Пример #7
0
        public void Test_MandatoryAttribute_ThrowException()
        {
            DummyManagerForTesting m = new DummyManagerForTesting();

            m.Mandatory();
        }