protected void PositionAtStarShouldProduceExpected(string code, AnalyzerOutput expected, bool isCSharp, Profile profileOverload) { var pos = code.IndexOf("*", StringComparison.Ordinal); var syntaxTree = isCSharp ? CSharpSyntaxTree.ParseText(code.Replace("*", string.Empty)) : VisualBasicSyntaxTree.ParseText(code.Replace("*", string.Empty)); Assert.IsNotNull(syntaxTree); var semModel = isCSharp ? CSharpCompilation.Create(string.Empty).AddSyntaxTrees(syntaxTree).GetSemanticModel(syntaxTree, true) : VisualBasicCompilation.Create(string.Empty).AddSyntaxTrees(syntaxTree).GetSemanticModel(syntaxTree, true); var analyzer = isCSharp ? new CSharpAnalyzer(DefaultTestLogger.Create()) as IDocumentAnalyzer : new VisualBasicAnalyzer(DefaultTestLogger.Create()); var actual = analyzer.GetSingleItemOutput(syntaxTree.GetRoot(), semModel, pos, profileOverload); Assert.AreEqual(expected.OutputType, actual.OutputType); Assert.AreEqual(expected.Name, actual.Name); Assert.AreEqual(expected.Output, actual.Output); }
public void GetCustomPropertyWithSpecificMapping() { var orderProfile = new Profile { Name = "GridTestProfile", ClassGrouping = "Grid", FallbackOutput = "<TextBlock Text=\"FALLBACK_$name$\" />", SubPropertyOutput = "<TextBlock Text=\"SP_$name$\" />", Mappings = new ObservableCollection <Mapping> { new Mapping { Type = "Order", NameContains = "", Output = "<TextBlock Text=\"$name$\" x:Order=\"true\" />", IfReadOnly = false, }, }, }; var code = @" Namespace tests Class Class1 ☆Public Property LastOrder As Order☆ End Class Public Class Order Public Property OrderId As Int Public Property OrderDescription As String End Class End Namespace"; var expected = new AnalyzerOutput { Name = "LastOrder", Output = "<TextBlock Text=\"LastOrder\" x:Order=\"true\" />", OutputType = AnalyzerOutputType.Property, }; this.EachPositionBetweenStarsShouldProduceExpected(code, expected, orderProfile); }
public void Check_GridWithRowDefsIndicator_IsNotCaseSensitive() { var gridProfile = new Profile { Name = "GridTestProfile", ClassGrouping = "GrId-PlUs-RoWdEfS", FallbackOutput = "<TextBlock Text=\"FALLBACK_$name$\" />", SubPropertyOutput = "<TextBlock Text=\"SP_$name$\" />", Mappings = new ObservableCollection <Mapping> { new Mapping { Type = "string", NameContains = "", Output = "<TextBlock Text=\"$name$\" Grid.Row=\"$incint$\" />", IfReadOnly = false, }, }, }; var code = @" Public Class Class100 * Public Property Property1 As String End Class"; var expectedOutput = "<Grid>" + Environment.NewLine + "<Grid.RowDefinitions>" + Environment.NewLine + "<RowDefinition Height=\"*\" />" + Environment.NewLine + "</Grid.RowDefinitions>" + Environment.NewLine + "<TextBlock Text=\"Property1\" Grid.Row=\"0\" />" + Environment.NewLine + "</Grid>"; var expected = new AnalyzerOutput { Name = "Class100", Output = expectedOutput, OutputType = AnalyzerOutputType.Class, }; this.PositionAtStarShouldProduceExpected(code, expected, gridProfile); }
public void GetClassAndSubPropertiesInGenericList_ForClassInExternalLibrary() { var recurseProfile = new Profile { Name = "GridTestProfile", ClassGrouping = "Grid", FallbackOutput = "<TextBlock Text=\"FB_$name$\" />", SubPropertyOutput = "<TextBlock Text=\"SP_$name$\" />", Mappings = new ObservableCollection <Mapping> { new Mapping { Type = "ObservableCollection<T>", NameContains = "", Output = "<ListView><ListView.ItemTemplate><DataTemplate><StackPanel>$subprops$</StackPanel></DataTemplate></ListView.ItemTemplate></ListView>", IfReadOnly = false, }, }, }; var code = @" Pu*blic Class Class1 Public Property PastOrders As ObservableCollection(Of TestLibrary.TestClass) End Class"; var expectedOutput = "<Grid>" + Environment.NewLine + "<ListView><ListView.ItemTemplate><DataTemplate><StackPanel>" + Environment.NewLine + "<TextBlock Text=\"SP_TestProperty\" />" + Environment.NewLine + "<TextBlock Text=\"SP_BaseTestProperty\" />" + Environment.NewLine + "</StackPanel></DataTemplate></ListView.ItemTemplate></ListView>" + Environment.NewLine + "</Grid>"; var expected = new AnalyzerOutput { Name = "Class1", Output = expectedOutput, OutputType = AnalyzerOutputType.Class, }; this.PositionAtStarShouldProduceExpectedUsingAdditonalLibraries(code, expected, recurseProfile, TestLibraryPath); }
public void ClassGroupingWithExtraProperties() { var extraGroupPropertiesProfile = new Profile { Name = "GridTestProfile", ClassGrouping = "StackPanel Orientation=\"Horizontal\"", FallbackOutput = "<TextBlock Text=\"FALLBACK_$name$\" />", Mappings = new ObservableCollection <Mapping> { new Mapping { Type = "string", NameContains = "", Output = "<TextBlock Text=\"$name$\" />", IfReadOnly = false, }, }, }; var code = @" namespace tests { class Class100 * { public string Property1 { get; set; } } }"; var expectedOutput = "<StackPanel Orientation=\"Horizontal\">" + Environment.NewLine + "<TextBlock Text=\"Property1\" />" + Environment.NewLine + "</StackPanel>"; var expected = new AnalyzerOutput { Name = "Class100", Output = expectedOutput, OutputType = AnalyzerOutputType.Class, }; this.PositionAtStarShouldProduceExpected(code, expected, extraGroupPropertiesProfile); }
public void GetGenericListProperty() { var code = @" Imports System.Collections.Generic Namespace tests Class Class1 ☆Public Property MyListProperty As List(Of String)☆ End Class End Namespace"; var expected = new AnalyzerOutput { Name = "MyListProperty", Output = "<ItemsControl ItemsSource=\"{x:Bind MyListProperty}\">" + Environment.NewLine + "</ItemsControl>", OutputType = AnalyzerOutputType.Property, }; this.EachPositionBetweenStarsShouldProduceExpected(code, expected); }
public void GetIntProperty() { var code = @" namespace tests { class Class1 { ☆public int SomeProperty { get; set; }☆ } }"; var expected = new AnalyzerOutput { Name = "SomeProperty", Output = "<Slider Minimum=\"0\" Maximum=\"100\" x:Name=\"SomeProperty\" Value=\"{x:Bind SomeProperty, Mode=TwoWay}\" />", OutputType = AnalyzerOutputType.Property, }; this.EachPositionBetweenStarsShouldProduceExpected(code, expected); }
protected void SelectionBetweenStarsShouldProduceExpected(string code, AnalyzerOutput expected, bool isCSharp, Profile profileOverload) { var startPos = code.IndexOf("*", StringComparison.Ordinal); var endPos = code.LastIndexOf("*", StringComparison.Ordinal) - 1; var syntaxTree = isCSharp ? CSharpSyntaxTree.ParseText(code.Replace("*", string.Empty)) : VisualBasicSyntaxTree.ParseText(code.Replace("*", string.Empty)); Assert.IsNotNull(syntaxTree); var semModel = isCSharp ? CSharpCompilation.Create(string.Empty).AddSyntaxTrees(syntaxTree).GetSemanticModel(syntaxTree, true) : VisualBasicCompilation.Create(string.Empty).AddSyntaxTrees(syntaxTree).GetSemanticModel(syntaxTree, true); var analyzer = isCSharp ? new CSharpAnalyzer(DefaultTestLogger.Create()) as IDocumentAnalyzer : new VisualBasicAnalyzer(DefaultTestLogger.Create()); var actual = analyzer.GetSelectionOutput(syntaxTree.GetRoot(), semModel, startPos, endPos, new TestVisualStudioAbstraction().XamlIndent, profileOverload); Assert.AreEqual(expected.OutputType, actual.OutputType); Assert.AreEqual(expected.Name, actual.Name); StringAssert.AreEqual(expected.Output, actual.Output); }
public void CanHandleMultipleNumberReplacementsForClass() { var gridProfile = new Profile { Name = "GridTestProfile", ClassGrouping = "Grid", FallbackOutput = "<TextBlock Text=\"FALLBACK_$name$\" />", SubPropertyOutput = "<TextBlock Text=\"SP_$name$\" />", Mappings = new ObservableCollection <Mapping> { new Mapping { Type = "string", NameContains = "", Output = "<TextBlock Text=\"$name$\" Grid.Row=\"$incint$\" />", IfReadOnly = false, }, }, }; var code = @" Public Class Class100* Public Property Property1 As String Public Property Property2 As String End Class"; var expectedOutput = "<Grid>" + Environment.NewLine + "<TextBlock Text=\"Property1\" Grid.Row=\"0\" />" + Environment.NewLine + "<TextBlock Text=\"Property2\" Grid.Row=\"1\" />" + Environment.NewLine + "</Grid>"; var expected = new AnalyzerOutput { Name = "Class100", Output = expectedOutput, OutputType = AnalyzerOutputType.Class, }; this.PositionAtStarShouldProduceExpected(code, expected, gridProfile); }
public void GetClassAllPropertyOptions() { var code = @" Public Class Class1 Private _property8 As String * Public Property Property1 As String // include NOT readonly Public ReadOnly Property Property2 As String // include readonly Protected Property Property3 As String // DO NOT include Private Property Property4 As String // DO NOT include Public Property Property5 As Integer // include NOT readonly Public Property Property6 As List(Of String) // include NOT readonly Friend Property Property7 As String // DO NOT include Public Property Property8 As String Get Return _property8 End Get Set _property8 = value End Set End Property // include NOT readonly End Class"; var expectedOutput = "<StackPanel>" + Environment.NewLine + "<TextBox Text=\"{x:Bind Property1, Mode=TwoWay}\" />" + Environment.NewLine + "<TextBlock Text=\"Property2\" />" + Environment.NewLine + "<Slider Minimum=\"0\" Maximum=\"100\" x:Name=\"Property5\" Value=\"{x:Bind Property5, Mode=TwoWay}\" />" + Environment.NewLine + "<ItemsControl ItemsSource=\"{x:Bind Property6}\"></ItemsControl>" + Environment.NewLine + "<TextBox Text=\"{x:Bind Property8, Mode=TwoWay}\" />" + Environment.NewLine + "</StackPanel>"; var expected = new AnalyzerOutput { Name = "Class1", Output = expectedOutput, OutputType = AnalyzerOutputType.Class, }; this.PositionAtStarShouldProduceExpected(code, expected); }
public void MappingSupportsGenericTypeInVBAndCSFormats() { var profile = TestProfile.CreateEmpty(); profile.SubPropertyOutput = "<DymnProp Value=\"$name$\" />"; profile.Mappings.Add(new Mapping { Type = "List<Int>", IfReadOnly = false, NameContains = string.Empty, Output = "<Int />", }); profile.Mappings.Add(new Mapping { Type = "List(Of String)", IfReadOnly = false, NameContains = string.Empty, Output = "<String />", }); var code = @" namespace tests { class Class1 { ☆public List<Int> SomeInts { get; set; } public List<String> SomeStrings { get; set; }☆ } }"; var expected = new AnalyzerOutput { Name = "SomeInts and SomeStrings", Output = "<Int />" + Environment.NewLine + "<String />", OutputType = AnalyzerOutputType.Selection, }; this.SelectionBetweenStarsShouldProduceExpected(code, expected, profile); }
public void HandleSubPropertiesOfSimpleProperty() { var recurseProfile = new Profile { Name = "GridTestProfile", ClassGrouping = "Grid", FallbackOutput = "<TextBlock Text=\"FB_$name$\" />", SubPropertyOutput = "<TextBlock Text=\"SP_$name$\" />", Mappings = new ObservableCollection <Mapping> { new Mapping { Type = "string", NameContains = "LastOrder", Output = "<StackPanel>$subprops$</StackPanel>", IfReadOnly = false, }, }, }; var code = @" Namespace tests Public Class Class1 ☆Public Property LastOrder As String☆ End Class End Namespace"; var expectedOutput = "<StackPanel>" + Environment.NewLine + " <TextBlock Text=\"SP_\" />" + Environment.NewLine + "</StackPanel>"; var expected = new AnalyzerOutput { Name = "LastOrder", Output = expectedOutput, OutputType = AnalyzerOutputType.Property, }; this.EachPositionBetweenStarsShouldProduceExpected(code, expected, recurseProfile); }
public void GetArrayPropertiesInClass() { var code = @" Namespace tests Class Cla*ss1 Public Property MyBool As Boolean Public Property MyArray As Array Public Property MyArrayBool() As Boolean End Class End Namespace"; var expected = new AnalyzerOutput { Name = "Class1", Output = @"<Bool /> <Array /> <ArrayBool />", OutputType = AnalyzerOutputType.Class, }; this.PositionAtStarShouldProduceExpected(code, expected, this.ArrayTestsProfile); }
public void GetNullablePropertyLonghand() { var code = @" using System.Collections.Generic; namespace tests { class Class1 { public Nullable<bool> MyNull☆ableBool { get; set; } } }"; var expected = new AnalyzerOutput { Name = "MyNullableBool", Output = "<NullBool />", OutputType = AnalyzerOutputType.Property, }; this.PositionAtStarShouldProduceExpected(code, expected, this.NullableTestsProfile); }
public void GetGenericListProperty() { var code = @" using System.Collections.Generic; namespace tests { class Class1 { *public List<string> MyListProperty { get; set; }* } }"; var expected = new AnalyzerOutput { Name = "MyListProperty", Output = "<ItemsControl ItemsSource=\"{x:Bind MyListProperty}\"></ItemsControl>", OutputType = AnalyzerOutputType.Property, }; this.EachPositionBetweenStarsShouldProduceExpected(code, expected); }
public void GetArrayPropertiesInSelection() { var code = @" Namespace tests Class Class1 *Public Property MyBool As Boolean Public Property MyArray As Array Public Property MyArrayBool() As Boolean* End Class End Namespace"; var expected = new AnalyzerOutput { Name = "MyBool, MyArray and 1 other property", Output = @"<Bool /> <Array /> <ArrayBool />", OutputType = AnalyzerOutputType.Selection, }; this.SelectionBetweenStarsShouldProduceExpected(code, expected, this.ArrayTestsProfile); }
public void GetInheritedPropertiesInOtherFilesOverMultipleLevels() { var code = @" Public Class Class1 Inherits Base*Class Public Property Property1 As String Public Property Property2 As String End Class "; var code2 = @" Public Class BaseClass Inherits SuperBaseClass Public Property BaseProperty As String End Class"; var code3 = @" Public Class SuperBaseClass Public Property SuperBaseProperty As String End Class"; var expectedOutput = "<StackPanel>" + Environment.NewLine + "<TextBox Text=\"{x:Bind Property1, Mode=TwoWay}\" />" + Environment.NewLine + "<TextBox Text=\"{x:Bind Property2, Mode=TwoWay}\" />" + Environment.NewLine + "<TextBox Text=\"{x:Bind BaseProperty, Mode=TwoWay}\" />" + Environment.NewLine + "<TextBox Text=\"{x:Bind SuperBaseProperty, Mode=TwoWay}\" />" + Environment.NewLine + "</StackPanel>"; var expected = new AnalyzerOutput { Name = "Class1", Output = expectedOutput, OutputType = AnalyzerOutputType.Class, }; this.PositionAtStarShouldProduceExpectedUsingAdditonalFiles(code, expected, profileOverload: null, additionalCode: new[] { code2, code3 }); }
protected void PositionAtStarShouldProduceExpected(string code, AnalyzerOutput expected, bool isCSharp, Profile profileOverload) { this.EnsureOneStar(code); var(pos, actualCode) = this.GetCodeAndCursorPos(code); var syntaxTree = isCSharp ? CSharpSyntaxTree.ParseText(actualCode) : VisualBasicSyntaxTree.ParseText(actualCode); Assert.IsNotNull(syntaxTree); var semModel = isCSharp ? CSharpCompilation.Create(string.Empty).AddSyntaxTrees(syntaxTree).GetSemanticModel(syntaxTree, true) : VisualBasicCompilation.Create(string.Empty).AddSyntaxTrees(syntaxTree).GetSemanticModel(syntaxTree, true); var indent = new TestVisualStudioAbstraction().XamlIndent; var analyzer = isCSharp ? new CSharpAnalyzer(DefaultTestLogger.Create(), indent) as IDocumentAnalyzer : new VisualBasicAnalyzer(DefaultTestLogger.Create(), indent); var actual = analyzer.GetSingleItemOutput(syntaxTree.GetRoot(), semModel, pos, profileOverload); this.AssertOutput(expected, actual); }
public void GetSelectionOfStructProperties() { var profile = TestProfile.CreateEmpty(); profile.Mappings.Add(new Mapping { Type = "string", IfReadOnly = false, NameContains = string.Empty, Output = "<String Name=\"$name$\" />", }); profile.Mappings.Add(new Mapping { Type = "integer", IfReadOnly = false, NameContains = string.Empty, Output = "<Int Name=\"$name$\" />", }); var code = @" Namespace tests Structure StructViewModel *Public Property Property1 As String Public Property Property2 As Integer* End Structure End Namespace"; var expectedOutput = "<String Name=\"Property1\" />" + Environment.NewLine + "<Int Name=\"Property2\" />"; var expected = new AnalyzerOutput { Name = "Property1 and Property2", Output = expectedOutput, OutputType = AnalyzerOutputType.Selection, }; this.SelectionBetweenStarsShouldProduceExpected(code, expected, profile); }
public void GetNullablePropertyShorthand() { var code = @" using System.Collections.Generic; namespace tests { class Class1 { public bool? MyBoo*lQ { get; set; } } }"; var expected = new AnalyzerOutput { Name = "MyBoolQ", Output = @"<BoolQ />", OutputType = AnalyzerOutputType.Property, }; this.PositionAtStarShouldProduceExpected(code, expected, this.NullableTestsProfile); }
public void GetArrayPropertyLonghand() { var code = @" using System; namespace tests { class Class1 { public Array<bool> MyAr*rayBool { get; set; } } }"; var expected = new AnalyzerOutput { Name = "MyArrayBool", Output = @"<ArrayBool />", OutputType = AnalyzerOutputType.Property, }; this.PositionAtStarShouldProduceExpected(code, expected, this.ArrayTestsProfile); }
public void GetNonExistentPropertyProperty() { var code = @" namespace tests { class Class1 { ☆public InvalidType LastOrder { get; set; }☆ } }"; var invalidTypeProfile = new Profile { Name = "GridTestProfile", ClassGrouping = "Grid", FallbackOutput = "<TextBlock Text=\"FALLBACK_$name$\" />", SubPropertyOutput = "<TextBlock Text=\"SP_$name$\" />", Mappings = new ObservableCollection <Mapping> { new Mapping { Type = "InvalidType", NameContains = "", Output = "<TextBlock Text=\"$name$\" x:InvalidType=\"true\" />", IfReadOnly = false, }, }, }; var expected = new AnalyzerOutput { Name = "LastOrder", Output = "<TextBlock Text=\"LastOrder\" x:InvalidType=\"true\" />", OutputType = AnalyzerOutputType.Property, }; this.EachPositionBetweenStarsShouldProduceExpected(code, expected, invalidTypeProfile); }
public void MappingSupportsGenericTypeInVBAndCSFormats() { var profile = TestProfile.CreateEmpty(); profile.SubPropertyOutput = "<DymnProp Value=\"$name$\" />"; profile.Mappings.Add(new Mapping { Type = "List<Int>", IfReadOnly = false, NameContains = string.Empty, Output = "<Int />", }); profile.Mappings.Add(new Mapping { Type = "List(Of String)", IfReadOnly = false, NameContains = string.Empty, Output = "<String />", }); var code = @" Namespace tests Class Class1 *Public Property SomeInts As List(Of int) Public Property SomeStrings As List(Of String)* End Class End Namespace"; var expected = new AnalyzerOutput { Name = "SomeInts and SomeStrings", Output = @"<Int /> <String />", OutputType = AnalyzerOutputType.Selection, }; this.SelectionBetweenStarsShouldProduceExpected(code, expected, profile); }
public void GetSelectionOfMultipleProperties() { var code = @" namespace tests { class SomeClass { private string _property8; ☆ public string Property1 { get; set; } public string Property2 { get; private set; } string Property3 { get; } private string Property4 { get; set; } public int Property5 { get; set; } public List<string> Property6 { get; set; } internal string Property7 { get; set; } public string Property8 { get => _property8; set => _property8 = value; } ☆ } }"; var expectedOutput = "<TextBox Text=\"{x:Bind Property1, Mode=TwoWay}\" />" + Environment.NewLine + "<TextBlock Text=\"Property2\" />" + Environment.NewLine + "<TextBlock Text=\"Property3\" />" + Environment.NewLine + "<TextBox Text=\"{x:Bind Property4, Mode=TwoWay}\" />" + Environment.NewLine + "<Slider Minimum=\"0\" Maximum=\"100\" x:Name=\"Property5\" Value=\"{x:Bind Property5, Mode=TwoWay}\" />" + Environment.NewLine + "<ItemsControl ItemsSource=\"{x:Bind Property6}\">" + Environment.NewLine + "</ItemsControl>" + Environment.NewLine + "<TextBox Text=\"{x:Bind Property7, Mode=TwoWay}\" />" + Environment.NewLine + "<TextBox Text=\"{x:Bind Property8, Mode=TwoWay}\" />"; var expected = new AnalyzerOutput { Name = "Property1, Property2 and 6 other properties", Output = expectedOutput, OutputType = AnalyzerOutputType.Selection, }; this.SelectionBetweenStarsShouldProduceExpected(code, expected); }
public void GetCustomProperty() { var code = @" Namespace tests Class Class1 ☆Public Property LastOrder As Order☆ End Class Public Class Order Public Property OrderId As Int Public Property OrderDescription As String End Class End Namespace"; var expected = new AnalyzerOutput { Name = "LastOrder", Output = "<TextBlock Text=\"FALLBACK_LastOrder\" />", OutputType = AnalyzerOutputType.Property, }; this.EachPositionBetweenStarsShouldProduceExpected(code, expected); }
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 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 = "Class1", Output = @"<form> <Dyno> <DymnProp Value="""" /> </Dyno> </form>", OutputType = AnalyzerOutputType.Class, }; this.EachPositionBetweenStarsShouldProduceExpected(code, expected, profile); }
public MainWindow() { InitializeComponent(); Logger.LogReceived += log; var configObj = Application.Current.Resources["Config"]; updateConfig(configObj as Config); var bmpsObj = Application.Current.Resources["Bitmaps"]; bitmaps = bmpsObj as Bitmaps; var analyzerOutObj = Application.Current.Resources["AnalyzerOuput"]; analyzerOutput = analyzerOutObj as AnalyzerOutput; var useGPUObj = ConfigurationManager.AppSettings["UseGPU"]; bool useGPU = false; if (useGPUObj != null) { bool.TryParse(useGPUObj.ToString(), out useGPU); } analyzer = new Analyzer(bitmaps, analyzerOutput, useGPU); var cogObj = Application.Current.Resources["CognitiveData"]; cognitiveData = cogObj as CognitiveData; cognitiveController = new CognitiveController(bitmaps, cognitiveData); Closed += MainWindow_Closed; frameTimer = new DispatcherTimer(TimeSpan.FromMilliseconds(20), DispatcherPriority.Normal, timerElapsed, this.Dispatcher); }
public void GetClassAllPropertyOptions() { var code = @" namespace tests { class Class1 { private string _property8; * public string Property1 { get; set; } // include NOT readonly public string Property2 { get; private set; } // include readonly string Property3 { get; } // DO NOT include private string Property4 { get; set; } // DO NOT include public int Property5 { get; set; } // include NOT readonly public List<string> Property6 { get; set; } // include NOT readonly internal string Property7 { get; set; } // DO NOT include public string Property8 { get => _property8; set => _property8 = value; } // include NOT readonly } }"; var expectedOutput = "<StackPanel>" + Environment.NewLine + "<TextBox Text=\"{x:Bind Property1, Mode=TwoWay}\" />" + Environment.NewLine + "<TextBlock Text=\"Property2\" />" + Environment.NewLine + "<Slider Minimum=\"0\" Maximum=\"100\" x:Name=\"Property5\" Value=\"{x:Bind Property5, Mode=TwoWay}\" />" + Environment.NewLine + "<ItemsControl ItemsSource=\"{x:Bind Property6}\"></ItemsControl>" + Environment.NewLine + "<TextBox Text=\"{x:Bind Property8, Mode=TwoWay}\" />" + Environment.NewLine + "</StackPanel>"; var expected = new AnalyzerOutput { Name = "Class1", Output = expectedOutput, OutputType = AnalyzerOutputType.Class, }; this.PositionAtStarShouldProduceExpected(code, expected); }
public void GetNonExistantProperty() { var code = @" Namespace tests Class Class1 ☆Public Property LastOrder As DneType☆ End Class End Namespace"; var dneProfile = new Profile { Name = "GridTestProfile", ClassGrouping = "Grid", FallbackOutput = "<TextBlock Text=\"FALLBACK_$name$\" />", SubPropertyOutput = "<TextBlock Text=\"SP_$name$\" />", Mappings = new ObservableCollection <Mapping> { new Mapping { Type = "DneType", NameContains = "", Output = "<TextBlock Text=\"$name$\" x:DneType=\"true\" />", IfReadOnly = false, }, }, }; var expected = new AnalyzerOutput { Name = "LastOrder", Output = "<TextBlock Text=\"LastOrder\" x:DneType=\"true\" />", OutputType = AnalyzerOutputType.Property, }; this.EachPositionBetweenStarsShouldProduceExpected(code, expected, dneProfile); }
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; }☆ } }"; 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 AnalyzerOutput { Name = "SomeList", Output = expectedXaml, OutputType = AnalyzerOutputType.Selection, }; this.SelectionBetweenStarsShouldProduceExpected(code, expected, profile); }