예제 #1
0
        public void BenchmarkDeleteScheduleItems()
        {
            HermesActivityGroup activityGroup = client.CreateActivityGroup("AG1");
            HermesActivityType  activityType  = client.CreateActivityType("AT1", activityGroup);
            HermesActivity      activity      = client.CreateActivity("Test", activityType);

            HermesScheduleItem[] items = new HermesScheduleItem[StressTestsHelper.Iteration];

            for (int i = 0; i < StressTestsHelper.Iteration; i++)
            {
                // Create the item
                items[i] = client.CreateScheduleItem(DateTime.Today, activity);
            }

            StressTestsHelper.Start();
            for (int i = 0; i < StressTestsHelper.Iteration; i++)
            {
                IList <string> ids = new List <string>();
                ids.Add(items[i].Id);

                // Delete the items.
                client.DeleteScheduleItems(ids);
            }
            StressTestsHelper.Stop("DeleteScheduleItems");
        }
예제 #2
0
        public void TestGetActivity_Accuracy2()
        {
            HermesActivity first  = AccuracyTestsHelper.CreateHermesActivity();
            HermesActivity second = instance.GetActivity(first.Id);

            Assert.IsNull(second);
        }
예제 #3
0
        public void SetUp()
        {
            cm.Clear(false);
            cm.LoadFile(CONF);
            cm.LoadFile("../../test_files/stress/ConnectionFactory.xml");

            string name =
                cm.GetValue("HermesNS.TC.Services.ScheduleItem.Persistence.HermesScheduleItemPersistenceProvider",
                            "connectionName");

            provider = new HermesScheduleItemPersistenceProvider(name, new HermesScheduleItemPersistenceHelper());
            group    = CreateActivityGroup();

            provider.SaveActivityGroup(group);

            activityType = CreateActivityType();
            provider.SaveActivityType(activityType);
            activity = CreateActivity();
            provider.SaveActivity(activity);

            itemStatus = CreateScheduleItemStatus();
            provider.SaveScheduleItemStatus(itemStatus);
            requestStatus = CreateScheduleItemRequestStatus();
            provider.SaveScheduleItemRequestStatus(requestStatus);
            scheduleItem = CreateScheduleItem();
            provider.SaveScheduleItem(scheduleItem);
        }
예제 #4
0
        public void BenchmarkSaveScheduleItems()
        {
            HermesActivityGroup activityGroup = client.CreateActivityGroup("AG1");
            HermesActivityType  activityType  = client.CreateActivityType("AT1", activityGroup);
            HermesActivity      activity      = client.CreateActivity("Test", activityType);

            // Create the item
            HermesScheduleItem item = client.CreateScheduleItem(DateTime.Today, activity);

            StressTestsHelper.Start();
            for (int i = 0; i < StressTestsHelper.Iteration; i++)
            {
                item.Duration = i;

                IList <HermesScheduleItem> items = new List <HermesScheduleItem>();
                items.Add(item);

                // Save the item.
                IList <HermesScheduleItem> result = client.SaveScheduleItems(items);

                // Verify the result.
                Assert.IsNotNull(result, "Should not be null.");
            }
            StressTestsHelper.Stop("SaveScheduleItems");
        }
예제 #5
0
        public void BenchmarkCreateActivity()
        {
            HermesActivityGroup activityGroup = client.CreateActivityGroup("AG1");
            HermesActivityType  activityType  = client.CreateActivityType("AT1", activityGroup);

            StressTestsHelper.Start();
            for (int i = 0; i < StressTestsHelper.Iteration; i++)
            {
                HermesActivity activity = client.CreateActivity("Test", activityType);
                Assert.IsNotNull(activity, "activity should have been created.");
            }
            StressTestsHelper.Stop("CreateActivity");
        }
예제 #6
0
        public void TestGetAllActivities_Accuracy2()
        {
            HermesActivity first = AccuracyTestsHelper.CreateHermesActivity();

            instance.SaveActivityGroup(first.ActivityType.ActivityGroup);
            instance.SaveActivityType(first.ActivityType);
            instance.SaveActivity(first);

            // Verify
            IList <HermesActivity> result = instance.GetAllActivities(false);

            Assert.AreEqual(0, result.Count, "GetAllActivities is wrong.");
        }
