public LocationsTreeViewModel(ObservableCollection<Location> locations)
 {
     Locations = new ObservableList<LocationNode>();
     foreach (var location in locations) Locations.Add(new LocationNode(location));
     locations.CollectionChanged += (s, e) =>
     {
         switch (e.Action)
         {
             case NotifyCollectionChangedAction.Add:
                 foreach (Location location in e.NewItems) Locations.Add(new LocationNode(location));
                 break;
             case NotifyCollectionChangedAction.Remove:
                 foreach (Location location in e.OldItems)
                 {
                     var item = Locations.FirstOrDefault(l => l.Location.Guid == location.Guid);
                     if (item != null) Locations.Remove(item);
                 }
                 break;
             case NotifyCollectionChangedAction.Replace:
                 foreach (Location location in e.OldItems)
                 {
                     var item = Locations.FirstOrDefault(l => l.Location.Guid == location.Guid);
                     if (item != null) Locations.Remove(item);
                 }
                 foreach (Location location in e.NewItems) Locations.Add(new LocationNode(location));
                 break;
             case NotifyCollectionChangedAction.Reset:
                 Locations.Clear();
                 foreach (Location location in e.NewItems) Locations.Add(new LocationNode(location));
                 break;
         }
     };
     LocationsTreeViewSource = new CollectionViewSource { Source = Locations };
     LocationsTreeViewSource.SortDescriptions.Add(new SortDescription("Location.Name", ListSortDirection.Ascending));
 }
Exemplo n.º 2
0
		void Click()
		{
			if (click==0)
			{
				items = listView.DataSource;

				items.Add("Added from script 0");
				items.Add("Added from script 1");
				items.Add("Added from script 2");

				items.Remove("Caster");

				click += 1;
				return ;
			}
			if (click==1)
			{
				items.Clear();
				
				click += 1;
				return ;
			}
			if (click==2)
			{
				items.Add("test");
				
				click += 1;
				return ;
			}
		}
 public void AddItemAfterSubscribing()
 {
     var source = new ObservableList<ObservableList<string>>();
     ImmutableList<string> result = ImmutableList<string>.Empty;
     source.ToLiveLinq()
         .SelectMany((list, _) => list.ToLiveLinq())
         .ToObservableEnumerable().Subscribe(value => result = value);
     source.Add(new ObservableList<string>());
     source.Add(new ObservableList<string>());
     result.Should().BeEmpty();
 }
 public void DisposeSubscription_ThenRemoveItem()
 {
     var source = new ObservableList<ObservableList<string>>();
     ImmutableList<string> result = ImmutableList<string>.Empty;
     var subscription = source.ToLiveLinq()
         .SelectMany((list, _) => list.ToLiveLinq())
         .ToObservableEnumerable().Subscribe(value => result = value);
     source.Add(new ObservableList<string>());
     source.Add(new ObservableList<string>());
     source[0].Add("a");
     source[1].Add("c");
     subscription.Dispose();
     source.RemoveAt(1);
     result.Should().ContainInOrder("a", "c");
 }
Exemplo n.º 5
0
        public void CanAccumulate()
        {
            var items = new ObservableList<Person>();


            var subscription = items.Changes
                .Subscribe(changes =>
                {
                    Console.WriteLine(changes);
                });


            using (var x = items.SuspendNotifications())
            {
                foreach (var person in _random.Take(20000))
                {
                    items.Add(person);
                }
                items.Clear();
                var result = items.GetChanges();

                items[10] = new Person("Roland", 1);
            }

        }
		ObservableList<TreeNode<ITreeViewSampleItem>> Data2Country(List<TreeViewSampleDataCountry> data)
		{
			var countries = new ObservableList<TreeNode<ITreeViewSampleItem>>();
			data.ForEach(x => countries.Add(Node(new TreeViewSampleItemCountry(x.Name, x.Flag))));

			return countries;
		}
Exemplo n.º 7
0
 public void TestAdd()
 {
     var list = new List<string> { "aaa", "bbb", "ccc" };
     var set = new ObservableList<string>(list);
     bool propertyChangedInvoked = false;
     bool collectionChangedInvoked = false;
     Assert.AreEqual(set.Count, list.Count);
     set.PropertyChanged += (sender, e) =>
     {
         Assert.AreEqual(e.PropertyName, nameof(ObservableList<string>.Count));
         propertyChangedInvoked = true;
     };
     set.CollectionChanged += (sender, e) =>
     {
         Assert.AreEqual(e.Action, NotifyCollectionChangedAction.Add);
         Assert.AreEqual(e.NewStartingIndex, 3);
         Assert.NotNull(e.NewItems);
         Assert.AreEqual(e.NewItems.Count, 1);
         Assert.AreEqual(e.NewItems[0], "ddd");
         collectionChangedInvoked = true;
     };
     set.Add("ddd");
     Assert.AreEqual(set[0], "aaa");
     Assert.AreEqual(set[1], "bbb");
     Assert.AreEqual(set[2], "ccc");
     Assert.AreEqual(set[3], "ddd");
     Assert.True(propertyChangedInvoked);
     Assert.True(collectionChangedInvoked);
 }
 public void AddItem()
 {
   _handle = new EventWaitHandle(false, EventResetMode.ManualReset);
   var test = new ObservableList<string>();
   test.ItemAdded += List_ItemEvent;
   test.Add("myValue");
   Assert.IsTrue(_handle.WaitOne(10));
 }
Exemplo n.º 9
0
    public override void Initialize()
    {
        base.Initialize();

        Playables = new ObservableList<IPlayable>();
        foreach (var t in Resources.FindObjectsOfTypeAll<IPlayable>())
            Playables.Add(t);
    }
 public void TestAddRemoveDispose()
 {
     var sourceList = new ObservableList<string>();
     var targetList = new Collection<string>();
     var syncer1 = new CollectionSyncer<string, string>(sourceList, targetList, (x) => x.ToUpper(), (x) => x.ToUpper(), false);
     var syncer2 = new CollectionSyncer<string, string>(sourceList, targetList, (x) => x.ToLower(), (x) => x.ToLower(), false);
     sourceList.Add("Test1");
     Assert.Equal(2, targetList.Count);
     Assert.True(targetList.Contains("test1"));
     Assert.True(targetList.Contains("TEST1"));
     sourceList.Remove("Test1");
     Assert.Equal(sourceList.Count, targetList.Count);
     Assert.Equal(0, targetList.Count);
     syncer2.Dispose();
     sourceList.Add("Test1");
     Assert.Equal(sourceList.Count, targetList.Count);
 }
Exemplo n.º 11
0
        public void ObservableList_RaisesCollectionResetOnReverse()
        {
            var list  = new ObservableList<Int32>();
            var reset = false;

            list.CollectionReset += (source) =>
            {
                reset = true;
            };
            list.Add(1);
            list.Add(2);
            list.Add(3);
            list.Add(4);
            list.Reverse();

            TheResultingValue(reset).ShouldBe(true);
        }
        public void TestConstruction()
        {
            var badList = new List<string>();
            var sourceList = new ObservableList<string>();
            var targetList = new Collection<string>();
            Assert.Throws<ArgumentNullException>(() => new CollectionSyncer<string, string>(null, targetList, (x) => x, (x) => x, false));
            Assert.Throws<ArgumentNullException>(() => new CollectionSyncer<string, string>(sourceList, null, (x) => x, (x) => x, false));
            Assert.Throws<Exception>(() => new CollectionSyncer<string, string>(badList, targetList, (x) => x, (x) => x, false));

            sourceList.Add("Test1");
            sourceList.Add("Test2");
            var syncer1 = new CollectionSyncer<string, string>(sourceList, targetList, (x) => x, (x) => x, false);
            Assert.Equal(2, sourceList.Count);
            Assert.Equal(0, targetList.Count);

            var syncer2 = new CollectionSyncer<string, string>(sourceList, targetList, (x) => x, (x) => x, true);
            Assert.Equal(sourceList.Count, targetList.Count);
        }
 public void ChangeItem()
 {
   _handle = new EventWaitHandle(false, EventResetMode.ManualReset);
   var test = new ObservableList<string>();
   test.Add("myValue");
   test.ItemChanged += List_ItemEvent;
   test[test.IndexOf("myValue")] = "myNewValue";
   Assert.IsTrue(_handle.WaitOne(10));
 }
Exemplo n.º 14
0
        public void Delegates_AddingNewHandler_ShouldNotPassStringsWithoutFirstCapitalLetter()
        {
            ObservableList<string> capitalLetters = new ObservableList<string>();
            capitalLetters.AddingNew += HandlerMethods.FirstLetterCapitalHandler;

            capitalLetters.Add("Brustwarzen");
            capitalLetters.Add("smellFungus");
            capitalLetters.Add("Mumpsimus");
            capitalLetters.Add("Jackanapes");
            capitalLetters.Add("hocus-Pocus");
            capitalLetters.Add("Fuddy-duddy");
            capitalLetters.Add("Batrachomyomachy");
            capitalLetters.Add("Fard");
            capitalLetters.Add("Handschuh");
            capitalLetters.Add("arschbombe");

            Assert.AreEqual(7, capitalLetters.Count);
        }
