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"); }
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); }
public void TestGetScheduleItemParentCopy_Accuracy() { HermesScheduleItem parent = AccuracyTestsHelper.CreateHermesScheduleItem(); instance.SaveActivityGroup(parent.Activity.ActivityType.ActivityGroup); instance.SaveActivityType(parent.Activity.ActivityType); instance.SaveActivity(parent.Activity); instance.SaveScheduleItemRequestStatus(parent.ScheduleItemRequestStatus); instance.SaveScheduleItemStatus(parent.ScheduleItemStatus); instance.SaveScheduleItem(parent); HermesScheduleItem editCopy = AccuracyTestsHelper.CreateHermesScheduleItem(); instance.SaveActivityGroup(editCopy.Activity.ActivityType.ActivityGroup); instance.SaveActivityType(editCopy.Activity.ActivityType); instance.SaveActivity(editCopy.Activity); instance.SaveScheduleItemRequestStatus(editCopy.ScheduleItemRequestStatus); instance.SaveScheduleItemStatus(editCopy.ScheduleItemStatus); instance.SaveScheduleItem(editCopy); instance.CreateScheduleItemPublishEditCopyRelationship(parent, editCopy); // Verify HermesScheduleItem dbParent = instance.GetScheduleItemParentCopy(editCopy); AccuracyTestsHelper.VerifyHermesScheduleItem(parent, dbParent); }
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"); }
public void Demo2() { HermesScheduleItem parent = client.GetScheduleItem(new Guid("66666666666666666666666666666666").ToString()); HermesScheduleItem editCopy = client.GetScheduleItem(new Guid("6666666666666666666666666666666A").ToString()); //Create relation client.CreateScheduleItemPublishEditCopyRelationship(parent, editCopy); //Create edit copy HermesScheduleItem newEditCopy = client.CreateScheduleItemEditCopy(parent); //Get parent parent = client.GetScheduleItemParentCopy(editCopy); //Get edit copy editCopy = client.GetScheduleItemEditCopy(parent); //Publish item client.PublishScheduleItem(editCopy); //Delete relation client.DeleteScheduleItemPublishEditCopyRelationship(editCopy); }
public void TestGetScheduleItem_Accuracy2() { HermesScheduleItem first = AccuracyTestsHelper.CreateHermesScheduleItem(); // Verify HermesScheduleItem second = instance.GetScheduleItem(first.Id); Assert.IsNull(second); }
public void TestGetScheduleItem_Accuracy1() { HermesScheduleItem first = AccuracyTestsHelper.CreateHermesScheduleItem(); instance.SaveActivityGroup(first.Activity.ActivityType.ActivityGroup); instance.SaveActivityType(first.Activity.ActivityType); instance.SaveActivity(first.Activity); instance.SaveScheduleItemRequestStatus(first.ScheduleItemRequestStatus); instance.SaveScheduleItemStatus(first.ScheduleItemStatus); instance.SaveScheduleItem(first); // Verify HermesScheduleItem second = instance.GetScheduleItem(first.Id); AccuracyTestsHelper.VerifyHermesScheduleItem(first, second); }
public void TestScheduleItem() { DateTime start = DateTime.Now; HermesScheduleItem item = CreateScheduleItem(); for (int i = 1; i <= ITERATION; i++) { item.LastModifiedBy = "test" + i; provider.SaveScheduleItem(item); HermesScheduleItem result = provider.GetScheduleItem(item.Id); Assert.AreEqual(item.LastModifiedBy, result.LastModifiedBy); provider.DeleteScheduleItem(item.Id); Assert.IsNull(provider.GetScheduleItem(item.Id)); } Console.WriteLine("ScheduleItem run {0} times, taking {1}ms.", ITERATION, (DateTime.Now - start).TotalMilliseconds.ToString("n")); }
/// <summary> /// Validates HermesScheduleItem. /// </summary> /// <param name="first">The first entity.</param> /// <param name="second">>The second entity.</param> internal static void VerifyHermesScheduleItem(HermesScheduleItem first, HermesScheduleItem second) { 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.Duration, second.Duration, "Duration is wrong."); Assert.AreEqual(first.ExceptionFlag, second.ExceptionFlag, "ExceptionFlag is wrong."); Assert.AreEqual(first.ExpirationDate.Date, second.ExpirationDate.Date, "LastModifiedDate is wrong."); Assert.AreEqual(first.Version, second.Version, "Version is wrong."); Assert.AreEqual(first.WorkDate.Date, second.WorkDate.Date, "WorkDate is wrong."); Assert.AreEqual(first.WorkDayAmount, second.WorkDayAmount, "WorkDayAmount is wrong."); Assert.AreEqual(first.Note.Id, second.Note.Id, "Note.Id is wrong."); VerifyHermesActivity(first.Activity, second.Activity); VerifyHermesScheduleItemRequestStatus(first.ScheduleItemRequestStatus, second.ScheduleItemRequestStatus); VerifyHermesScheduleItemStatus(first.ScheduleItemStatus, second.ScheduleItemStatus); }
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"); }
/// <summary> /// Creates HermesScheduleItem. /// </summary> internal static HermesScheduleItem CreateHermesScheduleItem() { HermesScheduleItem entity = new HermesScheduleItem(); entity.Activity = CreateHermesActivity(); entity.Duration = 99; entity.ExceptionFlag = 'Y'; entity.ExpirationDate = DateTime.Now; entity.Id = Guid.NewGuid().ToString(); entity.LastModifiedBy = "zaixiang"; entity.LastModifiedDate = DateTime.Now; entity.ScheduleItemRequestStatus = CreateHermesScheduleItemRequestStatus(); entity.ScheduleItemStatus = CreateHermesScheduleItemStatus(); entity.Version = 2; entity.WorkDate = DateTime.Now; entity.WorkDayAmount = 87; entity.Note = new HermesGenericNote(); entity.Note.Id = Guid.NewGuid().ToString(); return(entity); }
/// <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"); }
/// <summary> /// Create an instance of <see cref="HermesScheduleItem"/>. /// </summary> /// <returns>The created HermesScheduleItem instance.</returns> public static HermesScheduleItem CreateScheduleItem() { HermesScheduleItem item = new HermesScheduleItem(); item.Activity = CreateActivity(); item.Duration = 11.1M; item.LastModifiedBy = "failureTester"; item.LastModifiedDate = DateTime.UtcNow; item.Note = new HermesGenericNote(); item.Note.Id = Guid.NewGuid().ToString("N"); item.ExceptionFlag = 'E'; item.ExpirationDate = DateTime.UtcNow; item.WorkDate = DateTime.UtcNow; item.ScheduleItemRequestStatus = CreateRequestStatus(); item.ScheduleItemStatus = CreateItemStatus(); item.Version = 1; item.WorkDayAmount = 6.8M; return(item); }
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"); }
public void TestDeleteScheduleItem_Accuracy() { HermesScheduleItem first = AccuracyTestsHelper.CreateHermesScheduleItem(); instance.SaveActivityGroup(first.Activity.ActivityType.ActivityGroup); instance.SaveActivityType(first.Activity.ActivityType); instance.SaveActivity(first.Activity); instance.SaveScheduleItemRequestStatus(first.ScheduleItemRequestStatus); instance.SaveScheduleItemStatus(first.ScheduleItemStatus); instance.SaveScheduleItem(first); // Verify HermesScheduleItem second = instance.GetScheduleItem(first.Id); Assert.IsNotNull(second, "SaveScheduleItem is wrong."); instance.DeleteScheduleItem(first.Id); // Verify second = instance.GetScheduleItem(first.Id); Assert.IsNull(second, "DeleteScheduleItem is wrong."); }
/// <summary> /// Create the HermesScheduleItem for the test /// </summary> /// <returns>the instance of the HermesScheduleItem</returns> private HermesScheduleItem CreateScheduleItem() { HermesScheduleItem hsi = new HermesScheduleItem(); hsi.Id = Guid.NewGuid().ToString("N"); hsi.Activity = activity; hsi.Duration = new decimal(456.6); hsi.ExceptionFlag = 'N'; hsi.ExpirationDate = new DateTime(2005, 5, 23); hsi.LastModifiedBy = "abc"; hsi.LastModifiedDate = new DateTime(2003, 12, 1); HermesGenericNote note = new HermesGenericNote(); note.Id = Guid.NewGuid().ToString("n"); hsi.Note = note; hsi.ScheduleItemRequestStatus = requestStatus; hsi.ScheduleItemStatus = itemStatus; hsi.Version = 2; hsi.WorkDate = new DateTime(2004, 4, 12); hsi.WorkDayAmount = new Decimal(867.23); return(hsi); }
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); }
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()); }