예제 #7
0
        public void TestGetActivity_Accuracy1()
        {
            HermesActivity first = AccuracyTestsHelper.CreateHermesActivity();

            instance.SaveActivityGroup(first.ActivityType.ActivityGroup);
            instance.SaveActivityType(first.ActivityType);
            instance.SaveActivity(first);

            // Verify
            HermesActivity second = instance.GetActivity(first.Id);

            AccuracyTestsHelper.VerifyHermesActivity(first, second);
        }
예제 #8
0
 /// <summary>
 /// Validates HermesActivity.
 /// </summary>
 /// <param name="first">The first entity.</param>
 /// <param name="second">>The second entity.</param>
 internal static void VerifyHermesActivity(HermesActivity first, HermesActivity second)
 {
     Assert.AreEqual(first.Abbreviation, second.Abbreviation, "Abbreviation is wrong.");
     Assert.AreEqual(first.DefaultDuration, second.DefaultDuration, "DefaultDuration is wrong.");
     Assert.AreEqual(first.DefaultExpireDays, second.DefaultExpireDays, "DefaultExpireDays is wrong.");
     Assert.AreEqual(first.DefaultStartTime, second.DefaultStartTime, "DefaultStartTime is wrong.");
     Assert.AreEqual(first.Enabled, second.Enabled, "Enabled is wrong.");
     Assert.AreEqual(first.ExclusiveFlag, second.ExclusiveFlag, "ExclusiveFlag is wrong.");
     Assert.AreEqual(first.Id, second.Id, "Id is wrong.");
     Assert.AreEqual(first.LastModifiedBy, second.LastModifiedBy, "LastModifiedBy is wrong.");
     Assert.AreEqual(first.LastModifiedDate.Date, second.LastModifiedDate.Date, "LastModifiedDate is wrong.");
     Assert.AreEqual(first.Name, second.Name, "Name is wrong.");
     Assert.AreEqual(first.WorkDayAmount, second.WorkDayAmount, "WorkDayAmount is wrong.");
     VerifyHermesActivityType(first.ActivityType, second.ActivityType);
 }
예제 #9
0
        public void TestActivity()
        {
            DateTime       start          = DateTime.Now;
            HermesActivity hermesActivity = activity;

            for (int i = 1; i <= ITERATION; i++)
            {
                hermesActivity.LastModifiedBy = "test" + i;
                provider.SaveActivity(hermesActivity);
                HermesActivity result = provider.GetActivity(hermesActivity.Id);
                Assert.AreEqual(hermesActivity.LastModifiedBy, result.LastModifiedBy);
                IList <HermesActivity> list = provider.GetAllActivities(true);
            }
            Console.WriteLine("Test Activity run {0} times, taking {1}ms.", ITERATION,
                              (DateTime.Now - start).TotalMilliseconds.ToString("n"));
        }
예제 #10
0
        public void BenchmarkDeleteActivity()
        {
            HermesActivityGroup activityGroup = client.CreateActivityGroup("AG1");
            HermesActivityType  activityType  = client.CreateActivityType("AT1", activityGroup);

            HermesActivity[] activities = new HermesActivity[StressTestsHelper.Iteration];
            for (int i = 0; i < StressTestsHelper.Iteration; i++)
            {
                activities[i] = client.CreateActivity("Test", activityType);
            }

            StressTestsHelper.Start();
            for (int i = 0; i < StressTestsHelper.Iteration; i++)
            {
                client.DeleteActivity(activities[i].Id);
            }
            StressTestsHelper.Stop("DeleteActivity");
        }