Exemplo n.º 15
0
        public void Delegates_AddingNewHandler_ShouldNotPassOddNumbers()
        {
            ObservableList<int> evenNumbers = new ObservableList<int>();
            evenNumbers.AddingNew += HandlerMethods.EvenNumberHandler;

            evenNumbers.Add(0);
            evenNumbers.Add(1);
            evenNumbers.Add(2);
            evenNumbers.Add(3);
            evenNumbers.Add(4);
            evenNumbers.Add(5);
            evenNumbers.Add(6);
            evenNumbers.Add(7);
            evenNumbers.Add(8);
            evenNumbers.Add(9);

            Assert.AreEqual(5, evenNumbers.Count);
        }
        public void When_Add_Then_Action_Add_Raised()
        {
            // Arrange
            var sut = new ObservableList<int>();
            var results = new List<NotifyCollectionChangedEventArgs>();
            var expected = new[]
            {
                new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, 10, 0),
                new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, 99, 1),
            };
            sut.CollectionChanged += (o, e) => results.Add(e);

            // Act
            sut.Add(10);
            sut.Add(99);

            // Assert
            KKAssert.AreEqualByValue(expected, results);
        }
Exemplo n.º 17
0
        public static ObservableList<Filter> CreateFilters(List<string> ids)
        {
            var list = new ObservableList<Filter>();

            foreach (var id in ids)
            {
                list.Add(CreateFilter(id));
            }

            return list;
        }
 public void ChangeCollection()
 {
   _handle = new EventWaitHandle(false, EventResetMode.ManualReset);
   var test = new ObservableList<string>();
   test.Changed += List_Changed;
   test.Add("myValue");
   Assert.IsTrue(_handle.WaitOne(10), "Add() is not recognized as a change");
   _handle.Reset();
   test[0] = "newValue";
   Assert.IsTrue(_handle.WaitOne(10), "this[] is not recognized as a change");
   _handle.Reset();
   test.RemoveAt(0);
   Assert.IsTrue(_handle.WaitOne(10), "RemoveAt() is not recognized as a change");
   _handle.Reset();
   test.Add("myValue");
   Assert.IsTrue(_handle.WaitOne(10), "Add() is not recognized as a change");
   _handle.Reset();
   test.Remove("myValue");
   Assert.IsTrue(_handle.WaitOne(10), "Remove() is not recognized as a change");
 }
        public void event_raised_when_item_is_inserted()
        {
            var testObject = new ObservableList<int>();

            var events = new List<NotifyCollectionChangedEventArgs>();

            testObject.Add(1);
            testObject.Add(2);

            testObject.CollectionChanged += (source, args) => events.Add(args);

            var itemAdded = 3;
            testObject.Insert(1, itemAdded);

            Assert.Equal(1, events.Count);

            var ev = events[0];
            Assert.Equal(NotifyCollectionChangedAction.Add, ev.Action);
            Assert.Equal(itemAdded, ev.NewItems[0]);
            Assert.Equal(1, ev.NewStartingIndex);
        }
Exemplo n.º 20
0
        public void ObservableList_RaisesCollectionItemAdded()
        {
            var list  = new ObservableList<Int32>();
            var added = false;

            list.CollectionItemAdded += (source, index, value) =>
            {
                added = (value == 1234);
            };
            list.Add(1234);

            TheResultingValue(added).ShouldBe(true);
        }
Exemplo n.º 21
0
        public void Add_FiresCollectionChanged()
        {
            var list = new ObservableList<int> { 1, 2 };

            list.CollectionChanged += (sender, args) =>
            {
                Assert.AreEqual(NotifyCollectionChangedAction.Add, args.Action);
                Assert.AreEqual(2, args.NewStartingIndex);
                Assert.IsTrue(new[] { 3 }.SequenceEqual(args.NewItems.Cast<int>()));
            };

            list.Add(3);
        }
Exemplo n.º 22
0
        public void Adding_an_item_to_the_list_raises_property_changed()
        {
            var observable = new ObservableList<string>();
            var propertyChangedRaised = false;
            observable.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "Add") 
                    propertyChangedRaised = true;
            };

            observable.Add("test");

            Assert.IsTrue(propertyChangedRaised);
        }
		ObservableList<TreeNode<ITreeViewSampleItem>> GetData()
		{
			var countries = new ObservableList<TreeNode<ITreeViewSampleItem>>();
			countries.Add(Node(new TreeViewSampleItemContinent("Africa", 54)));
			countries.Add(Node(new TreeViewSampleItemContinent("Antarctica", 12)));
			countries.Add(Node(new TreeViewSampleItemContinent("Asia", 48), Data2Country(dataAsia)));
			countries.Add(Node(new TreeViewSampleItemContinent("Australia", 4)));
			countries.Add(Node(new TreeViewSampleItemContinent("Europe", 50), Data2Country(dataEurope)));
			countries.Add(Node(new TreeViewSampleItemContinent("North America", 23)));
			countries.Add(Node(new TreeViewSampleItemContinent("South America", 12)));

			return countries;
		}
        public void TestEnumAddsDependancy()
        {
            var list = new ObservableList<int>(1, 2, 3, 4, 5, 6);
            var computed = new ComputedObservable<double[]>(() => list.Select(i => Math.Pow(i, 2)).ToArray())
            {
                Name = "ComputedVal"
            };
            CollectionAssert.AreEquivalent(new[] {1.0, 4.0, 9.0, 16.0, 25.0, 36.0}, computed.Value);
            Assert.AreEqual(1, computed.DependencyCount);

            list[1] = 10;
            CollectionAssert.AreEquivalent(new[] {1.0, 100.0, 9.0, 16.0, 25.0, 36.0}, computed.Value);
            list.Add(100);
            CollectionAssert.Contains(computed.Value, 10000.0);
        }
        public void event_raised_when_item_is_removed_by_index()
        {
            var testObject = new ObservableList<int>();

            var events = new List<NotifyCollectionChangedEventArgs>();

            testObject.Add(1);
            testObject.Add(2);
            testObject.Add(3);

            var itemRemoved = 2;

            testObject.CollectionChanged += (source, args) => events.Add(args);

            testObject.RemoveAt(1);

            Assert.Equal(1, events.Count);

            var ev = events[0];
            Assert.Equal(NotifyCollectionChangedAction.Remove, ev.Action);
            Assert.Equal(1, ev.OldItems.Count);
            Assert.Equal(itemRemoved, ev.OldItems[0]);
            Assert.Equal(1, ev.OldStartingIndex);
        }
Exemplo n.º 26
0
        public static ObservableList<Filter> CreateAllFilters()
        {
            var filters = new ObservableList<Filter>();
            var types = typeof(Filter).GetTypeInfo().Assembly.ExportedTypes
                                      .Where(type => type.GetTypeInfo().IsClass &&
                                             type.GetTypeInfo().IsAbstract == false &&
                                             type.GetTypeInfo().IsSubclassOf(typeof(Filter)));

            foreach (var type in types)
            {
                filters.Add((Filter)Activator.CreateInstance(type));
            }

            return filters;
        }
Exemplo n.º 27
0
        public void AddFiresListChangedEvent()
        {
            const string expectedItem = "a string to add";
            var actualItem = "";
            var actualIndex = -1;

            var observableList = new ObservableList<string>();
            observableList.ListChanged += (s, e) =>
                                              {
                                                  actualItem = e.Item;
                                                  actualIndex = e.Index;
                                              };
            observableList.Add(expectedItem);

            Assert.AreEqual(expectedItem, actualItem);
            Assert.AreEqual(0, actualIndex);
            CollectionAssert.AreEqual(new[] { expectedItem }, observableList.ToArray());
        }
Exemplo n.º 28
0
    public override void Initialize()
    {
        base.Initialize();

        var viewpointGroup = GameObject.Find("Viewpoints");
        if (viewpointGroup == null || viewpointGroup.transform.childCount == 0 ||
            viewpointGroup.GetComponentsInChildren<Viewpoint>() == null)
            MenuHeader = "No viewpoints defined";
        else
        {
            Viewpoints = new ObservableList<Viewpoint>();
            // Iterate over childs to preserve order from editor
            for (var i = 0; i < viewpointGroup.transform.childCount; ++i)
            {
                var child = viewpointGroup.transform.GetChild(i);
                var viewpoint = child.gameObject.GetComponent<Viewpoint>();
                if (viewpoint == null) continue;
                Viewpoints.Add(viewpoint);
            }
        }
    }
        public void WhereThenSelect()
        {
            var coll1 = new ObservableList<SelectObservableCollectionViewModel>();
            var result = coll1.ToLiveLinq().Where(nested => nested.Name.Select(val => val.Length > 2).Snapshot())
                .Select(nested => nested.Name.AsObservable()).ToReadOnlyObservableList();
            result.Count.Should().Be(0);

            coll1.Add(new SelectObservableCollectionViewModel(string.Empty));
            result.Count.Should().Be(0);

            coll1[0].Name.Value = "test";
            result.Count.Should().Be(1);
            result[0].Should().Be("test");

            coll1[0].Name.Value = "test2";
            result.Count.Should().Be(1);
            result[0].Should().Be("test2");

            coll1[0].Name.Value = "t";
            result.Count.Should().Be(0);
        }
