Represents a method decorated with the [ViewTestClass] attribute.
Inheritance: Open.Core.Common.ModelBase
        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 ClassNodeViewModel(ViewTestClass model)
        {
            // Setup initial conditions.
            Model = model;

            // Wire up events.
            modelObserver = new PropertyObserver<ViewTestClass>(model)
                    .RegisterHandler(m => m.DisplayName, m => OnPropertyChanged<T>(o => o.DisplayName))
                    .RegisterHandler(m => m.IsCurrent, m => FireCurrentChanged());
            harnessObserver = new PropertyObserver<TestHarnessModel>(TestHarnessModel.Instance)
                    .RegisterHandler(m => m.CurrentClass, m => FireCurrentChanged());
        }
        public void ShouldConstructFromType()
        {
            var sampleType = new SampleViewTestClass1().GetType(); // NB: Instance used to get actual SL type of (instead of 'typeof' which returns native Type).
            var model = new ViewTestClass(sampleType, "File.xap");

            model.TypeName.ShouldBe(sampleType.FullName);
            model.AssemblyName.ShouldBe(ReflectionUtil.GetAssemblyName(sampleType.Assembly.FullName));
            model.IsActivated.ShouldBe(true);

            Assert.AreEqual(sampleType, model.Type);
            Assert.IsNotNull(model.Attribute);
        }
        public void TestSetup()
        {
            TestHarnessModel.ResetSingleton();
            TestRunnerMockViewTest.InvokeCount = 0;

            viewTestRunner = new ViewTestRunner { Interval = 0.01 };

            module = new ViewTestClassesAssemblyModule(new ModuleSetting());
            module.LoadAssembly(GetType().Assembly);

            testClass = module.GetTestClasses("TestRunnerMockViewTest").FirstOrDefault();
            testMethodInfo = testClass.GetTestMethod("SampleTestRunnerMethod").MethodInfo;
        }
        public void Initialize()
        {
            TestHarnessModel.ResetSingleton();
            var testHarness = TestHarnessModel.Instance;
            testHarness.Modules.RemoveAll();

            classModel = new ViewTestClass(typeof(SampleViewTestClass1), "File.xap");

            moduleModel = new ViewTestClassesAssemblyModule(new ModuleSetting(sampleAssembly.FullName, "File.xap"));
            moduleModel.LoadAssembly(sampleAssembly);
            moduleModel.Classes.Add(classModel);

            testHarness.Modules.Add(moduleModel);
        }
        public DisplayContainerViewModel(ViewTestClass model)
        {
            // Setup initial conditions.
            this.model = model;

            // Create wrapper collection.
            CurrentControls = new ObservableCollectionWrapper<object, DisplayItemViewModel>(
                                                model.CurrentControls,
                                                control => new DisplayItemViewModel(this, control as UIElement));

            // Wire up events.
            modelObserver = new PropertyObserver<ViewTestClass>(model)
                .RegisterHandler(m => m.CurrentViewTest, m => OnCurrentViewTestChanged());
        }
        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()
        {
            TestHarnessModel.ResetSingleton();
            var testHarness = TestHarnessModel.Instance;
            testHarness.Modules.RemoveAll();

            classModel = new ViewTestClass(typeof(SampleViewTestClass1), "File.xap");

            moduleModel = new ViewTestClassesAssemblyModule(new ModuleSetting(GetType().Assembly.FullName, "File.xap"));
            moduleModel.Classes.Add(classModel);
            testHarness.Modules.Add(moduleModel);

            rootVm = new RootViewModel();
            selectorPanelVm = new SelectorPanelViewModel(rootVm);
        }
        public void TestInitialize()
        {
            TestHarnessModel.ResetSingleton();
            var testHarness = TestHarnessModel.Instance;
            testHarness.Modules.RemoveAll();

            classModel = new ViewTestClass(typeof(SampleViewTestClass1), "File.xap");

            moduleModel = new ViewTestClassesAssemblyModule(new ModuleSetting(GetType().Assembly.FullName, "File.xap"));
            moduleModel.Classes.Add(classModel);
            testHarness.Modules.Add(moduleModel);

            classModel.IsCurrent = true;
            testModel = classModel.ViewTests[0];
        }
 public void ShouldReturnFirstTestMarkedAsDefault()
 {
     var model = new ViewTestClass(typeof(SampleViewTestClass1), "File.xap");
     model.DefaultViewTest.MethodInfo.Name.ShouldBe(SampleViewTestClass1.PropMethod2);
 }
        public void ShouldUpdateCurrentModuleAndClass()
        {
            TestHarnessModel.ResetSingleton();
            var testHarness = TestHarnessModel.Instance;

            var args = new List<string>();
            testHarness.PropertyChanged += (sender, e) => args.Add(e.PropertyName);

            var class1 = new ViewTestClass(typeof(SampleViewTestClass1), "File.xap");
            var class2 = new ViewTestClass(typeof(SampleViewTestClass1), "File.xap");

            var module1 = new ViewTestClassesAssemblyModule(new ModuleSetting(GetType().Assembly.FullName, "File.xap"));
            var module2 = new ViewTestClassesAssemblyModule(new ModuleSetting(GetType().Assembly.FullName, "File.xap"));

            module1.Classes.Add(class1);
            module2.Classes.Add(class2);

            testHarness.Modules.Add(module1);
            testHarness.Modules.Add(module2);

            testHarness.CurrentClass.ShouldBe(null);

            // -------------

            class1.IsCurrent = true;
            testHarness.CurrentClass.ShouldBe(class1);
            args.ShouldContain(TestHarnessModel.PropCurrentClass);
            args.Clear();

            class2.IsCurrent = true;
            testHarness.CurrentClass.ShouldBe(class2);
            args.ShouldContain(TestHarnessModel.PropCurrentClass);
            args.Clear();

            class1.IsCurrent.ShouldBe(false);
            module1.CurrentClass.ShouldBe(null);

            class2.IsCurrent = false;
            testHarness.CurrentClass.ShouldBe(null);
            args.ShouldContain(TestHarnessModel.PropCurrentClass);
            args.Clear();

            TestHarnessModel.ResetSingleton();
        }
 public void ShouldHaveNullAsDefaultTestIfNoTestsExist()
 {
     var model = new ViewTestClass(typeof(SampleViewTestClassEmpty), "File.xap");
     model.DefaultViewTest.ShouldBe(null);
 }
 /// <summary>Removes the specified item from the recent selections list.</summary>
 /// <param name="item">The item to remove.</param>
 /// <param name="silent">Flag indicating if the corresponding property-change event should be fired.</param>
 public void RemoveRecentSelection(ViewTestClass item, bool silent)
 {
     var list = new List<RecentSelectionSetting>(RecentSelections);
     if (RemoveItem(item, list)) SetRecentSelections(list.ToArray());
 }
        public void ShouldChangeCurrentControls()
        {
            var classModel = new ViewTestClass(typeof(SampleViewTestClass1), "File.xap");
            
            var args = new List<string>();
            classModel.PropertyChanged += (sender, e) => args.Add(e.PropertyName);

            classModel.CurrentControls.Count.ShouldBe(3);
            classModel.ViewTests[0].Execute();

            args.ShouldContain(LinqExtensions.GetPropertyName<ViewTestClass>(m => m.CurrentControls));

            classModel.CurrentControls.Count.ShouldBe(1);
        }
        public void ShouldAlertWhenChildMethodExecuteRequestIsMade()
        {
            var sampleType = new SampleViewTestClass1().GetType(); // NB: Instance used to get actual SL type of (instead of 'typeof' which returns native Type).
            var classModel = new ViewTestClass(sampleType, "File.xap");
            var testModel = classModel.ViewTests[2];
            testModel.ShouldNotBe(classModel.DefaultViewTest);

            classModel.CurrentViewTest.ShouldBe(classModel.DefaultViewTest);

            var argsProp = new List<string>();
            classModel.PropertyChanged += (sender, e) => argsProp.Add(e.PropertyName);

            TestExecuteEventArgs argsExecuteRequest = null;
            classModel.ExecuteRequest += (sender, e) => argsExecuteRequest = e;

            testModel.Execute();
            argsExecuteRequest.ShouldNotBe(null);
            argsProp.ShouldContain(LinqExtensions.GetPropertyName<ViewTestClass>(m => m.CurrentViewTest));

            classModel.CurrentViewTest.ShouldBe(testModel);
        }
 public void ShouldHaveNoTags()
 {
     classModel = new ViewTestClass(typeof(SampleViewTestClass2), "File.xap");
     classModel.ViewTests[0].Tags.Count().ShouldBe(0);
 }
 public void ShouldHaveEmptyCollectionOfViewTests()
 {
     var model = new ViewTestClass(typeof(SampleViewTestClassEmpty), "File.xap");
     model.ViewTests.Count.ShouldBe(0);
 }
        public void ShouldReturnParentModule()
        {
            TestHarnessModel.ResetSingleton();
            var testHarness = TestHarnessModel.Instance;
            testHarness.Modules.RemoveAll();

            var classModel = new ViewTestClass(typeof(SampleViewTestClass2), "File.xap");
            var moduleModel = new ViewTestClassesAssemblyModule(new ModuleSetting(typeof(SampleViewTestClass2).Assembly.FullName, "File.xap"));

            moduleModel.Classes.Add(classModel);
            testHarness.Modules.Add(moduleModel);
            testHarness.Modules.Count.ShouldBe(1);

            var retrievedModule = classModel.ParentModule;
            retrievedModule.ShouldBe(moduleModel);
        }
 public void ShouldHaveTwoTags()
 {
     var model = new ViewTestClass((new TwoTags().GetType()), "File.xap");
     model.Tags.Count().ShouldBe(2);
     model.Tags.ElementAt(0).ShouldBe("One");
     model.Tags.ElementAt(1).ShouldBe("Two");
 }
        public void ShouldNotGetMethod()
        {
            var sampleType = new Sample().GetType(); // NB: Instance used to get actual SL type of (instead of 'typeof' which returns native Type).
            var model = new ViewTestClass(sampleType, "File.xap");

            model.GetTestMethod(null).ShouldBe(null);
            model.GetTestMethod("").ShouldBe(null);
            model.GetTestMethod("  ").ShouldBe(null);
        }
        public void ShouldGetMethod()
        {
            var sampleType = new Sample().GetType(); // NB: Instance used to get actual SL type of (instead of 'typeof' which returns native Type).
            var model = new ViewTestClass(sampleType, "File.xap");

            var method = model.GetTestMethod("method1");
            method.ShouldNotBe(null);
            model.ViewTests.ShouldContain(method);
        }
        public void ShouldReportEquivalent()
        {
            var type1 = typeof(SampleViewTestClass1);

            var model1A = new ViewTestClass(type1, "File.xap");
            var model1B = new ViewTestClass(type1.FullName, null, type1.Assembly.GetAssemblyName(), "File.xap");

            model1A.IsEquivalent(type1).ShouldBe(true);
            model1B.IsEquivalent(type1).ShouldBe(true);

            var model2 = new ViewTestClass(typeof(SampleViewTestClass2), "File.xap");
            model2.IsEquivalent(type1).ShouldBe(false);
        }
        public void ShouldReuseExistingControlInstances()
        {
            var classModel = new ViewTestClass(typeof(SampleViewTestClass1), "File.xap");

            var firstInstance = classModel.CurrentControls[0];
            classModel.ViewTests[0].Execute();
            classModel.CurrentControls[0].ShouldBe(firstInstance);
        }
 public void ShouldReturnNullIfNoDefaultTestsSpecified()
 {
     var model = new ViewTestClass(typeof(SampleViewTestClass2), "File.xap");
     model.DefaultViewTest.ShouldBe(null);
 }
 public void TestInitialize()
 {
     classModel = new ViewTestClass(typeof(SampleViewTestClass1), "File.xap");
     viewModel = new DisplayContainerViewModel(classModel);
 }
        public void ShouldLazyLoadFromString()
        {
            var sampleType = new SampleViewTestClass1().GetType(); // NB: Instance used to get actual SL type of (instead of 'typeof' which returns native Type).
            var typeName = sampleType.FullName;
            var assemblyName = sampleType.Assembly.FullName;
            var model = new ViewTestClass(typeName, null, assemblyName, "File.xap");

            model.TypeName.ShouldBe(typeName);
            model.IsActivated.ShouldBe(false);

            // Activate from Type.
            model.Type.ShouldNotBe(null);
            model.Type.FullName.ShouldBe(typeName);
            model.IsActivated.ShouldBe(true);

            // Activate from Attribute.
            model = new ViewTestClass(typeName, null, assemblyName, "File.xap");
            model.IsActivated.ShouldBe(false);
            model.Attribute.ShouldNotBe(null);
            model.IsActivated.ShouldBe(true);

            // Activate from ViewTests.
            model = new ViewTestClass(typeName, null, assemblyName, "File.xap");
            model.IsActivated.ShouldBe(false);
            model.ViewTests.Count.ShouldNotBe(0);
            model.IsActivated.ShouldBe(true);
        }
 public void ShouldHaveNoTags()
 {
     var model = new ViewTestClass((new Sample().GetType()), "File.xap");
     model.Tags.Count().ShouldBe(0);
 }
 private static bool RemoveItem(ViewTestClass item, ICollection<RecentSelectionSetting> collection)
 {
     var match = collection.FirstOrDefault(
         setting => 
         setting.Module.AssemblyName == item.AssemblyName 
         && setting.ClassName == item.TypeName);
     if (match == null) return false;
     collection.Remove(match);
     return true;
 }
 public void ShouldHaveCollectionOfViewTests()
 {
     var sampleType = new SampleViewTestClass1().GetType(); // NB: Instance used to get actual SL type of (instead of 'typeof' which returns native Type).
     var model = new ViewTestClass(sampleType, "File.xap");
     model.ViewTests.Count.ShouldBe(4);
 }
        public void ShouldExposeCurrentControls()
        {
            var classModel = new ViewTestClass(typeof(SampleViewTestClass1), "File.xap");

            classModel.CurrentViewTest.ShouldBe(classModel.DefaultViewTest);
            classModel.CurrentViewTest.MethodInfo.Name.ShouldBe(SampleViewTestClass1.PropMethod2);

            classModel.CurrentControls.Count.ShouldBe(3);
            classModel.CurrentControls[0].GetType().ShouldBe(typeof(Placeholder));
            classModel.CurrentControls[1].GetType().ShouldBe(typeof(Border));
            classModel.CurrentControls[2].GetType().ShouldBe(typeof(Placeholder));

            classModel.CurrentControls[0].ShouldNotBe(classModel.CurrentControls[2]);
        }