예제 #11
0
        /// <summary>
        /// Creates HermesActivity.
        /// </summary>
        internal static HermesActivity CreateHermesActivity()
        {
            HermesActivity entity = new HermesActivity();

            entity.Abbreviation      = "Abbreviation 1";
            entity.Id                = Guid.NewGuid().ToString();
            entity.LastModifiedBy    = "zaixiang";
            entity.LastModifiedDate  = DateTime.Now;
            entity.Name              = "HermesActivityType";
            entity.ActivityType      = CreateHermesActivityType();
            entity.DefaultDuration   = 100;
            entity.DefaultExpireDays = 1001;
            entity.DefaultStartTime  = 100;
            entity.Enabled           = false;
            entity.ExclusiveFlag     = true;
            entity.WorkDayAmount     = 9;
            return(entity);
        }
예제 #12
0
        public void TestDeleteActivity_Accuracy()
        {
            HermesActivity first = AccuracyTestsHelper.CreateHermesActivity();

            instance.SaveActivityGroup(first.ActivityType.ActivityGroup);
            instance.SaveActivityType(first.ActivityType);
            instance.SaveActivity(first);

            // Verify
            HermesActivity second = instance.GetActivity(first.Id);

            Assert.IsNotNull(second, "SaveActivity is wrong.");

            instance.DeleteActivity(first.Id);

            // Verify
            second = instance.GetActivity(first.Id);
            Assert.IsNull(second, "DeleteActivity is wrong.");
        }
예제 #13
0
        public void BenchmarkCreateScheduleItem()
        {
            HermesActivityGroup activityGroup = client.CreateActivityGroup("AG1");
            HermesActivityType  activityType  = client.CreateActivityType("AT1", activityGroup);
            HermesActivity      activity      = client.CreateActivity("Test", activityType);

            StressTestsHelper.Start();
            for (int i = 0; i < StressTestsHelper.Iteration; i++)
            {
                // Create the item
                HermesScheduleItem item = client.CreateScheduleItem(DateTime.Today, activity);

                // Verify the result.
                HermesScheduleItem result = client.GetScheduleItem(item.Id);

                Assert.IsNotNull(result, "HermesScheduleItem gotten should not be null.");
            }
            StressTestsHelper.Stop("CreateScheduleItem");
        }
예제 #14
0
        /// <summary>
        /// Create an instance of <see cref="HermesActivity"/>.
        /// </summary>
        /// <returns>The created HermesActivity instance.</returns>
        public static HermesActivity CreateActivity()
        {
            HermesActivity activit = new HermesActivity();

            activit.Abbreviation     = "DR";
            activit.Name             = "Digital Run";
            activit.ExclusiveFlag    = true;
            activit.LastModifiedBy   = "failureTester";
            activit.LastModifiedDate = DateTime.UtcNow;
            activit.ActivityType     = CreateType();

            activit.DefaultDuration   = 11.2M;
            activit.DefaultExpireDays = 100;
            activit.DefaultStartTime  = 100;
            activit.Enabled           = true;

            activit.WorkDayAmount = 100;

            return(activit);
        }
예제 #15
0
        public void BenchmarkSaveActivity()
        {
            HermesActivityGroup activityGroup = client.CreateActivityGroup("AG1");
            HermesActivityType  activityType  = client.CreateActivityType("AT1", activityGroup);

            HermesActivity[] activities = new HermesActivity[StressTestsHelper.Iteration];
            for (int i = 0; i < StressTestsHelper.Iteration; i++)
            {
                activities[i] = client.CreateActivity("Test" + i, activityType);
                activities[i].Abbreviation = "abbr" + i;
                activities[i].ActivityType = activityType;
            }

            StressTestsHelper.Start();
            for (int i = 0; i < StressTestsHelper.Iteration; i++)
            {
                HermesActivity activity = client.SaveActivity(activities[i]);
                Assert.IsNotNull(activity, "Should not be null.");
            }
            StressTestsHelper.Stop("SaveActivity");
        }