Exemplo n.º 30
0
    public override void Initialize()
    {
        base.Initialize();

        Objects = new ObservableList<VisibilityStruct>();

        var objectVisibilities = FindObjectsOfType<ObjectVisibility>();
        foreach (var objectVisibility in objectVisibilities)
        {
            objectVisibility.RestoreState();
            if (objectVisibility.Entries == null || objectVisibility.Entries.Length == 0)
                continue;

            var index = 0;
            foreach (var objectVisibilityInfo in objectVisibility.Entries)
            {
                var materialProperties = objectVisibilityInfo.GameObject.GetComponentsInChildren<MaterialProperties>();
                if (materialProperties == null || materialProperties.Length == 0)
                    continue;

                Objects.Add(new VisibilityStruct
                {
                    Name = objectVisibilityInfo.GameObject.name,
                    Opacity = materialProperties[0].Opacity,
                    Enabled = materialProperties[0].Enabled,
                    MatProps = materialProperties
                });
                index++;
            }
        }

        var go = GameObject.Find("Visibilities");
        if (go == null)
            return;
        GoList = go.GetComponentInChildren<GameObjectList>();

        UpdateVisibilities();
    }
        private void CountChanged()
        {
            var count = _countWatcher.Value;

            if (count < 0)
            {
                count = 0;
            }

            if (count > _resultList.Count)
            {
                for (int i = _resultList.Count; i < count; ++i)
                {
                    _resultList.Add(i, _valueWatcher.Value);
                }
            }
            else if (count < _resultList.Count)
            {
                for (int i = _resultList.Count - 1; i >= count; --i)
                {
                    _resultList.Remove(i);
                }
            }
        }
Exemplo n.º 32
0
        public QTPImportPage()
        {
            InitializeComponent();

            //handles the basic display of the UFT Import dialog
            ResultsDataGrid.DataSourceList = new ObservableList <ConvertedCodeLine>();
            SetActivitiesGridView();

            eFilter mFilter = eFilter.AllLines;

            GingerCore.General.FillComboFromEnumObj(FilterComboBox, mFilter);

            InitCommonFunctionMappingUCGrid();

            TargetApplication sTarget = new TargetApplication();

            if (WorkSpace.Instance.Solution != null)
            {
                sTarget.AppName  = WorkSpace.Instance.Solution.MainApplication.ToString();
                sTarget.Selected = true;
                TargetApplicationsList.Add(sTarget);
                mBusinessFlow.TargetApplications = TargetApplicationsList;
            }
        }
Exemplo n.º 33
0
        public void RegisterDebug(DebugDisplaySettings settings)
        {
            DebugManager debugManager = DebugManager.instance;
            List <IDebugDisplaySettingsPanelDisposable> panels = new List <IDebugDisplaySettingsPanelDisposable>();

            debugManager.RegisterData(this);

            m_Settings         = settings;
            m_DisposablePanels = panels;

            Action <IDebugDisplaySettingsData> onExecute = (data) =>
            {
                IDebugDisplaySettingsPanelDisposable disposableSettingsPanel = data.CreatePanel();
                DebugUI.Widget[] panelWidgets = disposableSettingsPanel.Widgets;
                string           panelId      = disposableSettingsPanel.PanelName;
                DebugUI.Panel    panel        = debugManager.GetPanel(panelId, true);
                ObservableList <DebugUI.Widget> panelChildren = panel.children;

                panels.Add(disposableSettingsPanel);
                panelChildren.Add(panelWidgets);
            };

            m_Settings.ForEach(onExecute);
        }
Exemplo n.º 34
0
        private void LoadPluginsActions()
        {
            ObservableList <PluginPackage> plugins        = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <PluginPackage>();
            ObservableList <Act>           PlugInsActions = new ObservableList <Act>();

            foreach (PluginPackage pluginPackage in plugins)
            {
                try
                {
                    ObservableList <StandAloneAction> actions = pluginPackage.GetStandAloneActions();

                    foreach (StandAloneAction SAA in actions)
                    {
                        ActPlugIn act = new ActPlugIn();
                        act.Description = SAA.Description;
                        act.GetOrCreateInputParam(nameof(ActPlugIn.ServiceId), pluginPackage.PluginID);
                        act.GetOrCreateInputParam(nameof(ActPlugIn.GingerActionID), SAA.ID);
                        foreach (var v in SAA.InputValues)
                        {
                            act.InputValues.Add(new ActInputValue()
                            {
                                Param = v.Param
                            });
                        }
                        act.Active = true;
                        PlugInsActions.Add(act);
                    }
                }
                catch (Exception ex)
                {
                    Reporter.ToLog(eLogLevel.ERROR, "Failed to get the Action of the Plugin '" + pluginPackage.PluginID + "'", ex);
                }
            }

            PlugInsActionsGrid.DataSourceList = PlugInsActions;
        }
        public void PopulateFilter()
        {               //****************************************
            var MySeed    = Environment.TickCount;
            var MyRandom  = new Random(MySeed);
            var MyRecords = new ObservableList <int>(1024);
            //****************************************

            var MyView = new ObservableListView <int>(MyRecords, FilterLessThan512);

            for (int Index = 0; Index < 1024; Index++)
            {
                MyRecords.Add(MyRandom.Next(short.MaxValue));
            }

            //****************************************

            var MySortedRecords = MyRecords.Where(FilterLessThan512).ToArray();

            Array.Sort(MySortedRecords);

            CollectionAssert.AreEqual(MySortedRecords, MyView, "Bad Seed was {0}", MySeed);

            Thread.Sleep(1);
        }
Exemplo n.º 36
0
    public override void Init(object args = null)
    {
        var c = args as Character;

        if (c == null)
        {
            originalCharacterRef = CharacterModel.Instance.Characters.MyCharacter;
        }
        else
        {
            originalCharacterRef = c;
        }

        Name = originalCharacterRef.Name;
        var savedAttrs  = originalCharacterRef.Attributes;
        var savedSkills = originalCharacterRef.Skills;

        attributes.Clear();
        skills.Clear();

        // If we haven't saved our character yet, create new data;
        foreach (var attr in savedAttrs)
        {
            var newAttr = new Attribute(this, attr);
            attributes.Add(newAttr);
        }

        foreach (var skill in savedSkills)
        {
            var newSkill = new Attribute(this, skill);
            skills.Add(newSkill);
        }

        Stun   = originalCharacterRef.Stun;
        Damage = originalCharacterRef.Damage;
    }
        private ObservableList <ActReturnValue> ConvertTemplateReturnValues(ObservableList <ActReturnValue> modelReturnValues)
        {
            ObservableList <ActReturnValue> returnValuesList = new ObservableList <ActReturnValue>();

            foreach (ActReturnValue modelRV in modelReturnValues)
            {
                ActReturnValue rv = new ActReturnValue();
                rv.AddedAutomatically = true;
                rv.Guid     = modelRV.Guid;
                rv.Active   = modelRV.Active;
                rv.Param    = modelRV.Param;
                rv.Path     = modelRV.Path;
                rv.Operator = Amdocs.Ginger.Common.Expressions.eOperator.Equals;
                rv.Expected = modelRV.Expected;

                if (!string.IsNullOrEmpty(modelRV.StoreToValue))
                {
                    rv.StoreTo      = ActReturnValue.eStoreTo.ApplicationModelParameter;
                    rv.StoreToValue = modelRV.StoreToValue;
                }
                returnValuesList.Add(rv);
            }
            return(returnValuesList);
        }
Exemplo n.º 38
0
        public ObservableList <ITextEditor> GetTextFileEditors()
        {
            //TODO: cache
            if (!Isloaded)
            {
                LoadInfoFromDLL();
            }

            ObservableList <ITextEditor> textEditors = new ObservableList <ITextEditor>();

            foreach (PluginAssemblyInfo PAI in mAssembliesInfo)
            {
                Assembly assembly = null;
                if (string.IsNullOrEmpty(mPluginPackageInfo.UIDLL))
                {
                    continue;
                }
                string UIDLLFileName = Path.Combine(mFolder, "UI", mPluginPackageInfo.UIDLL);
                if (!File.Exists(UIDLLFileName))
                {
                    throw new Exception("Plugin UI DLL not found: " + UIDLLFileName);
                }
                assembly = Assembly.UnsafeLoadFrom(UIDLLFileName);

                var list = from type in assembly.GetTypes()
                           where typeof(ITextEditor).IsAssignableFrom(type) && type.IsAbstract == false
                           select type;

                foreach (Type t in list)
                {
                    ITextEditor textEditor = (ITextEditor)assembly.CreateInstance(t.FullName); // Activator.CreateInstance(t);
                    textEditors.Add(textEditor);
                }
            }
            return(textEditors);
        }
