public void OwrAutoWireDataContextXNameAlias4()
        {
            ExecuteInStaMode.Invoke(() =>
            {
                // The name "AutoWireAliasDataContextVer123"        is split into parts {"Auto","Wire","Alias","Data","Context","Ver123"} , and
                // The name "AutoWire_Alias_DataContext_Ver123"     is split into parts {"Auto","Wire","Alias","Data","Context","Ver123"};
                // so they are considered as the match.

                // case UnitTest.AliasDataContext            !=> UnitTest.ViewModels.AliasDataContext
                // x:Name=AutoWireAliasDataContextVer123     !=> UnitTest.ViewModels.AutoWireAliasDataContext
                //                                           ==> UnitTest.ViewModels.AutoWireAbracadabraName123 because  [ViewModelClassAlias("AutoWire_Alias_DataContext_Ver123")]

                AliasDataContext dependencyObject = new AliasDataContext();
                dependencyObject.Name             = "AutoWireAliasDataContextVer123";
                object dataContext = dependencyObject.DataContext;
                Assert.Null(dataContext);

                AutoWireVmDataContext wireProvider = new AutoWireVmDataContext()
                {
                    ViewModelNamespaceOverwrite = "Abracadabra.Where.It.Placed"
                };
                wireProvider.Execute(dependencyObject);
                dataContext = dependencyObject.DataContext;
                Assert.NotNull(dataContext);
            });
        }
        public void AutoWireDataContextNoXNameNeg()
        {
            ExecuteInStaMode.Invoke(() =>
            {
                // case UnitTest.AutoWireDataContext !=> UnitTest.ViewModels.AutoWireDataContext
                //                                   !=> UnitTest.ViewModels.AutoWireDataContextViewModel

                AutoWireDataContext dependencyObject = new AutoWireDataContext();
                object dataContext = dependencyObject.DataContext;
                Assert.Null(dataContext);

                AutoWireVmDataContext wireProvider = new AutoWireVmDataContext();
                wireProvider.Execute(dependencyObject);
                dataContext = dependencyObject.DataContext;
                Assert.Null(dataContext);
            });
        }
        public void AutoWireDataContextNoNameAlias1()
        {
            ExecuteInStaMode.Invoke(() =>
            {
                // case UnitTest.AutoWireAliaasDataContext   !=> UnitTest.ViewModels.AutoWireAliasDataContext
                //                                           ==> UnitTest.ViewModels.AutoWireAbracadabraName123 because  [ViewModelClassAlias("AutoWireAliasDataContext")]

                AutoWireAliasDataContext dependencyObject = new AutoWireAliasDataContext();
                object dataContext = dependencyObject.DataContext;
                Assert.Null(dataContext);

                AutoWireVmDataContext wireProvider = new AutoWireVmDataContext();
                wireProvider.Execute(dependencyObject);
                dataContext = dependencyObject.DataContext;
                Assert.NotNull(dataContext);
            });
        }
        public void OwrAutoWireDataContextXNamePriority1()
        {
            ExecuteInStaMode.Invoke(() =>
            {
                // case UnitTest.AutoWireDataContext   !=> UnitTest.ViewModels.AutoWireDataContext
                // x:Name=AutoWireDataContextViewModel ==> UnitTest.ViewModels.AutoWireDataContextViewModel

                AutoWireDataContext dependencyObject = new AutoWireDataContext();
                dependencyObject.Name = "AutoWireDataContextViewModel";
                object dataContext    = dependencyObject.DataContext;
                Assert.Null(dataContext);

                AutoWireVmDataContext wireProvider = new AutoWireVmDataContext();
                wireProvider.Execute(dependencyObject);
                dataContext = dependencyObject.DataContext;
                Assert.NotNull(dataContext);
            });
        }
        public void OwrAutoWireDataContextNoXName()
        {
            ExecuteInStaMode.Invoke(() =>
            {
                // case UnitTest.AutoWireDataContextView ==> UnitTest.ViewModels.AutoWireDataContextViewModel

                AutoWireDataContextView dependencyObject = new AutoWireDataContextView();
                object dataContext = dependencyObject.DataContext;
                Assert.Null(dataContext);

                AutoWireVmDataContext wireProvider = new AutoWireVmDataContext()
                {
                    ViewModelNamespaceOverwrite = "Abracadabra.Where.It.Placed"
                };
                wireProvider.Execute(dependencyObject);
                dataContext = dependencyObject.DataContext;
                Assert.NotNull(dataContext);
            });
        }
        public void AutoWireDataContextNoXName()
        {
            ExecuteInStaMode.Invoke(() =>
            {
                // case UnitTest.AutoWireDataContextView ==> UnitTest.ViewModels.AutoWireDataContextViewModel

                AutoWireDataContextView dependencyObject = new AutoWireDataContextView();
                object dataContext = dependencyObject.DataContext;
                Assert.Null(dataContext);

                AutoWireVmDataContext wireProvider = new AutoWireVmDataContext();
                wireProvider.Execute(dependencyObject);
                dataContext = dependencyObject.DataContext;
                Assert.NotNull(dataContext);

                object awVM = BindXAML.GetAutoWiredViewModel(dependencyObject);
                Assert.True(object.ReferenceEquals(awVM, dataContext));
            });
        }
        public void OwrAutoWireDataContextNoXNameSubMatch()
        {
            ExecuteInStaMode.Invoke(() =>
            {
                // case UnitTest.AutoWireDataContext ==> UnitTest.ViewModels.AutoWireDataContext because (sub match)
                //                                   !=> UnitTest.ViewModels.AutoWireDataContextViewModel

                AutoWireDataContext dependencyObject = new AutoWireDataContext();
                object dataContext = dependencyObject.DataContext;
                Assert.Null(dataContext);

                AutoWireVmDataContext wireProvider = new AutoWireVmDataContext()
                {
                    UseMaxNameSubMatch = true, ViewModelNamespaceOverwrite = "Abracadabra.Where.It.Placed"
                };
                wireProvider.Execute(dependencyObject);
                dataContext = dependencyObject.DataContext;
                Assert.NotNull(dataContext);
            });
        }