예제 #16
0
        /// <summary>
        /// Creates entity instances to be used for the tests.
        /// </summary>
        private void CreateReferenceEntities()
        {
            // Get an activity type to be used in tests
            refHermesActivityType = client.GetActivityType("22222222222222222222222222222222");

            // Get an activity group to be used in tests
            refHermesActivityGroup = client.GetActivityGroup("11111111111111111111111111111111");

            // Get an activity to be used in tests
            refHermesActivity = client.GetActivity("33333333333333333333333333333333");

            // Get an activity to be used in tests
            refHermesScheduleItemStatus = client.GetScheduleItemStatus("44444444444444444444444444444444");

            // Get an activity to be used in tests
            refHermesScheduleItemRequestStatus =
                client.GetScheduleItemRequestStatus("55555555555555555555555555555555");

            // Get an activity to be used in tests
            refHermesScheduleItem = client.GetScheduleItem("66666666666666666666666666666666");
        }
예제 #17
0
        public void BenchmarkGetScheduleItemEditCopy()
        {
            HermesActivityGroup activityGroup = client.CreateActivityGroup("AG1");
            HermesActivityType  activityType  = client.CreateActivityType("AT1", activityGroup);
            HermesActivity      activity      = client.CreateActivity("Test", activityType);

            HermesScheduleItem[] items  = new HermesScheduleItem[StressTestsHelper.Iteration];
            HermesScheduleItem   parent = client.CreateScheduleItem(DateTime.Today, activity);

            for (int i = 0; i < StressTestsHelper.Iteration; i++)
            {
                // Create the item
                items[i] = client.CreateScheduleItemEditCopy(parent);
            }

            StressTestsHelper.Start();
            for (int i = 0; i < StressTestsHelper.Iteration; i++)
            {
                client.GetScheduleItemEditCopy(parent);
            }
            StressTestsHelper.Stop("GetScheduleItemEditCopy");
        }
예제 #18
0
        /// <summary>
        /// Create the CreateActivity for the test
        /// </summary>
        /// <returns>the instance of the CreateActivity</returns>
        private HermesActivity CreateActivity()
        {
            HermesActivity activity = new HermesActivity();

            activity.Id = new Guid().ToString();

            activity.Abbreviation      = "ACT";
            activity.ActivityType      = activityType;
            activity.DefaultDuration   = new decimal(456.45);
            activity.DefaultExpireDays = 123;

            //Changed by kurtrips
            //Changed from date to int as this property is supposed
            //to be an int denoting the number of seconds from 2001/1/1
            activity.DefaultStartTime = 300;

            activity.Enabled          = true;
            activity.ExclusiveFlag    = true;
            activity.LastModifiedBy   = "ACTuser";
            activity.LastModifiedDate = DateTime.Now;
            activity.Name             = "CoolAndReallyNiceActivity";
            activity.WorkDayAmount    = 345;
            return(activity);
        }