Exemplo n.º 39
0
        public override Dictionary <string, ObservableList <UIElementFilter> > GetUIElementFilterList()
        {
            ObservableList <UIElementFilter> uIBasicElementFilters    = new ObservableList <UIElementFilter>();
            ObservableList <UIElementFilter> uIAdvancedElementFilters = new ObservableList <UIElementFilter>();

            foreach (PlatformInfoBase.ElementTypeData elementTypeOperation in GetPlatformElementTypesData())
            {
                if (elementTypeOperation.IsCommonElementType)
                {
                    uIBasicElementFilters.Add(new UIElementFilter(elementTypeOperation.ElementType, string.Empty, true));
                }
                else
                {
                    uIAdvancedElementFilters.Add(new UIElementFilter(elementTypeOperation.ElementType, string.Empty, false));
                }
            }

            Dictionary <string, ObservableList <UIElementFilter> > elementListDic = new Dictionary <string, ObservableList <UIElementFilter> >();

            elementListDic.Add("Basic", new ObservableList <UIElementFilter>(uIBasicElementFilters));
            elementListDic.Add("Advanced", new ObservableList <UIElementFilter>(uIAdvancedElementFilters));

            return(elementListDic);
        }
Exemplo n.º 40
0
        public ObservableList <ITextEditor> GetTextFileEditors()
        {
            //TODO: cache
            if (!Isloaded)
            {
                ScanPackage();
            }

            ObservableList <ITextEditor> textEditors = new ObservableList <ITextEditor>();

            foreach (PluginAssemblyInfo PAI in mAssembliesInfo)
            {
                var list = from type in PAI.Assembly.GetTypes()
                           where typeof(ITextEditor).IsAssignableFrom(type) && type.IsAbstract == false
                           select type;

                foreach (Type t in list)
                {
                    ITextEditor textEditor = (ITextEditor)PAI.Assembly.CreateInstance(t.FullName);
                    textEditors.Add(textEditor);
                }
            }
            return(textEditors);
        }
    public void UnitTest2()
    {
        // ARRANGE
        using var item1 = new CapturedItem();
        using var list  = new ObservableList <CapturedItem>
              {
                  AutomaticallyCaptureSubItems = false,
              };

        // ACT
        list.Add(item1);

        item1.TestProperty = "aaa";
        item1.TestProperty = "bbb";
        item1.TestProperty = "ccc";

        list.Undo();

        // ASSERT
        Assert.Equal(
            "ccc",
            item1.TestProperty);
        Assert.Empty(list);
    }
Exemplo n.º 42
0
        public void OnSelectFramePageRightClick()
        {
            if (m_nCurPageIndex >= m_nPageCount)
            {
                return;
            }

            m_nCurPageIndex++;
            //PageIndexText.text = m_nCurPageIndex.ToString();
            int nSlotId = 0;
            ObservableList <UTileViewItemRoomHeroSkin> newData = new ObservableList <UTileViewItemRoomHeroSkin>();

            foreach (UTileViewItemRoomHeroSkin item in  SelectHeroDataFilter)
            {
                if (nSlotId >= (m_nCurPageIndex - 1) * m_nPageItemCount && nSlotId < m_nCurPageIndex * m_nPageItemCount)
                {
                    newData.Add(item);
                }
                nSlotId++;
            }

            this.DataSource = newData;
            ClearSelectState();
        }
        public void Comparer()
        {               //****************************************
            var MySeed    = Environment.TickCount;
            var MyRandom  = new Random(MySeed);
            var MyRecords = new ObservableList <int>(1024);
            //****************************************

            var MyView = new ObservableListView <int>(MyRecords, ReverseComparer <int> .Default);

            for (int Index = 0; Index < 1024; Index++)
            {
                MyRecords.Add(MyRandom.Next(short.MaxValue));
            }

            //****************************************

            var MySortedRecords = MyRecords.ToArray();

            Array.Sort(MySortedRecords, ReverseComparer <int> .Default);

            CollectionAssert.AreEqual(MySortedRecords, MyView, "Bad Seed was {0}", MySeed);

            Thread.Sleep(1);
        }
Exemplo n.º 44
0
        public void DeserializeContent(string dataDir, Base_Json json)
        {
            Classes_Json classes = json as Classes_Json;

            foreach (var charClass in classes.classes)
            {
                _Content.Add(
                    DeserializeSingleClass(dataDir, charClass));
            }

            if (classes.filters != null)
            {
                foreach (var filter in classes.filters)
                {
                    FilterGroup fg = new FilterGroup()
                    {
                        ID                   = filter.id != null ? filter.id : "",
                        Header               = filter.title != null ? filter.title : "Filter by Unknown",
                        ShowExlusiveToggle   = filter.showExclusiveToggle,
                        ExclusiveToggleLabel = filter.exclusiveToggleLabel != null ? filter.exclusiveToggleLabel : "Exclude unchecked options",
                        IsExclusive          = filter.isExclusive
                    };
                    foreach (var option in filter.options)
                    {
                        fg.AddItem(option.id, option.display);
                    }

                    _FilterGroups.Add(fg);
                }
            }

            if (Content.Count() <= 0)
            {
                throw new ArgumentNullException("No classes were loaded from classes json file. Is the file empty?");
            }
        }
Exemplo n.º 45
0
        private void ReplaceScreenshotTemplate(ref string ActivityData, List <string> ScreenShots)
        {
            var Screenshots = string.Empty;
            ObservableList <Bitmap> Bitmp = new ObservableList <Bitmap>();

            foreach (String bitmapsource in ScreenShots)
            {
                Bitmap bmp = Ginger.Utils.BitmapManager.FileToBitmapImage(bitmapsource);
                var    txt = string.Empty;

                //Bitmap bitmap;
                using (var outStream = new MemoryStream())
                {
                    Bitmp.Add(bmp);
                    var ms = new MemoryStream();
                    bmp.Save(ms, ImageFormat.Png);
                    var byteImage = ms.ToArray();
                    txt = @"data:image/png;base64," + Convert.ToBase64String(byteImage);
                }
                var html = @"<img src=" + txt + " >";
                Screenshots = Screenshots + "<br/>" + html;
            }
            ActivityData = ActivityData.Replace("BusinessFlows[i].Activities[i].Actions[i].ScreenShots", Screenshots);
        }
        public void EventAdd()
        {               //****************************************
            var MySeed    = Environment.TickCount;
            var MyRandom  = new Random(MySeed);
            var MyRecords = new ObservableList <int>(1);
            NotifyCollectionChangedEventArgs MyEventArgs = null;
            //****************************************

            var MyView = new ObservableListView <int>(MyRecords);

            MyView.CollectionChanged += (sender, e) => MyEventArgs = e;

            MyRecords.Add(42);

            //****************************************

            Assert.AreEqual(1, MyView.Count, "Item count does not match");
            Assert.IsNotNull(MyEventArgs, "No Event Raised");
            Assert.AreEqual(NotifyCollectionChangedAction.Add, MyEventArgs.Action);
            Assert.IsNotNull(MyEventArgs.NewItems, "No New Items");
            Assert.AreEqual(0, MyEventArgs.NewStartingIndex, "Starting Index incorrect");
            Assert.AreEqual(1, MyEventArgs.NewItems.Count, "New Items Count incorrect");
            Assert.AreEqual(42, MyEventArgs.NewItems[0], "New Items Value incorrect");
        }
Exemplo n.º 47
0
        public void CanAccumulate()
        {
            var items = new ObservableList <Person>();


            var subscription = items.Changes
                               .Subscribe(changes =>
            {
                Console.WriteLine(changes);
            });


            using (var x = items.SuspendNotifications())
            {
                foreach (var person in _random.Take(20000))
                {
                    items.Add(person);
                }
                items.Clear();
                var result = items.GetChanges();

                items[10] = new Person("Roland", 1);
            }
        }
Exemplo n.º 48
0
        private void LoadGridData()
        {
            ObservableList <Act> allActions      = GetPlatformsActions();
            ObservableList <Act> platformActions = new ObservableList <Act>();
            ObservableList <Act> generalActions  = new ObservableList <Act>();
            ObservableList <Act> LegacyActions   = new ObservableList <Act>();

            if (allActions != null)
            {
                IEnumerable <Act> OrderedActions = allActions.OrderBy(x => x.Description);
                foreach (Act cA in OrderedActions)
                {
                    if (cA.LegacyActionPlatformsList.Intersect(WorkSpace.Instance.Solution.ApplicationPlatforms
                                                               .Where(x => mContext.Activity.TargetApplication == x.AppName)
                                                               .Select(x => x.Platform).ToList()).Any())
                    {
                        LegacyActions.Add(cA);
                    }
                    else if (cA.SupportedPlatforms == "All")
                    {
                        if ((cA is ActPlugIn) == false)
                        {
                            generalActions.Add(cA);
                        }
                    }
                    else
                    {
                        platformActions.Add(cA);
                    }
                }
            }

            PlatformActionsGrid.DataSourceList = platformActions;
            GeneralActionsGrid.DataSourceList  = generalActions;
            LegacyActionsGrid.DataSourceList   = LegacyActions;
        }
        public void RandomlyChangeDirection()
        {
            RandomGenerator.ResetRandomGenerator();

            var list = new ObservableList <int>();

            foreach (var value in Enumerable.Range(0, 100))
            {
                list.Add(list.Count, RandomGenerator.GenerateRandomInteger());
            }

            var index = new ActiveValue <ListSortDirection>();

            var sut       = list.ActiveOrderBy(i => i, index);
            var watcher   = new CollectionSynchronizationWatcher <int>(sut);
            var validator = new LinqValidator <int, int, int>(list, sut, l => index.Value == ListSortDirection.Ascending ? l.OrderBy(i => i) : l.OrderByDescending(i => i), false, null);

            foreach (var value in Enumerable.Range(0, 10))
            {
                index.Value = RandomGenerator.GenerateRandomInteger(0, 2) == 0 ? ListSortDirection.Ascending : ListSortDirection.Descending;

                validator.Validate();
            }
        }
