public void GetClassWithDynamicProperty() { var profile = TestProfile.CreateEmpty(); profile.ClassGrouping = "form"; profile.Mappings.Add(new Mapping { Type = "dynamic", IfReadOnly = false, NameContains = string.Empty, Output = "<Dynamic Name=\"$name$\" />", }); var code = @" Namespace tests *Class Class1* Public Property SomeProperty As dynamic End Class End Namespace"; var expected = new AnalyzerOutput { Name = "Class1", Output = @"<form> <Dynamic Name=""SomeProperty"" /> </form>", OutputType = AnalyzerOutputType.Class, }; this.EachPositionBetweenStarsShouldProduceExpected(code, expected, profile); }
public void CanDetectWhereAndWhatToInsert() { var profile = TestProfile.CreateEmpty(); profile.Datacontext.XamlPageAttribute = "DataContext=\"HasBeenSet\""; var logger = DefaultTestLogger.Create(); var activeDocText = "<Page" + Environment.NewLine + " xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"" + Environment.NewLine + " >" + Environment.NewLine + " <!-- Content would go here -->" + Environment.NewLine + "</Page>"; var vs = new TestVisualStudioAbstraction { ActiveDocumentFileName = "test.xaml", ActiveDocumentText = activeDocText, }; var fs = new TestFileSystem(); var sut = new SetDataContextCommandLogic(profile, logger, vs, fs); var result = sut.GetPageAttributeToAdd("TestViewModel", "Tests"); Assert.IsTrue(result.anythingToAdd); Assert.AreEqual(2, result.lineNoToAddAfter); Assert.AreEqual($"{Environment.NewLine} DataContext=\"HasBeenSet\"", result.contentToAdd); }
public void DetectsWhenConstructorContentIsNotAlreadySet() { var profile = TestProfile.CreateEmpty(); profile.Datacontext.CodeBehindConstructorContent = "DataContext = ViewModel"; var logger = DefaultTestLogger.Create(); var vs = new TestVisualStudioAbstraction { ActiveDocumentFileName = "TestPage.xaml.vb", ActiveDocumentText = @"Public NotInheritable Class TestPage Inherits Page Sub New() InitializeComponent() End Sub End Class", }; var fs = new TestFileSystem(); var sut = new SetDataContextCommandLogic(profile, logger, vs, fs); var result = sut.ShouldEnableCommand(); Assert.IsTrue(result); }
public void CanDetectWhereAndWhenToInsertConstructorAndPageContentWhenConstructorExists() { var pageContent = "Public ReadOnly Property ViewModel As $viewmodelclass$" + Environment.NewLine + " Get" + Environment.NewLine + " Return New $viewmodelclass$" + Environment.NewLine + " End Get" + Environment.NewLine + "End Property"; var profile = TestProfile.CreateEmpty(); profile.ViewGeneration.XamlFileSuffix = "Page"; profile.ViewGeneration.ViewModelFileSuffix = "ViewModel"; profile.Datacontext.CodeBehindConstructorContent = "DataContext = ViewModel"; profile.Datacontext.CodeBehindPageContent = pageContent; var logger = DefaultTestLogger.Create(); var fs = new TestFileSystem { FileText = @"Public NotInheritable Class TestPage Inherits Page Sub New() InitializeComponent() End Sub End Class", }; var synTree = VisualBasicSyntaxTree.ParseText(fs.FileText); var vs = new TestVisualStudioAbstraction { ActiveDocumentFileName = "TestPage.xaml.vb", ActiveDocumentText = fs.FileText, SyntaxTree = synTree, DocumentIsCSharp = false, }; var sut = new SetDataContextCommandLogic(profile, logger, vs, fs); var documentRoot = synTree.GetRoot(); var result = sut.GetCodeBehindContentToAdd("TestPage", "TestViewModel", "TestVmNamespace", documentRoot); Assert.IsTrue(result[0].anythingToAdd); Assert.AreEqual(5, result[0].lineNoToAddAfter); StringAssert.AreEqual($"{Environment.NewLine}{Environment.NewLine}DataContext = ViewModel", result[0].contentToAdd); var expectedContent = "" + Environment.NewLine + "" + Environment.NewLine + "Public ReadOnly Property ViewModel As TestViewModel" + Environment.NewLine + " Get" + Environment.NewLine + " Return New TestViewModel" + Environment.NewLine + " End Get" + Environment.NewLine + "End Property"; Assert.IsTrue(result[1].anythingToAdd); Assert.AreEqual(8, result[1].lineNoToAddAfter); StringAssert.AreEqual(expectedContent, result[1].contentToAdd); }
public void DetectsWhenPageContentIsNotAlreadySet() { var profile = TestProfile.CreateEmpty(); profile.ViewGeneration.XamlFileSuffix = "Page"; profile.ViewGeneration.ViewModelFileSuffix = "ViewModel"; profile.Datacontext.CodeBehindPageContent = @"Public ReadOnly Property ViewModel As $viewmodelclass$ Get Return New $viewmodelclass$ End Get End Property"; var logger = DefaultTestLogger.Create(); var vs = new TestVisualStudioAbstraction { ActiveDocumentFileName = "TestPage.xaml.vb", ActiveDocumentText = @"Public NotInheritable Class TestPage Inherits Page Sub New() InitializeComponent() End Sub End Class", }; var fs = new TestFileSystem(); var sut = new SetDataContextCommandLogic(profile, logger, vs, fs); var result = sut.ShouldEnableCommand(); Assert.IsTrue(result); }
public void GetAsNewProperty() { var profile = TestProfile.CreateEmpty(); profile.Mappings.Add(new Mapping { Type = "ShellViewModel", IfReadOnly = false, NameContains = string.Empty, Output = "<Element Name=\"$name$\" />", }); var code = @" Namespace tests Class Class1 ☆Public ReadOnly Property ViewModel As New ShellViewModel End Class End Namespace"; var expected = new ParserOutput { Name = "ViewModel", Output = "<Element Name=\"ViewModel\" />", OutputType = ParserOutputType.Member, }; this.PositionAtStarShouldProduceExpected(code, expected, profile); }
public void GetClassWithDynamicListProperty() { var profile = TestProfile.CreateEmpty(); profile.ClassGrouping = "form"; profile.SubPropertyOutput = "<DymnProp Value=\"$name$\" />"; profile.Mappings.Add(new Mapping { Type = "List<dynamic>", IfReadOnly = false, NameContains = string.Empty, Output = "<Dyno>$subprops$</Dyno>", }); var code = @" Namespace tests *Class Class1* Public Property SomeList As List(Of dynamic) End Class End Namespace"; // A single "DymnProp" with no value indicates that no sub-properties of the dynamic type were found var expected = new AnalyzerOutput { Name = "Class1", Output = @"<form> <Dyno> <DymnProp Value="""" /> </Dyno> </form>", OutputType = AnalyzerOutputType.Class, }; this.EachPositionBetweenStarsShouldProduceExpected(code, expected, profile); }
private void initializeTestProfile() { try { if (!string.IsNullOrEmpty(Program.TestPerformanceFile)) { m_testProfileUri = new Uri(TestProperties.ExpandString(Program.TestPerformanceFile)); m_testTreeView.TestProfile = TestProfile.ReadFromFile(m_testProfileUri.LocalPath); } } catch (FileNotFoundException) { MessageBox.Show( string.Format("Unable to locate test performance file \"{0}\".\r\n\r\nPlease verify the file path.", Program.TestPerformanceFile), "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (SerializationException) { MessageBox.Show( string.Format("Unable to read test performance \"{0}\".\r\n\r\nPlease verify the file is a valid test performance file.", Program.TestPerformanceFile), "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (UriFormatException) { MessageBox.Show( string.Format("Unable to read test performance \"{0}\".\r\n\r\nPlease verify the file is a valid test performance file.", Program.TestPerformanceFile), "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (Exception e) { MessageBox.Show(e.Message, "Quintity TestEngineer", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public void GetDynamicProperty() { var profile = TestProfile.CreateEmpty(); profile.Mappings.Add(new Mapping { Type = "dynamic", IfReadOnly = false, NameContains = string.Empty, Output = "<Dynamic Name=\"$name$\" />", }); var code = @" namespace tests { class Class1 { ☆public dynamic SomeProperty { get; set; }☆ } }"; var expected = new ParserOutput { Name = "SomeProperty", Output = "<Dynamic Name=\"SomeProperty\" />", OutputType = ParserOutputType.Property, }; this.EachPositionBetweenStarsShouldProduceExpected(code, expected, profile); }
private Profile MethodTestProfile() { var profile = TestProfile.CreateEmpty(); profile.ClassGrouping = "StackPanel"; profile.FallbackOutput = "<TextBlock Text=\"FALLBACK_$name$\" />"; profile.Mappings.Add(new Mapping { Type = "method()", NameContains = "", Output = "<TextBlock Text=\"NOPARAMS_$method$\" />", IfReadOnly = false, }); profile.Mappings.Add(new Mapping { Type = "method(T)", NameContains = "", Output = "<TextBlock Text=\"ONEPARAM_$method$_$arg1$\" />", IfReadOnly = false, }); profile.Mappings.Add(new Mapping { Type = "method(T,T)", NameContains = "", Output = "<TextBlock Text=\"TWOPARAMS_$method$_$arg1$_$arg2$\" />", IfReadOnly = false, }); return(profile); }
public void DetectsWhenConstructorContentIsNotAlreadySet() { var profile = TestProfile.CreateEmpty(); profile.Datacontext.CodeBehindConstructorContent = "this.DataContext = this.ViewModel;"; var logger = DefaultTestLogger.Create(); var vs = new TestVisualStudioAbstraction { ActiveDocumentFileName = "test.xaml.cs", ActiveDocumentText = @"class TestPage { public TestPage() { this.Initialize(); } }", }; var fs = new TestFileSystem(); var sut = new SetDataContextCommandLogic(profile, logger, vs, fs); var result = sut.ShouldEnableCommand(); Assert.IsTrue(result); }
public void GetSelectionWithDynamicListProperty() { var profile = TestProfile.CreateEmpty(); profile.SubPropertyOutput = "<DymnProp Value=\"$name$\" />"; profile.Mappings.Add(new Mapping { Type = "List<dynamic>", IfReadOnly = false, NameContains = string.Empty, Output = "<Dyno>$subprops$</Dyno>", }); var code = @" Namespace tests Class Class1 ☆Public Property SomeList As List(Of dynamic)☆ End Class End Namespace"; var expectedXaml = "<Dyno>" + Environment.NewLine + " <DymnProp Value=\"\" />" + Environment.NewLine + "</Dyno>"; // A single "DymnProp" with no value indicates that no sub-properties of the dynamic type were found var expected = new ParserOutput { Name = "SomeList", Output = expectedXaml, OutputType = ParserOutputType.Selection, }; this.SelectionBetweenStarsShouldProduceExpected(code, expected, profile); }
public void GetSelectionWithDynamicProperty() { var profile = TestProfile.CreateEmpty(); profile.Mappings.Add(new Mapping { Type = "dynamic", IfReadOnly = false, NameContains = string.Empty, Output = "<Dynamic Name=\"$name$\" />", }); var code = @" Namespace tests *Class Class1* *Public Property SomeProperty As dynamic* End Class End Namespace"; var expected = new AnalyzerOutput { Name = "SomeProperty", Output = "<Dynamic Name=\"SomeProperty\" />", OutputType = AnalyzerOutputType.Selection, }; this.SelectionBetweenStarsShouldProduceExpected(code, expected, profile); }
public void GetSelectionWithDynamicListProperty() { var profile = TestProfile.CreateEmpty(); profile.SubPropertyOutput = "<DymnProp Value=\"$name$\" />"; profile.Mappings.Add(new Mapping { Type = "List<dynamic>", IfReadOnly = false, NameContains = string.Empty, Output = "<Dyno>$subprops$</Dyno>", }); var code = @" namespace tests { class Class1 { *public List<dynamic> SomeList { get; set; }* } }"; // A single "DymnProp" with no value indicates that no sub-properties of the dynamic type were found var expected = new AnalyzerOutput { Name = "SomeList", Output = @"<Dyno> <DymnProp Value="""" /> </Dyno>", OutputType = AnalyzerOutputType.Selection, }; this.SelectionBetweenStarsShouldProduceExpected(code, expected, profile); }
public void DetectsWhenPageContentIsNotAlreadySet() { var profile = TestProfile.CreateEmpty(); profile.ViewGeneration.XamlFileSuffix = "Page"; profile.ViewGeneration.ViewModelFileSuffix = "ViewModel"; profile.Datacontext.CodeBehindPageContent = @"public $viewmodelclass$ ViewModel { get { return new $viewmodelclass$(); } }"; var logger = DefaultTestLogger.Create(); var vs = new TestVisualStudioAbstraction { ActiveDocumentFileName = "Testpage.xaml.cs", ActiveDocumentText = @"class TestPage { public TestPage() { this.Initialize(); } }", }; var fs = new TestFileSystem(); var sut = new SetDataContextCommandLogic(profile, logger, vs, fs); var result = sut.ShouldEnableCommand(); Assert.IsTrue(result); }
public TestVerdict WritePerformanceConfig(string filePath) { try { Setup(); var testProfile = new TestProfile(2, new TimeSpan(0, 0, 0, 30, 300), "TestAnalyst"); TestProfile.WritetoFile(testProfile, filePath); testProfile = TestProfile.ReadFromFile(filePath); TestVerdict = TestVerdict.Pass; TestMessage = testProfile.ToString(); } catch (Exception e) { TestMessage += e.ToString(); TestVerdict = TestVerdict.Error; } finally { Teardown(); } return(TestVerdict); }
// This is based on GetCSharpClassTests.GetClassWithAllTheProperties private void GetNameAndType(string property, string xaml) { var code = @" namespace tests { public class TestClass { ☆" + property + @" } }"; var profile = TestProfile.CreateEmpty(); profile.ClassGrouping = "StackPanel"; profile.FallbackOutput = "<TextBlock Name=\"$name$\" Type=\"$type$\" />"; var expected = new ParserOutput { Name = "IgNoRe", Output = xaml, OutputType = ParserOutputType.Member, }; this.PositionAtStarShouldProduceExpected(code, expected, profile); }
public void GetStructProperty() { var profile = TestProfile.CreateEmpty(); profile.Mappings.Add(new Mapping { Type = "MyStruct", IfReadOnly = false, NameContains = string.Empty, Output = "<MyStruct />", }); var code = @" Namespace tests Class Class1 ☆Public Property Property2 As MyStruct☆ End Class Structure MyStruct Public Property MyProperty1 As String Public Property MyProperty2 As Integer End Structure End Namespace"; var expected = new ParserOutput { Name = "Property2", Output = "<MyStruct />", OutputType = ParserOutputType.Property, }; this.EachPositionBetweenStarsShouldProduceExpected(code, expected, profile); }
public void CanDetectIfNotAlreadySet() { var profile = TestProfile.CreateEmpty(); profile.Datacontext.XamlPageAttribute = "DataContext=\"HasBeenSet\""; var logger = DefaultTestLogger.Create(); var vs = new TestVisualStudioAbstraction { ActiveDocumentFileName = "test.xaml", ActiveDocumentText = @"<Page > <!-- Content would go here --> </Page>", }; var fs = new TestFileSystem(); var sut = new SetDataContextCommandLogic(profile, logger, vs, fs); var result = sut.ShouldEnableCommand(); Assert.IsTrue(result); }
public void CanDetectWhereAndWhenToInsertPageContentAndConstructorExists() { var pageContent = "public $viewmodelclass$ ViewModel" + Environment.NewLine + "{" + Environment.NewLine + " get" + Environment.NewLine + " {" + Environment.NewLine + " return new $viewmodelclass$();" + Environment.NewLine + " }" + Environment.NewLine + "}"; var profile = TestProfile.CreateEmpty(); profile.ViewGeneration.XamlFileSuffix = "Page"; profile.ViewGeneration.ViewModelFileSuffix = "ViewModel"; profile.Datacontext.CodeBehindPageContent = pageContent; var logger = DefaultTestLogger.Create(); var fileText = "class TestPage" + Environment.NewLine + "{" + Environment.NewLine + " public TestPage()" + Environment.NewLine + " {" + Environment.NewLine + " this.Initialize();" + Environment.NewLine + " }" + Environment.NewLine + "}"; var fs = new TestFileSystem { FileText = fileText, }; var synTree = CSharpSyntaxTree.ParseText(fs.FileText); var vs = new TestVisualStudioAbstraction { ActiveDocumentFileName = "TestPage.xaml.cs", ActiveDocumentText = fs.FileText, SyntaxTree = synTree, DocumentIsCSharp = true, }; var sut = new SetDataContextCommandLogic(profile, logger, vs, fs); var (anythingToAdd, lineNoToAddAfter, contentToAdd) = sut.GetCodeBehindPageContentToAdd(vs.ActiveDocumentText, vs.SyntaxTree.GetRoot(), "TestViewModel", "TestVmNamespace"); var expectedContent = "" + Environment.NewLine + "" + Environment.NewLine + "public TestViewModel ViewModel" + Environment.NewLine + "{" + Environment.NewLine + " get" + Environment.NewLine + " {" + Environment.NewLine + " return new TestViewModel();" + Environment.NewLine + " }" + Environment.NewLine + "}"; Assert.IsTrue(anythingToAdd); Assert.AreEqual(6, lineNoToAddAfter); StringAssert.AreEqual(expectedContent, contentToAdd); }
protected virtual Profile GetProfile() { var profile = new TestProfile(StubLogger, PassPhrase); CreateTestMaps(profile); return(profile); }
public void GetClassAttributeWithoutType() { var profile = TestProfile.CreateEmpty(); profile.ClassGrouping = "StackPanel"; profile.FallbackOutput = "<TextBlock Text=\"FALLBACK_$name$\" />"; profile.Mappings.Add(new Mapping { Type = "T", NameContains = "", Output = "<TextBlock Text=\"T_$name$\" />", IfReadOnly = false, }); profile.Mappings.Add(new Mapping { Type = "[Hidden]", NameContains = "", Output = "<TextBlock Text=\"HIDDEN__$name$\" />", IfReadOnly = false, }); profile.Mappings.Add(new Mapping { Type = "[Hidden]string", NameContains = "", Output = "<TextBlock Text=\"HIDDEN_STRING_$name$\" />", IfReadOnly = false, }); var code = @" namespace tests { class Class1☆ { public string Property1 { get; set; } public int Property2 { get; set; } [Hidden] public string Property5 { get; set; } [Hidden] public int Property6 { get; set; } } }"; var expectedOutput = "<StackPanel>" + Environment.NewLine + " <TextBlock Text=\"T_Property1\" />" + Environment.NewLine + " <TextBlock Text=\"T_Property2\" />" + Environment.NewLine + " <TextBlock Text=\"HIDDEN_STRING_Property5\" />" + Environment.NewLine + " <TextBlock Text=\"HIDDEN__Property6\" />" + Environment.NewLine + "</StackPanel>"; var expected = new ParserOutput { Name = "Class1", Output = expectedOutput, OutputType = ParserOutputType.Class, }; this.PositionAtStarShouldProduceExpected(code, expected, profile); }
protected Profile GetProfileForTesting() { var profile = TestProfile.CreateEmpty(); profile.ClassGrouping = "StackPanel"; profile.FallbackOutput = "<TextBlock Text=\"$name$\" />"; return(profile); }
public void GetListOfStructProperty() { var profile = TestProfile.CreateEmpty(); profile.SubPropertyOutput = "<$name$ />"; profile.Mappings.Add(new Mapping { Type = "List<MyStruct>", IfReadOnly = false, NameContains = string.Empty, Output = "$subprops$", }); profile.Mappings.Add(new Mapping { Type = "string", IfReadOnly = false, NameContains = string.Empty, Output = "<String Name=\"$name$\" />", }); profile.Mappings.Add(new Mapping { Type = "int", IfReadOnly = false, NameContains = string.Empty, Output = "<Int Name=\"$name$\" />", }); var code = @" using System.Collections.Generic; namespace tests { class Class1 { ☆public List<MyStruct> MyListProperty { get; set; }☆ } struct MyStruct { public string MyProperty1 { get; set; } public int MyProperty2 { get; set; } } }"; var expectedXaml = "<MyProperty1 />" + Environment.NewLine + "<MyProperty2 />"; var expected = new ParserOutput { Name = "MyListProperty", Output = expectedXaml, OutputType = ParserOutputType.Property, }; this.EachPositionBetweenStarsShouldProduceExpected(code, expected, profile); }
public void AutoMapper_Mapping_SalesOrderAddressViewModel_IsValid() { var profile = new TestProfile(); new SalesOrder.AddressViewModel().Mapping(profile); var config = new MapperConfiguration(cfg => cfg.AddProfile(profile)); config.AssertConfigurationIsValid(); }
public void AutoMapper_Mapping_UpdateCustomerAddress_IsValid() { var profile = new TestProfile(); new Core.Models.UpdateCustomer.Address().Mapping(profile); var config = new MapperConfiguration(cfg => cfg.AddProfile(profile)); config.AssertConfigurationIsValid(); }
public ActionResult DeleteConfirmed(string id) { TestProfile testProfile = db.TestProfiles.Find(id); // delete the segments... db.TestProfileSegments.RemoveRange(db.TestProfileSegments.Where(x => x.ProfileId == id)); db.TestProfiles.Remove(testProfile); db.SaveChanges(); return(RedirectToAction("Index")); }
public void CheckConstructorRequiredParam_Logger() { var profile = TestProfile.CreateEmpty(); var fileContents = " // Just a comment"; (IFileSystemAbstraction fs, IVisualStudioAbstraction vsa) = this.GetVbAbstractions(fileContents); var sut = new DropHandlerLogic(null, vsa); }
public void Should_map_properties_with_same_name() { var mappingOptions = new TestProfile(); //mappingOptions.SourceMemberNamingConvention = new PascalCaseNamingConvention(); //mappingOptions.DestinationMemberNamingConvention = new PascalCaseNamingConvention(); var typeMap = _factory.CreateTypeMap(typeof(Source), typeof(Destination), mappingOptions, MemberList.Destination); var propertyMaps = typeMap.GetPropertyMaps(); propertyMaps.Count().ShouldEqual(2); }
public void CanDetectWhereAndWhenToInsertPageContentAndConstructorExists() { var profile = TestProfile.CreateEmpty(); profile.ViewGeneration.XamlFileSuffix = "Page"; profile.ViewGeneration.ViewModelFileSuffix = "ViewModel"; profile.Datacontext.CodeBehindPageContent = @"Public ReadOnly Property ViewModel As $viewmodelclass$ Get Return New $viewmodelclass$ End Get End Property"; var logger = DefaultTestLogger.Create(); var fs = new TestFileSystem { FileText = @"Public NotInheritable Class TestPage Inherits Page Sub New() InitializeComponent() End Sub End Class", }; var synTree = VisualBasicSyntaxTree.ParseText(fs.FileText); var vs = new TestVisualStudioAbstraction { ActiveDocumentFileName = "TestPage.xaml.vb", ActiveDocumentText = fs.FileText, SyntaxTree = synTree, DocumentIsCSharp = false, }; var sut = new SetDataContextCommandLogic(profile, logger, vs, fs); var(anythingToAdd, lineNoToAddAfter, contentToAdd) = sut.GetCodeBehindPageContentToAdd(vs.ActiveDocumentText, vs.SyntaxTree.GetRoot(), "TestViewModel", "TestVmNamespace"); var expectedContent = @" Public ReadOnly Property ViewModel As TestViewModel Get Return New TestViewModel End Get End Property"; Assert.IsTrue(anythingToAdd); Assert.AreEqual(6, lineNoToAddAfter); Assert.AreEqual(expectedContent, contentToAdd); }