public ModuleNodeViewModel(ViewTestClassesModule model) { // Setup initial conditions. this.model = model; classes = new ObservableCollectionWrapper<ViewTestClass, ClassNodeViewModel>(model.Classes, item => new ClassNodeViewModel(item)); if (IsRecentSelections) IsOpen = true; // Create commands. RemoveCommand = new DelegateCommand<Button>(button => RemoveModule()); ClickCommand = new DelegateCommand<Button>(button => { if (!IsLoading) IsOpen = !IsOpen; }); // Wire up events. if (AssemblyModel != null) { AssemblyModel.AssemblyLoadStarted += delegate { LoadStart(); }; AssemblyModel.AssemblyLoadComplete += delegate { LoadComplete(); }; } model.PropertyChanged += (s, e) => { if (e.PropertyName == ViewTestClassesModule.PropDisplayName) { UpdateDisplayName(); OnPropertyChanged<T>(m => m.DisplayName); } }; // Finish up. UpdateDisplayName(); }
public void ShouldConstruct() { var classModel = new ViewTestClass(typeof(SampleViewTestClass1), "File.xap"); var moduleModel = new ViewTestClassesModule { DisplayName = "Sample" }; moduleModel.Classes.Add(classModel); var moduleNodeVM = new ModuleNodeViewModel(moduleModel); }
public void ShouldLoadClassesFromAssembly() { var module = new ViewTestClassesModule(); PropertyChangedEventArgs args = null; module.PropertyChanged += (sender, e) => args = e; var sampleAssembly = new SampleViewTestClass1().GetType().Assembly; var count = module.AddFromAssembly(sampleAssembly, "File.xap"); count.ShouldNotBe(0); args.PropertyName.ShouldBe(ViewTestClassesModule.PropClasses); }
public void Initialize() { TestHarnessModel.ResetSingleton(); TestHarnessModel.Instance.Modules.RemoveAll(); moduleModel = new ViewTestClassesAssemblyModule(new ModuleSetting(GetType().Assembly.FullName, "File.xap")); var type = typeof (SampleViewTestClass1); classModel = new ViewTestClass(type.FullName, null, type.Assembly.FullName, "File.xap"); TestHarnessModel.Instance.Modules.Add(moduleModel); moduleNode = new ModuleNodeViewModel(moduleModel); classNode = new ClassNodeViewModel(classModel); moduleNode.Classes.Add(classNode); }
public void Initialize(ModuleSelector control) { // Setup initial conditions. control.Width = 320; control.Height = 400; // Setup sample data. var model1 = new ViewTestClassesModule { DisplayName = "Recent Selections" }; model1.Classes.Add(new ViewTestClass(typeof(ModuleSelectorViewTest), "File.xap")); model1.Classes.Add(new ViewTestClass(typeof(SampleViewTestClass1), "File.xap")); var viewModel1 = new ModuleNodeViewModel(model1); var model2 = new ViewTestClassesAssemblyModule(new ModuleSetting("Assembly.Name.xap")); model2.Classes.Add(new ViewTestClass(typeof(SampleViewTestClass1), "File.xap")); model2.Classes.Add(new ViewTestClass(typeof(SampleViewTestClass2), "File.xap")); model2.Classes.Add(new ViewTestClass(typeof(ModuleSelectorViewTest), "File.xap")); var viewModel2 = new ModuleNodeViewModel(model2); modules.Add(viewModel1); modules.Add(viewModel2); // Assign sample data to control. control.DataContext = modules; }
private void LoadRecentSelectionsModule() { // Setup initial conditions. RecentSelectionsModule = null; if (testHarness.Settings.RecentSelections.Length == 0) return; // Create the module. var module = new ViewTestClassesModule { DisplayName = StringLibrary.RecentSelections_Title }; // Populate with recent selections. LoadRecentSelectionsModule(module); // Finish up. Modules.Insert(0, module); RecentSelectionsModule = module; }
public void ClearModules() { Modules.RemoveAll(); RecentSelectionsModule = null; }
private void LoadRecentSelectionsModule(ViewTestClassesModule module) { // Setup initial conditions. if (module == null) return; // Build the new list. var list = new List<ViewTestClass>(); foreach (var setting in testHarness.Settings.RecentSelections) { list.Add(ViewTestClass.GetSingleton( setting.ClassName, setting.CustomName, setting.Module.AssemblyName, setting.Module.XapFileName)); } // Re-populate the collection. module.Classes.RemoveAll(); module.Classes.AddRange(list); }