public async Task Parse_Then_BindingTreeToStringVisitorShouldOutputExpectedResult(string inputFile, string expectedResultFile) { var xDocument = await LoadXDocument(inputFile).ConfigureAwait(false); var xamlPlatformInfo = XamlPlatformInfoProvider.GetXamlPlatformInfo(XamlPlatform.WPF); var bindingXamlPlatformInfo = new BindingXamlPlatformInfo(xamlPlatformInfo, new BindingCompilerSettings( new Dictionary <string, IReadOnlyDictionary <string, ReadOnlyDependencyPropertyToNotificationEvent> >(), new Dictionary <string, IReadOnlyDictionary <string, Namespace> >(), new Dictionary <string, IReadOnlyCollection <string> >())); var testee = new BindingTreeParser( bindingXamlPlatformInfo, new BindingMarkupExtensionParser(new BindingPathParser(new BindingPathLexicalAnalyzer())), false); var bindingTree = testee.Parse( xDocument.Root, Path.GetDirectoryName(inputFile), Path.GetFileNameWithoutExtension(inputFile), XamlTypeResolver.FromXDocument(xDocument, "Sundew.Xaml.Optimizations.TestData.ApiDesigner.Wpf", new IAssemblyReference[0], bindingXamlPlatformInfo.XamlTypeToSourceCodeNamespaces), new XamlElementNameResolver(xamlPlatformInfo.XamlNamespace)); var visitor = new BindingTreeToStringVisitor(); var result = visitor.Visit(bindingTree, null, 0); var expectedResult = GetExpectedResult(expectedResultFile); result.Should().Be(expectedResult); }
public BindingContainerCodeGeneratorTests() { this.xamlPlatformInfo = XamlPlatformInfoProvider.GetXamlPlatformInfo(XamlPlatform.WPF); this.bindingXamlPlatformInfo = new BindingXamlPlatformInfo(this.xamlPlatformInfo, new BindingCompilerSettings( new Dictionary <string, IReadOnlyDictionary <string, ReadOnlyDependencyPropertyToNotificationEvent> >(), new Dictionary <string, IReadOnlyDictionary <string, Namespace> >(), new Dictionary <string, IReadOnlyCollection <string> >(), false)); this.fileSystem = Substitute.For <IFileSystem>(); this.bindingContainerXamlModificationCollector = new BindingContainerXamlModificationCollector(); this.bindingOptimizationWriter = new BindingOptimizationWriter(new DirectoryInfo(@"c:\temp\sxo"), xamlPlatformInfo, this.fileSystem); this.fileSystem.File.ReadAllText(Arg.Any <string>()).Returns(info => ReadResourceStreamToEnd(info.Arg <string>())); }