예제 #19
0
파일: Demo.cs 프로젝트: kurtrips/tc
        public void Demo1()
        {
            //Get existing HermesActivity
            HermesActivity refHermesActivity =
                client.GetActivity(new Guid("33333333333333333333333333333333").ToString());

            //Create 2 new schedule items
            HermesScheduleItem schedItem1 = client.CreateScheduleItem(DateTime.Today, refHermesActivity);
            HermesScheduleItem schedItem2 = client.CreateScheduleItem(DateTime.Today, refHermesActivity);

            //Make some changes to the above 2
            schedItem1.Duration       = new decimal(34.67);
            schedItem1.ExceptionFlag  = 'Y';
            schedItem1.ExpirationDate = DateTime.Today.AddDays(24);
            HermesGenericNote note = new HermesGenericNote();

            note.Description = "NewNoteDesc";
            schedItem1.Note  = note;
            schedItem1.ScheduleItemRequestStatus =
                client.GetScheduleItemRequestStatus(new Guid("55555555555555555555555555555555").ToString());
            schedItem1.ScheduleItemStatus =
                client.GetScheduleItemStatus(new Guid("44444444444444444444444444444444").ToString());
            schedItem1.Version       = 2;
            schedItem1.WorkDate      = DateTime.Today.AddDays(1);
            schedItem1.WorkDayAmount = new decimal(10.45);

            schedItem2.Duration       = new decimal(34.67);
            schedItem2.ExceptionFlag  = 'Y';
            schedItem2.ExpirationDate = DateTime.Today.AddDays(24);
            note             = new HermesGenericNote();
            note.Description = "NewNoteDesc";
            schedItem2.Note  = note;
            schedItem2.ScheduleItemRequestStatus =
                client.GetScheduleItemRequestStatus(new Guid("55555555555555555555555555555555").ToString());
            schedItem2.ScheduleItemStatus =
                client.GetScheduleItemStatus(new Guid("44444444444444444444444444444444").ToString());
            schedItem2.Version       = 2;
            schedItem2.WorkDate      = DateTime.Today.AddDays(1);
            schedItem2.WorkDayAmount = new decimal(10.45);

            //We can save them individually
            client.SaveScheduleItem(schedItem1);
            client.SaveScheduleItem(schedItem2);

            //Or we can save them in one go
            List <HermesScheduleItem> schedItems = new List <HermesScheduleItem>();

            schedItems.Add(schedItem1);
            schedItems.Add(schedItem2);
            client.SaveScheduleItems(schedItems);

            //Get the schedule items
            schedItem1 = client.GetScheduleItem(schedItem1.Id);
            schedItem2 = client.GetScheduleItem(schedItem2.Id);

            //Although getting many schedule items in one go is not supported but it is supported for other types
            //Get all activities
            IList <HermesActivity> activities1 = client.GetAllActivities(true);
            //Get all activities which are enabled
            IList <HermesActivity> activities2 = client.GetAllActivities(false);
            //Get all activity groups
            IList <HermesActivityGroup> activityGroups = client.GetAllActivityGroups();

            //Delete them in one go
            List <string> ids = new List <string>();

            ids.Add(schedItem1.Id);
            ids.Add(schedItem2.Id);
            client.DeleteScheduleItems(ids);

            //Delete a single schedule item
            client.DeleteScheduleItem(new Guid("66666666666666666666666666666666").ToString());
        }