Exemplo n.º 50
0
        private void AddDefectsProfile(object sender, RoutedEventArgs e)
        {
            Mouse.OverrideCursor = Cursors.Wait;
            ALMDefectProfile newALMDefectProfile = new ALMDefectProfile();

            newALMDefectProfile.ToUpdate = true;
            if (mALMDefectProfiles.Count == 0)
            {
                newALMDefectProfile.IsDefault = true;
                newALMDefectProfile.ID        = 1;
            }
            else
            {
                newALMDefectProfile.ID        = mALMDefectProfiles.Select(x => x.ID).Max() + 1;
                newALMDefectProfile.IsDefault = false;
            }
            newALMDefectProfile.Name        = "Some Name " + (newALMDefectProfile.ID + 1).ToString();
            newALMDefectProfile.Description = "Some Description " + (newALMDefectProfile.ID + 1).ToString();
            mALMDefectProfiles.Add(newALMDefectProfile);

            // mALMDefectProfileFields.ToList().ForEach(x => newALMDefectProfile.ALMDefectProfileFields.Add((ExternalItemFieldBase)x.CreateCopy()));

            mALMDefectProfileFieldsExisted = new ObservableList <ExternalItemFieldBase>();
            foreach (ExternalItemFieldBase aLMDefectProfileField in mALMDefectProfileFields)
            {
                ExternalItemFieldBase aLMDefectProfileFieldExisted = (ExternalItemFieldBase)aLMDefectProfileField.CreateCopy();
                aLMDefectProfileFieldExisted.ExternalID     = string.Copy(aLMDefectProfileField.ExternalID);
                aLMDefectProfileFieldExisted.PossibleValues = aLMDefectProfileField.PossibleValues;
                mALMDefectProfileFieldsExisted.Add(aLMDefectProfileFieldExisted);
            }
            newALMDefectProfile.ALMDefectProfileFields = mALMDefectProfileFieldsExisted;

            grdDefectsProfiles.DataSourceList = mALMDefectProfiles;
            grdDefectsFields.DataSourceList   = newALMDefectProfile.ALMDefectProfileFields;
            Mouse.OverrideCursor = null;
        }
Exemplo n.º 51
0
        private void UpdateFolderItemsCacheFilePath()
        {
            ObservableList <T> cacheItems = new ObservableList <T>();

            foreach (T item in mFolderItemsCache.Items <T>())
            {
                cacheItems.Add(item);
            }
            foreach (T cacheitem in cacheItems)
            {
                RepositoryItemBase item = (RepositoryItemBase)(object)cacheitem;
                mFolderItemsCache.DeleteItem(item.FilePath);
                item.FilePath                    = Path.Combine(FolderFullPath, Path.GetFileName(PathHelper.GetLongPath(((RepositoryItemBase)item).FilePath)));
                item.FileName                    = Path.Combine(FolderFullPath, Path.GetFileName(PathHelper.GetLongPath((item).FilePath)));
                item.ContainingFolder            = FolderRelativePath;
                item.ContainingFolderFullPath    = FolderFullPath;
                mFolderItemsCache[item.FilePath] = item;
                item.OnPropertyChanged(nameof(RepositoryItemBase.FilePath));
                item.OnPropertyChanged(nameof(RepositoryItemBase.ContainingFolder));
                item.OnPropertyChanged(nameof(RepositoryItemBase.ContainingFolderFullPath));
                item.OnPropertyChanged(nameof(RepositoryItemBase.RelativeFilePath));
                item.OnPropertyChanged(nameof(RepositoryItemBase.FileName));
            }
        }
Exemplo n.º 52
0
        private static ObservableList <ApplicationAPIModel> GetParameters(string jsonText, ObservableList <ApplicationAPIModel> AAMSList, bool avoidDuplicatesNodes, string fileName)
        {
            ApplicationAPIModel AAM = new ApplicationAPIModel();

            AAM.Name = Path.GetFileNameWithoutExtension(fileName);

            //JObject jo = JObject.Parse(JSOnText);
            //IList<string> keys = jo.Properties().Select(p => p.Path).ToList();

            if (avoidDuplicatesNodes)
            {
                JsonExtended fullJSOnObjectExtended = new JsonExtended(jsonText);
                fullJSOnObjectExtended.RemoveDuplicatesNodes();
                jsonText = fullJSOnObjectExtended.JsonString;
            }

            object[] BodyandModelParameters = GenerateBodyANdModelParameters(jsonText);

            AAM.RequestBody        = (string)BodyandModelParameters[0];
            AAM.AppModelParameters = (ObservableList <AppModelParameter>)BodyandModelParameters[1];
            AAMSList.Add(AAM);

            return(AAMSList);
        }
        ObservableList <Act> IWindowExplorerTreeItem.GetElementActions()
        {
            ObservableList <Act> list = new ObservableList <Act>();

            list.Add(new ActJavaElement()
            {
                Description   = "Set Selected Value " + Name,
                ControlAction = ActJavaElement.eControlAction.Select
            });

            list.Add(new ActJavaElement()
            {
                Description   = "Get " + Name + " Value",
                ControlAction = ActJavaElement.eControlAction.GetValue
            });

            list.Add(new ActJavaElement()
            {
                Description   = "Get IsEnabled Property " + Name,
                ControlAction = ActJavaElement.eControlAction.IsEnabled
            });

            list.Add(new ActJavaElement()
            {
                Description   = "Select Value By Index",
                ControlAction = ActJavaElement.eControlAction.SelectByIndex,
                Value         = 0 + ""
            });

            list.Add(new ActJavaElement()
            {
                Description   = "Get Value By Index",
                ControlAction = ActJavaElement.eControlAction.GetValueByIndex,
                Value         = 0 + ""
            });

            list.Add(new ActJavaElement()
            {
                Description   = "Get Item Count",
                ControlAction = ActJavaElement.eControlAction.GetItemCount,
            });
            return(list);
        }
Exemplo n.º 54
0
        ObservableList <Act> IWindowExplorerTreeItem.GetElementActions()
        {
            ObservableList <Act> list = new ObservableList <Act>();

            list.Add(new ActJavaElement()
            {
                Description   = "Set " + Name + " ON",
                ControlAction = ActJavaElement.eControlAction.SetValue,
                Value         = "true"
            });

            list.Add(new ActJavaElement()
            {
                Description   = "Set " + Name + " OFF",
                ControlAction = ActJavaElement.eControlAction.SetValue,
                Value         = "false"
            });

            list.Add(new ActJavaElement()
            {
                Description   = "Toggle Checkbox " + Name,
                ControlAction = ActJavaElement.eControlAction.Toggle
            });

            list.Add(new ActJavaElement()
            {
                Description   = "Get " + Name + " Value",
                ControlAction = ActJavaElement.eControlAction.GetValue
            });

            list.Add(new ActJavaElement()
            {
                Description   = "Get IsEnabled Property " + Name,
                ControlAction = ActJavaElement.eControlAction.IsEnabled
            });

            list.Add(new ActJavaElement()
            {
                Description   = "Is Checked " + Name,
                ControlAction = ActJavaElement.eControlAction.IsChecked
            });
            return(list);
        }
Exemplo n.º 55
0
 public void OpenFile(string fileName)
 {
     _fileName.Value = fileName;
     if (File.Exists(fileName))
     {
         _instructions.Clear();
         using (var reader = new StreamReader(File.OpenRead(fileName)))
         {
             while (!reader.EndOfStream)
             {
                 var line = reader.ReadLine();
                 _instructions.Add(line);
             }
         }
     }
     else
     {
         Save();
     }
     _recording.Value = false;
     _playhead.Value  = 0;
 }
