Example #1
0
        public static KeyValuePair <TestItem, TestItemViewModel> ExistingDestCollEqualsWithNullElement()
        {
            var testItem   = new TestItem();
            var testItemVm = new TestItemViewModel();

            var testItems   = new List <TestCollection>();
            var testItemsVm = new List <TestCollectionViewModel>();

            for (var i = 0; i < 5; i++)
            {
                var id     = Guid.NewGuid();
                var format = string.Format("Name - {0}", i);
                var name   = string.Format("{0} - CHANGED!", format);

                var testCollection = new TestCollection
                {
                    Id   = id,
                    Name = name
                };

                var testCollectionVm = new TestCollectionViewModel
                {
                    Id   = id,
                    Name = format
                };

                testItems.Add(testCollection);
                testItemsVm.Add(i == 3 ? null : testCollectionVm);
            }
            testItem.Queryable = testItems.AsQueryable();
            testItemVm.Array   = testItemsVm.ToArray();

            return(new KeyValuePair <TestItem, TestItemViewModel>(testItem, testItemVm));
        }
Example #2
0
        public static KeyValuePair <TestItem, TestItemViewModel> ExistingDestCollNotEqual()
        {
            var testItem   = new TestItem();
            var testItemVm = new TestItemViewModel();

            var testItems   = new List <TestCollection>();
            var testItemsVm = new List <TestCollectionViewModel>();

            for (var i = 0; i < 10; i++)
            {
                var id     = Guid.NewGuid();
                var format = string.Format("Name - {0}", i);
                var name   = string.Format("{0} - CHANGED!", format);

                var testCollection = new TestCollection
                {
                    Id   = id,
                    Name = name
                };

                var testCollectionVm = new TestCollectionViewModel
                {
                    Id   = id,
                    Name = format
                };

                if (i < 6)
                {
                    testItems.Add(testCollection);
                }
                testItemsVm.Add(testCollectionVm);
            }
            testItem.Collection = testItems;
            testItemVm.Array    = testItemsVm.ToArray();

            return(new KeyValuePair <TestItem, TestItemViewModel>(testItem, testItemVm));
        }
        private IEnumerable<TestCollectionViewModel> LoadTestCollections()
        {
            var testCollections = new List<TestCollectionViewModel>();

            IList<string> testCollectionFiles = null;

            try
            {
                testCollectionFiles = _testCollectionService.GetTestCollectionFiles();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error Loading TestCollections", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            if (testCollectionFiles == null)
                return null;

            foreach (var testCollectionFile in testCollectionFiles)
            {
                TestCollection testCollection = null;

                try
                {
                    testCollection = _testCollectionService.GetTestCollection(testCollectionFile);
                }
                catch (Exception e)
                {
                    MessageBox.Show("TestCollection: " + testCollectionFile + Environment.NewLine + e.Message,
                                    "Error Loading TestCollection", MessageBoxButton.OK, MessageBoxImage.Error);
                }

                if (testCollection == null)
                    return null;

                var testCollectionViewModel = new TestCollectionViewModel
                {
                    Domain = testCollection.DefaultDomain,
                    IsEnabled = testCollection.Enabled,
                    Name = testCollection.File,
                    FullPath = testCollection.ResolvedFile,
                    OpenFileCommand = new DelegateCommand(() =>
                        {
                            _eventAggregator.GetEvent<ShowHelpWindowEvent>().Publish(null);

                            try
                            {
                                Process.Start(testCollection.ResolvedFile);
                            }
                            catch (Exception e)
                            {
                                // TODO: Remove blocking call.
                                MessageBox.Show(string.Format("Could not open {0}\r\n{1}", testCollection.ResolvedFile, e.Message));
                            }
                        })
                };

                if (testCollection.Tests == null)
                    return null;

                foreach (var test in testCollection.Tests)
                {
                    var testViewModel = new TestViewModel
                    {
                        IsEnabled = test.Enabled,
                        Name = test.Name,
                        Url = test.Url,
                        IsEnabledChangedCommand = new DelegateCommand<bool?>(enabled =>
                        {
                            test.Enabled = enabled.GetValueOrDefault();
                            _testCollectionService.SaveTestCollectionInfo(testCollection);
                        })
                    };

                    if (test.Commands == null)
                        return null;

                    foreach (var command in test.Commands)
                    {
                        var commandViewModel = new CommandViewModel
                        {
                            Name = command.Name,
                            Command = command,
                        };

                        var properties = _commandService.GetCommandValues(command);

                        foreach (var item in properties)
                        {
                            commandViewModel.Properties.Add(new CommandPropertyViewModel
                            {
                                Name = item.Key,
                                Value = item.Value
                            });
                        }

                        testViewModel.Children.Add(commandViewModel);
                    }

                    testCollectionViewModel.Children.Add(testViewModel);
                }

                testCollections.Add(testCollectionViewModel);
            }

            return testCollections;
        }
Example #4
0
        public static KeyValuePair<TestItem, TestItemViewModel> ExistingDestCollNotEqual()
        {
            var testItem = new TestItem();
            var testItemVm = new TestItemViewModel();

            var testItems = new List<TestCollection>();
            var testItemsVm = new List<TestCollectionViewModel>();

            for (var i = 0; i < 10; i++)
            {
                var id = Guid.NewGuid();
                var format = string.Format("Name - {0}", i);
                var name = string.Format("{0} - CHANGED!", format);

                var testCollection = new TestCollection
                {
                    Id = id,
                    Name = name
                };

                var testCollectionVm = new TestCollectionViewModel
                {
                    Id = id,
                    Name = format
                };

                if (i < 6)
                {
                    testItems.Add(testCollection);
                }
                testItemsVm.Add(testCollectionVm);
            }
            testItem.Collection = testItems;
            testItemVm.Array = testItemsVm.ToArray();

            return new KeyValuePair<TestItem, TestItemViewModel>(testItem, testItemVm);
        }
Example #5
0
        public static KeyValuePair<TestItem, TestItemViewModel> ExistingDestCollEqualsWithNullElement()
        {
            var testItem = new TestItem();
            var testItemVm = new TestItemViewModel();

            var testItems = new List<TestCollection>();
            var testItemsVm = new List<TestCollectionViewModel>();

            for (var i = 0; i < 5; i++)
            {
                var id = Guid.NewGuid();
                var format = string.Format("Name - {0}", i);
                var name = string.Format("{0} - CHANGED!", format);

                var testCollection = new TestCollection
                {
                    Id = id,
                    Name = name
                };

                var testCollectionVm = new TestCollectionViewModel
                {
                    Id = id,
                    Name = format
                };

                testItems.Add(testCollection);
                testItemsVm.Add(i == 3 ? null : testCollectionVm);
            }
            testItem.Queryable = testItems.AsQueryable();
            testItemVm.Array = testItemsVm.ToArray();

            return new KeyValuePair<TestItem, TestItemViewModel>(testItem, testItemVm);
        }
Example #6
0
        public static KeyValuePair<TestItem, TestItemViewModel> OtherCollectionMapTest()
        {
            var testItem = new TestItem();
            var testItemVm = new TestItemViewModel();

            var testItems = new List<TestCollection>();
            var testItemsVm = new List<TestCollectionViewModel>();

            for (var i = 0; i < 5; i++)
            {
                var id = Guid.NewGuid();
                var format = string.Format("Name - {0}", i);

                var testCollection = new TestCollection
                {
                    Id = id,
                    Name = format
                };

                var testCollectionVm = new TestCollectionViewModel
                {
                    Id = id,
                    Name = format
                };

                testItems.Add(testCollection);
                testItemsVm.Add(testCollectionVm);
            }
            testItem.Array = testItems.ToArray();
            testItemVm.ObservableCollection = new ObservableCollection<TestCollectionViewModel>(testItemsVm);

            return new KeyValuePair<TestItem, TestItemViewModel>(testItem, testItemVm);
        }
Example #7
0
        public static Tuple<TestItem, TestItemViewModel, TestItemViewModel> ExistingDestCollGreater()
        {
            var testItem = new TestItem();
            var testItemVm = new TestItemViewModel();
            var testItemVmCheck = new TestItemViewModel();

            var testItems = new List<TestCollection>();
            var testItemsVm = new List<TestCollectionViewModel>();
            var testItemsVmCheck = new List<TestCollectionViewModel>();

            for (var i = 0; i < 10; i++)
            {
                var id = Guid.NewGuid();
                var format = string.Format("Name - {0}", i);
                var name = string.Format("{0} - CHANGED!", format);

                var testCollection = new TestCollection
                {
                    Id = id,
                    Name = name
                };

                var testCollectionVm = new TestCollectionViewModel
                {
                    Id = id,
                    Name = format
                };

                var testCollectionVmCheck = new TestCollectionViewModel
                {
                    Id = id,
                    Name = name
                };

                if (i < 6)
                {
                    testItems.Add(testCollection);
                    testItemsVmCheck.Add(testCollectionVmCheck);
                }
                testItemsVm.Add(testCollectionVm);
            }
            testItem.Collection = testItems.ToArray();
            testItemVm.List = testItemsVm;
            testItemVmCheck.List = testItemsVmCheck.ToList();

            return new Tuple<TestItem, TestItemViewModel, TestItemViewModel>(testItem, testItemVm, testItemVmCheck);
        }
Example #8
0
        public static Tuple<TestItem, TestItemViewModel, TestItemViewModel> ExistingDestCollEquals()
        {
            var testItem = new TestItem();
            var testItemVm = new TestItemViewModel();
            var testItemVmCheck = new TestItemViewModel();

            var testItems = new List<TestCollection>();
            var testItemsVm = new List<TestCollectionViewModel>();
            var testItemsVmCheck = new List<TestCollectionViewModel>();

            for (var i = 0; i < 5; i++)
            {
                var id = Guid.NewGuid();
                var format = string.Format("Name - {0}", i);
                var name = string.Format("{0} - CHANGED!", format);

                var testCollection = new TestCollection
                {
                    Id = id,
                    Name = name
                };

                var testCollectionVm = new TestCollectionViewModel
                {
                    Id = id,
                    Name = format
                };

                var testCollectionVmCheck = new TestCollectionViewModel
                {
                    Id = id,
                    Name = name
                };

                testItems.Add(testCollection);
                testItemsVm.Add(testCollectionVm);
                testItemsVmCheck.Add(testCollectionVmCheck);
            }
            testItem.Queryable = testItems.AsQueryable();
            testItemVm.Array = testItemsVm.ToArray();
            testItemVmCheck.Array = testItemsVmCheck.ToArray();

            return new Tuple<TestItem, TestItemViewModel, TestItemViewModel>(testItem, testItemVm, testItemVmCheck);
        }
        private void LoadTestCollections()
        {
            IList<string> testCollectionFiles = null;

            try
            {
                testCollectionFiles = _testCollectionServiceService.GetTestCollectionFiles();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error Loading TestCollections", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            if (testCollectionFiles == null)
                return;

            foreach (var testCollectionFile in testCollectionFiles)
            {
                TestCollection testCollection = null;

                try
                {
                    testCollection = _testCollectionServiceService.GetTestCollection(testCollectionFile);
                }
                catch (Exception e)
                {
                    MessageBox.Show("TestCollection: " + testCollectionFile + Environment.NewLine + e.Message,
                                    "Error Loading TestCollection", MessageBoxButton.OK, MessageBoxImage.Error);
                }

                if (testCollection == null)
                    return;

                var testCollectionViewModel = new TestCollectionViewModel
                {
                    Domain = testCollection.DefaultDomain,
                    IsEnabled = testCollection.Enabled,
                    Name = testCollection.File,
                    FullPath = testCollection.ResolvedFile,
                };

                if (testCollection.Tests == null)
                    return;

                foreach (var test in testCollection.Tests)
                {
                    var testViewModel = new TestViewModel
                    {
                        IsEnabled = test.Enabled,
                        Name = test.Name,
                        Url = test.Url,
                        IsEnabledChangedCommand = new RelayCommand(enabled =>
                        {
                            test.Enabled = (bool) enabled;
                            _testCollectionServiceService.SaveTestCollectionInfo(testCollection);
                        })
                    };

                    if (test.Commands == null)
                        return;

                    foreach (var command in test.Commands)
                    {
                        var commandViewModel = new CommandViewModel
                        {
                            Name = command.Name,
                            Command = command,
                        };

                        var properties = _commandService.GetCommandValues(command);

                        foreach (var item in properties)
                        {
                            commandViewModel.Properties.Add(new CommandPropertyViewModel
                            {
                                Name = item.Key,
                                Value = item.Value
                            });
                        }

                        testViewModel.Children.Add(commandViewModel);
                    }

                    testCollectionViewModel.Children.Add(testViewModel);
                }

                TestCollections.Add(testCollectionViewModel);
            }
        }