예제 #20
0
파일: Demo.cs 프로젝트: kurtrips/tc
        public void Demo()
        {
            HermesScheduleItemPersistenceProvider hsipp = new HermesScheduleItemPersistenceProvider();

            ///////////////////INSERT UPDATE GET DELETE/////////////////////////////
            // Create an activity group
            HermesActivityGroup hag = new HermesActivityGroup();

            hag.Id               = new Guid("1234567890ABCDEF1234567890ABCDEF").ToString();
            hag.Abbreviation     = "HAG1";
            hag.Name             = "HermesActivityGroup1";
            hag.LastModifiedBy   = "hagUser";
            hag.LastModifiedDate = new DateTime(2007, 7, 7);
            //Save it into database
            hsipp.SaveActivityGroup(hag);
            //Get it from database
            HermesActivityGroup getFromDb = hsipp.GetActivityGroup("1234567890ABCDEF1234567890ABCDEF");

            //Delete it from database
            hsipp.DeleteActivityGroup("1234567890ABCDEF1234567890ABCDEF");

            //Create an activity type
            HermesActivityType hat = new HermesActivityType();

            hat.Id               = new Guid("34563456345634563456345634563456").ToString();
            hat.Abbreviation     = "HAT1";
            hat.Name             = "HermesActivityType1";
            hat.LastModifiedBy   = "hatUser";
            hat.LastModifiedDate = new DateTime(2007, 11, 7);
            hat.ActivityGroup    = hsipp.GetActivityGroup("11111111111111111111111111111111");
            //Save it into database
            hsipp.SaveActivityType(hat);
            //Get it from database
            HermesActivityType getFromDb2 = hsipp.GetActivityType("34563456345634563456345634563456");

            //Delete it from database
            hsipp.DeleteActivityType("34563456345634563456345634563456");

            //Create an activity
            HermesActivity activity = new HermesActivity();

            activity.Id                = new Guid("99887766998877669988776699887766").ToString();
            activity.Abbreviation      = "ACT";
            activity.ActivityType      = hsipp.GetActivityType("22222222222222222222222222222222");
            activity.DefaultDuration   = new decimal(33.45);
            activity.DefaultExpireDays = 666;
            activity.DefaultStartTime  = 432;
            activity.Enabled           = true;
            activity.ExclusiveFlag     = true;
            activity.LastModifiedBy    = "ACTuser";
            activity.LastModifiedDate  = new DateTime(2007, 8, 8);
            activity.Name              = "CoolAndReallyNiceActivity";
            activity.WorkDayAmount     = 9966;
            //Save it into database
            hsipp.SaveActivity(activity);
            //Get it from database
            HermesActivity getFromDb3 = hsipp.GetActivity("99887766998877669988776699887766");

            //Delete it from database
            hsipp.DeleteActivity("99887766998877669988776699887766");

            //Create a ScheduleItem and save
            HermesScheduleItem hsiParent = new HermesScheduleItem();

            hsiParent.Id               = new Guid("19081908190819081908190819081908").ToString();
            hsiParent.Activity         = hsipp.GetActivity("33333333333333333333333333333333");
            hsiParent.Duration         = new decimal(546.89);
            hsiParent.ExceptionFlag    = 'Y';
            hsiParent.ExpirationDate   = new DateTime(2005, 12, 23);
            hsiParent.LastModifiedBy   = "ivern";
            hsiParent.LastModifiedDate = new DateTime(2007, 12, 1);
            HermesGenericNote note = new HermesGenericNote();

            note.Id        = new Guid("12340987123409871234098712340987").ToString();
            hsiParent.Note = note;
            hsiParent.ScheduleItemRequestStatus = hsipp.GetScheduleItemRequestStatus("55555555555555555555555555555555");
            hsiParent.ScheduleItemStatus        = hsipp.GetScheduleItemStatus("44444444444444444444444444444444");
            hsiParent.Version       = 1;
            hsiParent.WorkDate      = new DateTime(2004, 12, 12);
            hsiParent.WorkDayAmount = new Decimal(86787.23);
            hsipp.SaveScheduleItem(hsiParent);

            //Create another ScheduleItem and save
            HermesScheduleItem hsiEdit = new HermesScheduleItem();

            hsiEdit.Id               = new Guid("23451987234519872345198723451987").ToString();
            hsiEdit.Activity         = hsipp.GetActivity("33333333333333333333333333333333");
            hsiEdit.Duration         = new decimal(546.89);
            hsiEdit.ExceptionFlag    = 'Y';
            hsiEdit.ExpirationDate   = new DateTime(2005, 12, 23);
            hsiEdit.LastModifiedBy   = "ivern";
            hsiEdit.LastModifiedDate = new DateTime(2007, 12, 1);
            HermesGenericNote note2 = new HermesGenericNote();

            note2.Id     = new Guid("12340987123409871234098712340987").ToString();
            hsiEdit.Note = note2;
            hsiEdit.ScheduleItemRequestStatus = hsipp.GetScheduleItemRequestStatus("55555555555555555555555555555555");
            hsiEdit.ScheduleItemStatus        = hsipp.GetScheduleItemStatus("44444444444444444444444444444444");
            hsiEdit.Version       = 1;
            hsiEdit.WorkDate      = new DateTime(2004, 12, 12);
            hsiEdit.WorkDayAmount = new Decimal(86787.23);
            hsipp.SaveScheduleItem(hsiEdit);

            //....and so on for other properties



            /////////////////GET ALL ENTITIES//////////
            IList <HermesScheduleItemRequestStatus> reqStats = hsipp.GetAllScheduleItemRequestStatuses();
            IList <HermesScheduleItemStatus>        statuses = hsipp.GetAllScheduleItemStatuses();
            IList <HermesActivity> items = hsipp.GetAllActivities(false);

            //....and so on for other properties



            //////////////MANAGE SCHEDULE ITEMS RELATIONS////////////////
            hsipp.CreateScheduleItemPublishEditCopyRelationship(hsiParent, hsiEdit);
            hsipp.GetScheduleItemEditCopy(hsiParent);
            hsipp.GetScheduleItemParentCopy(hsiEdit);
            hsipp.DeleteScheduleItemPublishEditCopyRelationship(hsiEdit);
        }