Пример #8
0
        public void AutoWireDataContextXNamePriority1()
        {
            ExecuteInStaMode.Invoke(() =>
            {
                // case UnitTest.AutoWireDataContext   !=> UnitTest.ViewModels.AutoWireDataContext
                // x:Name=AutoWireDataContextViewModel ==> UnitTest.ViewModels.AutoWireDataContextViewModel

                AutoWireDataContext dependencyObject = new AutoWireDataContext();
                dependencyObject.Name = "AutoWireDataContextViewModel";
                object dataContext    = dependencyObject.DataContext;
                Assert.IsNull(dataContext);

                AutoWireVmDataContext wireProvider = new AutoWireVmDataContext();
                wireProvider.Execute(dependencyObject);
                dataContext = dependencyObject.DataContext;
                Assert.IsNotNull(dataContext);

                object awVM = BindXAML.GetAutoWiredViewModel(dependencyObject);
                Assert.IsTrue(object.ReferenceEquals(awVM, dataContext));
            });
        }
        public void AutoWireDataContextNoXNameTag()
        {
            ExecuteInStaMode.Invoke(() =>
            {
                // case UnitTest.AutoWireDataContextView ==> UnitTest.ViewModels.AutoWireDataContextViewModel

                AutoWireDataContextView dependencyObject = new AutoWireDataContextView();
                object viewModel = dependencyObject.Tag;
                Assert.Null(viewModel);

                AutoWireVmDataContext wireProvider = new AutoWireVmDataContext()
                {
                    TargetPropertyName = "Tag"
                };
                wireProvider.Execute(dependencyObject);
                viewModel = dependencyObject.Tag;
                Assert.NotNull(viewModel);

                object awVM = BindXAML.GetAutoWiredViewModel(dependencyObject);
                Assert.True(object.ReferenceEquals(awVM, viewModel));
            });
        }
        public void OwrAutoWireDataContextXNameAlias2()
        {
            ExecuteInStaMode.Invoke(() =>
            {
                // case UnitTest.AliasDataContext            !=> UnitTest.ViewModels.AliasDataContext
                // x:Name=AutoWireAliasDataContext           !=> UnitTest.ViewModels.AutoWireAliasDataContext
                //                                           ==> UnitTest.ViewModels.AutoWireAbracadabraName123 because  [ViewModelClassAlias("AutoWireAliasDataContext")]

                AliasDataContext dependencyObject = new AliasDataContext();
                dependencyObject.Name             = "AutoWireAliasDataContext";
                object dataContext = dependencyObject.DataContext;
                Assert.Null(dataContext);

                AutoWireVmDataContext wireProvider = new AutoWireVmDataContext()
                {
                    ViewModelNamespaceOverwrite = "Abracadabra.Where.It.Placed"
                };
                wireProvider.Execute(dependencyObject);
                dataContext = dependencyObject.DataContext;
                Assert.NotNull(dataContext);
            });
        }
Пример #11
0
        public void AutoWireDataContextNoXNameSubMatch()
        {
            ExecuteInStaMode.Invoke(() =>
            {
                // case UnitTest.AutoWireDataContext ==> UnitTest.ViewModels.AutoWireDataContext because (sub match)
                //                                   !=> UnitTest.ViewModels.AutoWireDataContextViewModel

                AutoWireDataContext dependencyObject = new AutoWireDataContext();
                object dataContext = dependencyObject.DataContext;
                Assert.IsNull(dataContext);

                AutoWireVmDataContext wireProvider = new AutoWireVmDataContext()
                {
                    UseMaxNameSubMatch = true
                };
                wireProvider.Execute(dependencyObject);
                dataContext = dependencyObject.DataContext;
                Assert.IsNotNull(dataContext);

                object awVM = BindXAML.GetAutoWiredViewModel(dependencyObject);
                Assert.IsTrue(object.ReferenceEquals(awVM, dataContext));
            });
        }