Exemplo n.º 56
0
        private void SetCheckinGridView()
        {
            GridViewDef view = new GridViewDef(GridViewDef.DefaultViewName);
            ObservableList <GridColView> viewCols = new ObservableList <GridColView>();

            view.GridColsView = viewCols;

            // TODO: use fields
            viewCols.Add(new GridColView()
            {
                Field = nameof(SourceControlFileInfo.Selected), Header = "Selected", WidthWeight = 10, StyleType = GridColView.eGridColStyleType.CheckBox, AllowSorting = true
            });
            viewCols.Add(new GridColView()
            {
                Field = nameof(SourceControlFileInfo.Status), Header = "Status", WidthWeight = 10, ReadOnly = true, AllowSorting = true
            });
            viewCols.Add(new GridColView()
            {
                Field = nameof(SourceControlFileInfo.Name), Header = "Item Name", WidthWeight = 20, AllowSorting = true
            });
            viewCols.Add(new GridColView()
            {
                Field = nameof(SourceControlFileInfo.FileType), Header = "Item Type", WidthWeight = 20, AllowSorting = true
            });
            viewCols.Add(new GridColView()
            {
                Field = nameof(SourceControlFileInfo.SolutionPath), Header = "Item Path", WidthWeight = 40, ReadOnly = true, AllowSorting = true
            });
            if (App.UserProfile.Solution.ShowIndicationkForLockedItems)
            {
                viewCols.Add(new GridColView()
                {
                    Field = nameof(SourceControlFileInfo.Locked), Header = "Locked", WidthWeight = 10, StyleType = GridColView.eGridColStyleType.Text
                });
            }
            CheckInFilesGrid.SetAllColumnsDefaultView(view);
            CheckInFilesGrid.InitViewItems();
        }
Exemplo n.º 57
0
        private void UpdateRelatedActions()
        {
            GingerCore.Actions.ActTableElement.eTableAction?previousSelectedControlAction = null;
            if (mActions != null)
            {
                if (mActions.CurrentItem != null)
                {
                    if (mActions.CurrentItem is ActTableElement)
                    {
                        previousSelectedControlAction = ((ActTableElement)mActions.CurrentItem).ControlAction;
                    }
                }

                mActions.Clear();
            }

            //This is just example to show the actions can change
            // need to be per selected filter user did

            if (cmbColSelectorValue.SelectedIndex != -1)
            {
                mAct.ColSelectorValue = (GingerCore.Actions.ActTableElement.eRunColSelectorValue)Enum.Parse(typeof(GingerCore.Actions.ActTableElement.eRunColSelectorValue), cmbColSelectorValue.SelectedValue.ToString());
            }

            string description = "";
            string rowVal      = "";
            string colVal      = "";

            if (RowNum.IsChecked == true)
            {
                mAct.LocateRowType = "Row Number";
                if (RowSelectorValue != null)
                {
                    if (RowSelectorValue.SelectedIndex != -1)
                    {
                        rowVal = RowSelectorValue.SelectedItem.ToString();
                    }
                    else
                    {
                        rowVal = RowSelectorValue.Text;
                    }
                    description = " on Row:" + rowVal;
                }
            }
            else if (AnyRow.IsChecked == true)
            {
                mAct.LocateRowType = "Any Row";
                description        = " on Random Row";
            }
            else if (BySelectedRow.IsChecked == true)
            {
                mAct.LocateRowType = "By Selected Row";
                description        = " on Selected Row";
            }
            else if (Where.IsChecked == true)
            {
                mAct.LocateRowType = "Where";
                description        = " on Row with condition";
            }

            if (cmbColumnValue != null)
            {
                if (cmbColumnValue.SelectedIndex != -1)
                {
                    colVal = cmbColumnValue.SelectedItem.ToString();
                }
                else
                {
                    colVal = cmbColumnValue.Text;
                }
                description = description + " and Column:" + colVal;
            }

            if (eBaseWindow.Equals(BaseWindow.WindowExplorer) && cmbColSelectorValue.SelectedIndex != -1 && WhereColumn != null && WhereColumn.SelectedIndex != -1 && RowSelectorValue != null &&
                WhereProperty != null && WhereProperty.SelectedIndex != -1 && WhereOperator != null && WhereOperator.SelectedIndex != -1)
            {
                // Add some sample for specific cell
                mActions.Add(new ActTableElement()
                {
                    Description      = "Get Value of Cell:" + description,
                    ControlAction    = ActTableElement.eTableAction.GetValue,
                    ColSelectorValue = mAct.ColSelectorValue,
                    LocateColTitle   = colVal,
                    LocateRowType    = mAct.LocateRowType,
                    LocateRowValue   = rowVal,
                    ByRowNum         = (bool)RowNum.IsChecked,
                    ByRandRow        = (bool)AnyRow.IsChecked,
                    BySelectedRow    = (bool)BySelectedRow.IsChecked,
                    ByWhere          = (bool)Where.IsChecked,
                    WhereColSelector = (GingerCore.Actions.ActTableElement.eRunColSelectorValue)Enum.Parse(typeof(GingerCore.Actions.ActTableElement.eRunColSelectorValue), WhereColumn.SelectedValue.ToString()),
                    WhereColumnTitle = WhereColumnTitle.Text,
                    WhereColumnValue = WhereColumnValue.ValueTextBox.Text,
                    WhereOperator    = (GingerCore.Actions.ActTableElement.eRunColOperator)Enum.Parse(typeof(GingerCore.Actions.ActTableElement.eRunColOperator), WhereOperator.SelectedValue.ToString()),
                    WhereProperty    = (GingerCore.Actions.ActTableElement.eRunColPropertyValue)Enum.Parse(typeof(GingerCore.Actions.ActTableElement.eRunColPropertyValue), WhereProperty.SelectedValue.ToString())
                });
                mActions.Add(new ActTableElement()
                {
                    Description      = "Set Value of Cell: " + description,
                    ControlAction    = ActTableElement.eTableAction.SetValue,
                    ColSelectorValue = mAct.ColSelectorValue,
                    LocateColTitle   = colVal,
                    LocateRowType    = mAct.LocateRowType,
                    LocateRowValue   = rowVal,
                    ByRowNum         = (bool)RowNum.IsChecked,
                    ByRandRow        = (bool)AnyRow.IsChecked,
                    BySelectedRow    = (bool)BySelectedRow.IsChecked,
                    ByWhere          = (bool)Where.IsChecked,
                    WhereColSelector = (GingerCore.Actions.ActTableElement.eRunColSelectorValue)Enum.Parse(typeof(GingerCore.Actions.ActTableElement.eRunColSelectorValue), WhereColumn.SelectedValue.ToString()),
                    WhereColumnTitle = WhereColumnTitle.Text,
                    WhereColumnValue = WhereColumnValue.ValueTextBox.Text,
                    WhereOperator    = (GingerCore.Actions.ActTableElement.eRunColOperator)Enum.Parse(typeof(GingerCore.Actions.ActTableElement.eRunColOperator), WhereOperator.SelectedValue.ToString()),
                    WhereProperty    = (GingerCore.Actions.ActTableElement.eRunColPropertyValue)Enum.Parse(typeof(GingerCore.Actions.ActTableElement.eRunColPropertyValue), WhereProperty.SelectedValue.ToString())
                });
                mActions.Add(new ActTableElement()
                {
                    Description      = "Type Value in Cell: " + description,
                    ControlAction    = ActTableElement.eTableAction.Type,
                    ColSelectorValue = mAct.ColSelectorValue,
                    LocateColTitle   = colVal,
                    LocateRowType    = mAct.LocateRowType,
                    LocateRowValue   = rowVal,
                    ByRowNum         = (bool)RowNum.IsChecked,
                    ByRandRow        = (bool)AnyRow.IsChecked,
                    BySelectedRow    = (bool)BySelectedRow.IsChecked,
                    ByWhere          = (bool)Where.IsChecked,
                    WhereColSelector = (GingerCore.Actions.ActTableElement.eRunColSelectorValue)Enum.Parse(typeof(GingerCore.Actions.ActTableElement.eRunColSelectorValue), WhereColumn.SelectedValue.ToString()),
                    WhereColumnTitle = WhereColumnTitle.Text,
                    WhereColumnValue = WhereColumnValue.ValueTextBox.Text,
                    WhereOperator    = (GingerCore.Actions.ActTableElement.eRunColOperator)Enum.Parse(typeof(GingerCore.Actions.ActTableElement.eRunColOperator), WhereOperator.SelectedValue.ToString()),
                    WhereProperty    = (GingerCore.Actions.ActTableElement.eRunColPropertyValue)Enum.Parse(typeof(GingerCore.Actions.ActTableElement.eRunColPropertyValue), WhereProperty.SelectedValue.ToString())
                });
                mActions.Add(new ActTableElement()
                {
                    Description      = "Click Cell:" + description,
                    ControlAction    = ActTableElement.eTableAction.Click,
                    ColSelectorValue = mAct.ColSelectorValue,
                    LocateColTitle   = colVal,
                    LocateRowType    = mAct.LocateRowType,
                    LocateRowValue   = rowVal,
                    ByRowNum         = (bool)RowNum.IsChecked,
                    BySelectedRow    = (bool)BySelectedRow.IsChecked,
                    ByRandRow        = (bool)AnyRow.IsChecked,
                    ByWhere          = (bool)Where.IsChecked,
                    WhereColSelector = (GingerCore.Actions.ActTableElement.eRunColSelectorValue)Enum.Parse(typeof(GingerCore.Actions.ActTableElement.eRunColSelectorValue), WhereColumn.SelectedValue.ToString()),
                    WhereColumnTitle = WhereColumnTitle.Text,
                    WhereColumnValue = WhereColumnValue.ValueTextBox.Text,
                    WhereOperator    = (GingerCore.Actions.ActTableElement.eRunColOperator)Enum.Parse(typeof(GingerCore.Actions.ActTableElement.eRunColOperator), WhereOperator.SelectedValue.ToString()),
                    WhereProperty    = (GingerCore.Actions.ActTableElement.eRunColPropertyValue)Enum.Parse(typeof(GingerCore.Actions.ActTableElement.eRunColPropertyValue), WhereProperty.SelectedValue.ToString())
                });
            }

            RestoreOriginalActions();

            //try to select the action the user had selected before
            if (previousSelectedControlAction != null)
            {
                if (mActions != null)
                {
                    foreach (ActTableElement act in mActions)
                    {
                        if (act.ControlAction == previousSelectedControlAction)
                        {
                            mActions.CurrentItem = act;
                            break;
                        }
                    }
                }
            }
            if (mActions != null && mActions.CurrentItem == null && mActions.Count > 0)
            {
                mActions.CurrentItem = mActions[0];
            }

            // Add unique actions for the selected filter/cell
        }
