UnitTesting custom scripts and DBcompile

Hi,

Currently we are working on our unit tests for OneIdentity using the OneIdentity DLLs.

What we are trying to accomplish is to run daily UnitTesting on our custom scripts. We can create local objects by using "sessionSource.CreateNew(ADSAccount);" for example and set the attributes by using .PutValue.

But when running scripts the scripts make a connection to the actual database and does not look to the localy created object.

So we commited the objects to the database and remove them again afterwards, which works great.

Except that after we create test objects, run the script to test the functionality, remove the test objects from the database using  "sessionReload.MarkForDeletionWithoutDelay();" and "sessionReload.Save(Session);" the database needs to be compiled again which halts the rest of the processes because it's waiting for compile.

First of al, is this the right way to approach this? Or do we need to change some configuration which results in not even having to commit objects to the database.

Else, how do we make sure the DB is compiled after we run our Unit Tests so no processes are being halted.

If there are any questions feel free to ask.

  • Some sample code how we insert objects and remove them.

    namespace OneIdentityUnitTests
    {
        [TestClass()]
        public class Debugging : Initializer
        {
            // Initialize lib class
            Lib lib = new Lib();
    
            static IEntity OI_Object = null;
    
            [TestMethod()]
            public void CCC_Tests()
            {
                var sessionSource = Session.Source();
                IEntity sessionObject = null;
    
                using (var Uow = Session.StartUnitOfWork())
                {
                    try
                    {
                        sessionObject = sessionSource.CreateNew("ADSAccount");
    
                        sessionObject.PutValue("SAMAccountName", "LastnameF");
                        sessionObject.PutValue("CanonicalName", "xxxx.com / xxxx / Accounts / User / Lastname, F(Firstname)");
                        sessionObject.PutValue("UserPrincipalName", "LastnameF@xxxx.com");
                        sessionObject.PutValue("UID_ADSDomain", "df6589c9 - bebd - 4de0 - a738 - 3c3b86a61379");
                        sessionObject.PutValue("UID_ADSContainer", "701caef5 - 1bd9 - 4683 - aa33 - cfcf83084cb4");
                        sessionObject.PutValue("cn", "Lastname, F(Firstname)");
    
                        Uow.Commit();
    
                        //RUN TEST
                        //ASSERT
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                    finally
                    {
                        try
                        {
                            sessionObject.MarkForDeletionWithoutDelay();
                            sessionObject.Save(Session);
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    }
                }
            }
        }
    }

  • You may wanna take a look at the Unit-Test samples that are provided in the SDK section of the product starting with version 8.1. (Modules\QBM\dvd\AddOn\SDK\UnitTestSamples)

  • Hi Markus,

    Thanks for responding. Barry Jackson assisted me on this issue and we found out that another test that is creating objects in the DialogConfigParam table contained some attributes that should not be set by the unittest (.PutValue) and resulted in a compile of the DB.

    After removing these attributes and let let OI determine these itself the problem was solved and we no longer needed to compile the DB after that.