Exemplo n.º 58
0
        public static bool ExportBusinessFlowToQC(BusinessFlow businessFlow, TestSet mappedTestSet, string uploadPath, ObservableList <ExternalItemFieldBase> testSetFields, ref string result)
        {
            TestSet testSet;
            ObservableList <ActivitiesGroup> existingActivitiesGroups = new ObservableList <ActivitiesGroup>();

            try
            {
                if (mappedTestSet == null)
                {
                    //##create new Test Set in QC
                    TestSetFactory TestSetF = (TestSetFactory)mTDConn.TestSetFactory;
                    testSet = (TestSet)TestSetF.AddItem(System.DBNull.Value);

                    //set the upload path
                    TestSetTreeManager treeM = (TestSetTreeManager)mTDConn.TestSetTreeManager;
                    ISysTreeNode       testSetParentFolder = (ISysTreeNode)treeM.get_NodeByPath(uploadPath);
                    testSet.TestSetFolder = testSetParentFolder.NodeID;
                }
                else
                {
                    //##update existing test set
                    //testSet = mappedTestSet;
                    testSet = ImportFromQC.GetQCTestSet(mappedTestSet.ID.ToString());

                    TSTestFactory testsF      = (TSTestFactory)testSet.TSTestFactory;
                    List          tsTestsList = testsF.NewList("");
                    foreach (TSTest tsTest in tsTestsList)
                    {
                        ActivitiesGroup ag = businessFlow.ActivitiesGroups.Where(x => (x.ExternalID == tsTest.TestId.ToString() && x.ExternalID2 == tsTest.ID.ToString())).FirstOrDefault();
                        if (ag == null)
                        {
                            testsF.RemoveItem(tsTest.ID);
                        }
                        else
                        {
                            existingActivitiesGroups.Add(ag);
                        }
                    }
                }

                //set item fields
                foreach (ExternalItemFieldBase field in testSetFields)
                {
                    if (field.ToUpdate || field.Mandatory)
                    {
                        if (string.IsNullOrEmpty(field.SelectedValue) == false && field.SelectedValue != "NA")
                        {
                            testSet[field.ID] = field.SelectedValue;
                        }
                        else
                        {
                            try { testSet[field.ID] = "NA"; }
                            catch { }
                        }
                    }
                }

                //post the test set
                testSet.Name = businessFlow.Name;

                try
                {
                    testSet.Post();
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("The Test Set already exists"))
                    {
                        result = "Cannot export " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + "- The Test Set already exists in the selected folder. ";
                        Reporter.ToLog(eLogLevel.ERROR, result, ex);
                        return(false);
                    }

                    //Searching for the testset in case it was created in ALM although getting exception
                    TestSetFactory     TSetFact            = mTDConn.TestSetFactory;
                    TDFilter           tsFilter            = TSetFact.Filter;
                    TestSetTreeManager treeM               = (TestSetTreeManager)mTDConn.TestSetTreeManager;
                    ISysTreeNode       testSetParentFolder = (ISysTreeNode)treeM.get_NodeByPath(uploadPath);

                    try
                    {
                        tsFilter["CY_FOLDER_ID"] = "" + testSetParentFolder.NodeID + "";
                    }
                    catch (Exception e)
                    {
                        tsFilter["CY_FOLDER_ID"] = "\"" + testSetParentFolder.Path.ToString() + "\"";
                        Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {e.Message}", e);
                    }

                    List TestsetList = TSetFact.NewList(tsFilter.Text);
                    foreach (TestSet set in TestsetList)
                    {
                        if (set.Name == businessFlow.Name)
                        {
                            testSet = set;
                            break;
                        }
                    }
                }

                businessFlow.ExternalID = testSet.ID.ToString();

                //Add missing test cases
                TSTestFactory testCasesF = testSet.TSTestFactory;
                foreach (ActivitiesGroup ag in businessFlow.ActivitiesGroups)
                {
                    if (existingActivitiesGroups.Contains(ag) == false && string.IsNullOrEmpty(ag.ExternalID) == false && ImportFromQC.GetQCTest(ag.ExternalID) != null)
                    {
                        TSTest tsTest = testCasesF.AddItem(ag.ExternalID);
                        if (tsTest != null)
                        {
                            ag.ExternalID2 = tsTest.ID;//the test case instance ID in the test set- used for exporting the execution details
                        }
                    }
                    else
                    {
                        foreach (ActivityIdentifiers actIdent in ag.ActivitiesIdentifiers)
                        {
                            ExportActivityAsTestStep(ImportFromQC.GetQCTest(ag.ExternalID), (Activity)actIdent.IdentifiedActivity);
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                result = "Unexpected error occurred- " + ex.Message;
                Reporter.ToLog(eLogLevel.ERROR, "Failed to export the " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " to QC/ALM", ex);
                return(false);
            }
        }
Exemplo n.º 59
0
        public static bool ExportExecutionDetailsToQC(BusinessFlow bizFlow, ref string result, PublishToALMConfig publishToALMConfig = null)
        {
            result = string.Empty;
            if (bizFlow.ExternalID == "0" || String.IsNullOrEmpty(bizFlow.ExternalID))
            {
                result = GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + ": " + bizFlow.Name + " is missing ExternalID, cannot locate QC TestSet without External ID";
                return(false);
            }

            try
            {
                //get the BF matching test set
                TestSet testSet = ImportFromQC.GetQCTestSet(bizFlow.ExternalID);//bf.externalID holds the TestSet TSTests collection id
                if (testSet != null)
                {
                    //get the Test set TC's
                    List <TSTest> qcTSTests = ImportFromQC.GetTSTestsList(testSet); //list of TSTest's on main TestSet in TestLab

                    //get all BF Activities groups
                    ObservableList <ActivitiesGroup> activGroups = bizFlow.ActivitiesGroups;
                    if (activGroups.Count > 0)
                    {
                        foreach (ActivitiesGroup activGroup in activGroups)
                        {
                            if ((publishToALMConfig.FilterStatus == FilterByStatus.OnlyPassed && activGroup.RunStatus == eActivitiesGroupRunStatus.Passed) ||
                                (publishToALMConfig.FilterStatus == FilterByStatus.OnlyFailed && activGroup.RunStatus == eActivitiesGroupRunStatus.Failed) ||
                                publishToALMConfig.FilterStatus == FilterByStatus.All)
                            {
                                TSTest tsTest = null;
                                //go by TC ID = TC Instance ID
                                tsTest = qcTSTests.Where(x => x.TestId == activGroup.ExternalID && x.ID == activGroup.ExternalID2).FirstOrDefault();
                                if (tsTest == null)
                                {
                                    //go by Linked TC ID + TC Instance ID
                                    tsTest = qcTSTests.Where(x => ImportFromQC.GetTSTestLinkedID(x) == activGroup.ExternalID && x.ID == activGroup.ExternalID2).FirstOrDefault();
                                }
                                if (tsTest == null)
                                {
                                    //go by TC ID
                                    tsTest = qcTSTests.Where(x => x.TestId == activGroup.ExternalID).FirstOrDefault();
                                }
                                if (tsTest != null)
                                {
                                    //get activities in group
                                    List <Activity> activities   = (bizFlow.Activities.Where(x => x.ActivitiesGroupID == activGroup.Name)).Select(a => a).ToList();
                                    string          TestCaseName = PathHelper.CleanInValidPathChars(tsTest.TestName);
                                    if ((publishToALMConfig.VariableForTCRunName == null) || (publishToALMConfig.VariableForTCRunName == string.Empty))
                                    {
                                        String timeStamp = DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss");
                                        publishToALMConfig.VariableForTCRunName = "GingerRun_" + timeStamp;
                                    }

                                    RunFactory runFactory = (RunFactory)tsTest.RunFactory;
                                    Run        run        = (Run)runFactory.AddItem(publishToALMConfig.VariableForTCRunNameCalculated);

                                    // Attach ActivityGroup Report if needed
                                    if (publishToALMConfig.ToAttachActivitiesGroupReport)
                                    {
                                        if ((activGroup.TempReportFolder != null) && (activGroup.TempReportFolder != string.Empty) &&
                                            (System.IO.Directory.Exists(activGroup.TempReportFolder)))
                                        {
                                            //Creating the Zip file - start
                                            string targetZipPath = System.IO.Directory.GetParent(activGroup.TempReportFolder).ToString();
                                            string zipFileName   = targetZipPath + "\\" + TestCaseName.ToString() + "_GingerHTMLReport.zip";

                                            if (!System.IO.File.Exists(zipFileName))
                                            {
                                                ZipFile.CreateFromDirectory(activGroup.TempReportFolder, zipFileName);
                                            }
                                            else
                                            {
                                                System.IO.File.Delete(zipFileName);
                                                ZipFile.CreateFromDirectory(activGroup.TempReportFolder, zipFileName);
                                            }
                                            System.IO.Directory.Delete(activGroup.TempReportFolder, true);
                                            //Creating the Zip file - finish
                                            //Attaching Zip file - start
                                            AttachmentFactory      attachmentFactory = (AttachmentFactory)run.Attachments;
                                            TDAPIOLELib.Attachment attachment        = (TDAPIOLELib.Attachment)attachmentFactory.AddItem(System.DBNull.Value);
                                            attachment.Description = "TC Ginger Execution HTML Report";
                                            attachment.Type        = 1;
                                            attachment.FileName    = zipFileName;
                                            attachment.Post();

                                            //Attaching Zip file - finish
                                            System.IO.File.Delete(zipFileName);
                                        }
                                    }


                                    //create run with activities as steps
                                    run.CopyDesignSteps();
                                    run.Post();
                                    StepFactory stepF     = run.StepFactory;
                                    List        stepsList = stepF.NewList("");

                                    //int i = 0;
                                    int index = 1;
                                    foreach (Step step in stepsList)
                                    {
                                        //search for matching activity based on ID and not order, un matching steps need to be left as No Run
                                        int      stepDesignID     = (stepsList[index]).Field("ST_DESSTEP_ID");
                                        Activity matchingActivity = activities.Where(x => x.ExternalID == stepDesignID.ToString()).FirstOrDefault();
                                        if (matchingActivity != null)
                                        {
                                            switch (matchingActivity.Status)
                                            {
                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed:
                                                step.Status = "Failed";
                                                List <IAct> failedActs = matchingActivity.Acts.Where(x => x.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed).ToList();
                                                string      errors     = string.Empty;
                                                foreach (Act act in failedActs)
                                                {
                                                    errors += act.Error + Environment.NewLine;
                                                }
                                                step["ST_ACTUAL"] = errors;
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.NA:
                                                step.Status       = "N/A";
                                                step["ST_ACTUAL"] = "NA";
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed:
                                                step.Status       = "Passed";
                                                step["ST_ACTUAL"] = "Passed as expected";
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Skipped:
                                                //step.Status = "No Run";
                                                step.Status       = "N/A";
                                                step["ST_ACTUAL"] = "Skipped";
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Pending:
                                                step.Status       = "No Run";
                                                step["ST_ACTUAL"] = "Was not executed";
                                                break;

                                            case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Running:
                                                step.Status       = "Not Completed";
                                                step["ST_ACTUAL"] = "Not Completed";
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            //Step not exist in Ginger so left as "No Run" unless it is step data
                                            if (step.Name.ToUpper() == "STEP DATA")
                                            {
                                                step.Status = "Passed";
                                            }
                                            else
                                            {
                                                step.Status = "No Run";
                                            }
                                        }
                                        step.Post();
                                        index++;
                                    }

                                    //get all execution status for all steps
                                    ObservableList <string> stepsStatuses = new ObservableList <string>();
                                    foreach (Step step in stepsList)
                                    {
                                        stepsStatuses.Add(step.Status);
                                    }

                                    //update the TC general status based on the activities status collection.
                                    if (stepsStatuses.Where(x => x == "Failed").Count() > 0)
                                    {
                                        run.Status = "Failed";
                                    }
                                    else if (stepsStatuses.Where(x => x == "No Run").Count() == stepsList.Count || stepsStatuses.Where(x => x == "N/A").Count() == stepsList.Count)
                                    {
                                        run.Status = "No Run";
                                    }
                                    else if (stepsStatuses.Where(x => x == "Passed").Count() == stepsList.Count || (stepsStatuses.Where(x => x == "Passed").Count() + stepsStatuses.Where(x => x == "N/A").Count()) == stepsList.Count)
                                    {
                                        run.Status = "Passed";
                                    }
                                    else
                                    {
                                        run.Status = "Not Completed";
                                    }
                                    run.Post();
                                }
                                else
                                {
                                    //No matching TC was found for the ActivitiesGroup in QC
                                    result = "Matching TC's were not found for all " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroups) + " in QC/ALM.";
                                }
                            }
                        }
                    }
                    else
                    {
                        //No matching Test Set was found for the BF in QC
                        result = "No matching Test Set was found in QC/ALM.";
                    }
                }
                if (result == string.Empty)
                {
                    result = "Export performed successfully.";
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                result = "Unexpected error occurred- " + ex.Message;
                Reporter.ToLog(eLogLevel.ERROR, "Failed to export execution details to QC/ALM", ex);
                //if (!silentMode)
                //    Reporter.ToUser(eUserMsgKey.ErrorWhileExportingExecDetails, ex.Message);
                return(false);
            }
        }
Exemplo n.º 60
0
        public override ObservableList <SourceControlFileInfo> GetPathFilesStatus(string Path, ref string error, List <string> PathsToIgnore = null, bool includLockedFiles = false)
        {
            if (client == null)
            {
                Init();
            }
            ObservableList <SourceControlFileInfo> files = new ObservableList <SourceControlFileInfo>();

            System.Collections.ObjectModel.Collection <SvnStatusEventArgs> statuses;
            try
            {
                client.GetStatus(Path, out statuses);

                foreach (SvnStatusEventArgs arg in statuses)
                {
                    if (PathsToIgnore != null)
                    {
                        bool pathToIgnoreFound = false;
                        foreach (string pathToIgnore in PathsToIgnore)
                        {
                            if (System.IO.Path.GetFullPath(arg.FullPath).Contains(System.IO.Path.GetFullPath(pathToIgnore)) || arg.FullPath.Contains(pathToIgnore))
                            {
                                pathToIgnoreFound = true;
                                break;
                            }
                        }
                        if (pathToIgnoreFound)
                        {
                            continue;
                        }
                    }

                    if (System.IO.Path.GetExtension(arg.FullPath) == ".ldb" || System.IO.Path.GetExtension(arg.FullPath) == ".ignore")
                    {
                        continue;
                    }

                    SourceControlFileInfo SCFI = new SourceControlFileInfo();
                    SCFI.Path         = arg.FullPath;
                    SCFI.SolutionPath = arg.FullPath.Replace(SolutionFolder, @"~\");
                    SCFI.Status       = SourceControlFileInfo.eRepositoryItemStatus.Unknown;
                    SCFI.Selected     = true;
                    SCFI.Diff         = "";
                    if (arg.LocalContentStatus == SvnStatus.Modified)
                    {
                        SCFI.Status = SourceControlFileInfo.eRepositoryItemStatus.Modified;
                        Task.Run(() =>
                                 SCFI.Diff = Diff(arg.FullPath, arg.Uri));
                    }
                    if (arg.LocalContentStatus == SvnStatus.NotVersioned)
                    {
                        SCFI.Status = SourceControlFileInfo.eRepositoryItemStatus.New;
                    }
                    if (arg.LocalContentStatus == SvnStatus.Missing)
                    {
                        SCFI.Status = SourceControlFileInfo.eRepositoryItemStatus.Deleted;
                    }

                    if (includLockedFiles)
                    {
                        Collection <SvnListEventArgs> ListEventArgs;
                        Task.Run(() =>
                        {
                            GetRemoteUriFromPath(arg.FullPath, out ListEventArgs);

                            if (ListEventArgs != null && ListEventArgs[0].Lock != null)
                            {
                                SCFI.Locked      = true;
                                SCFI.LockedOwner = ListEventArgs[0].Lock.Owner;
                                SCFI.LockComment = ListEventArgs[0].Lock.Comment;
                            }
                            else
                            {
                                SCFI.Locked = false;
                            }
                        });
                    }

                    if (SCFI.Status != SourceControlFileInfo.eRepositoryItemStatus.Unknown)
                    {
                        files.Add(SCFI);
                    }
                }
            }
            catch (Exception ex)
            {
                error = ex.Message + Environment.NewLine + ex.InnerException;
                Reporter.ToLog(eLogLevel.ERROR, "Failed to communicate with SVN server through path " + Path + " got error " + ex.Message);
                return(files);
            }

            return(files);
        }