public void DifferentSourceNamespace_CreatesTargetClassWithDifferentNamespace()
            {
                var sourceProject = new SourceWebProject
                {
                    WebPageList = new List <SourceWebPage>()
                    {
                        new SourceWebPage
                        {
                            ClassFullName = "SomeOtherNamespace.Test1.TestItem",
                            PageUrl       = "TestWebPage.aspx"
                        }
                    },
                    RootNamespace = "TestSourceNamespace"
                };

                var targetProject = new TargetProject
                {
                    RootNamespace = "TestTargetNamespace"
                };
                var targetModelGenerator = new TargetModelGenerator();
                var projectResult        = targetModelGenerator.CompareProject(targetProject, sourceProject);

                Assert.AreEqual(1, projectResult.ClassesToAdd.Count);
                Assert.AreEqual(0, projectResult.ClassesToUpdate.Count);
                TestValidators.ValidateTargetClassComparisonResult(projectResult.ClassesToAdd[0],
                                                                   @"Client\Pages\SomeOtherNamespace\Test1\TestItemPageClient.designer.cs",
                                                                   @"Client\Pages\SomeOtherNamespace\Test1\TestItemPageClient.cs",
                                                                   @"SomeOtherNamespace.Test1.TestItem",
                                                                   @"TestTargetNamespace.Client.Pages.SomeOtherNamespace.Test1.TestItemPageClient",
                                                                   EnumSourceObjectType.WebPage,
                                                                   "TestWebPage.aspx");
            }
            public void MatchingSourceNamespace_CreatesTargetClassWithSameNamespace()
            {
                var sourceProject = new SourceWebProject
                {
                    WebPageList = new List <SourceWebPage>()
                    {
                        new SourceWebPage
                        {
                            ClassFullName = "TestTargetNamespace.Test1.TestItem",
                            PageUrl       = "TestWebPage.aspx"
                        }
                    },
                    RootNamespace = "TestSourceNamespace"
                };

                var targetProject = new TargetProject
                {
                    RootNamespace = "TestTargetNamespace.Test1"
                };
                var targetModelGenerator = new TargetModelGenerator();
                var projectResult        = targetModelGenerator.CompareProject(targetProject, sourceProject);

                Assert.AreEqual(1, projectResult.ClassesToAdd.Count);
                Assert.AreEqual(0, projectResult.ClassesToUpdate.Count);
                TestValidators.ValidateTargetClassComparisonResult(classResult: projectResult.ClassesToAdd[0],
                                                                   designerFileRelativePath: @"Client\Pages\TestTargetNamespace\Test1\TestItemPageClient.designer.cs",
                                                                   userFileRelativePath: @"Client\Pages\TestTargetNamespace\Test1\TestItemPageClient.cs",
                                                                   sourceClassFullName: @"TestTargetNamespace.Test1.TestItem",
                                                                   targetClassFullName: @"TestTargetNamespace.Test1.Client.Pages.TestTargetNamespace.Test1.TestItemPageClient",
                                                                   targetObjectType: EnumSourceObjectType.WebPage,
                                                                   expectedUrl: "TestWebPage.aspx");
            }
            public void ExistingTargetClassWithDifferentName_ShouldUpdateExistingTargetClass()
            {
                var sourceProject = new SourceWebProject
                {
                    WebPageList = new List <SourceWebPage>()
                    {
                        new SourceWebPage
                        {
                            ClassFullName = "TestSourceNamespace.Test1.TestItem",
                            PageUrl       = "TestWebPage.aspx"
                        }
                    },
                    RootNamespace = "TestSourceNamespace"
                };

                var targetProject = new TargetProject
                {
                    RootNamespace   = "TestTargetNamespace",
                    TargetClassList = new List <TargetClass>()
                    {
                        new TargetClass
                        {
                            SourceClassFullName      = "TestSourceNamespace.Test1.TestItem",
                            DesignerFileRelativePath = @"SomeOtherLocation\SomeOtherClassName.designer.cs",
                            UserFileRelativePath     = @"SomeOtherLocation\SomeOtherClassName.cs",
                            TargetClassFullName      = "SomeOtherLocation.SomeOtherClassName",
                            SourceObjectType         = EnumSourceObjectType.WebPage,
                            ExpectedUrl = "TestWebPage.aspx"
                        }
                    }
                };
                var targetModelGenerator = new TargetModelGenerator();
                var projectResult        = targetModelGenerator.CompareProject(targetProject, sourceProject);

                Assert.AreEqual(0, projectResult.ClassesToAdd.Count);
                Assert.AreEqual(1, projectResult.ClassesToUpdate.Count);
                TestValidators.ValidateTargetClassComparisonResult(projectResult.ClassesToUpdate[0],
                                                                   @"SomeOtherLocation\SomeOtherClassName.designer.cs",
                                                                   @"SomeOtherLocation\SomeOtherClassName.cs",
                                                                   "TestSourceNamespace.Test1.TestItem",
                                                                   "SomeOtherLocation.SomeOtherClassName",
                                                                   EnumSourceObjectType.WebPage,
                                                                   "TestWebPage.aspx");
            }
            public void ExistingTargetClassWithExpectedNameAndLocation_ShouldUpdateExistingClass()
            {
                var sourceProject = new SourceWebProject
                {
                    WebPageList = new List <SourceWebPage>()
                    {
                        new SourceWebPage
                        {
                            ClassFullName = "TestSourceNamespace.Test1.TestItem",
                            PageUrl       = "TestWebPage.aspx"
                        }
                    },
                    RootNamespace = "TestSourceNamespace"
                };

                var targetProject = new TargetProject
                {
                    RootNamespace   = "TestTargetNamespace",
                    TargetClassList = new List <TargetClass>()
                    {
                        new TargetClass
                        {
                            SourceClassFullName      = "TestSourceNamespace.Test1.TestItem",
                            DesignerFileRelativePath = @"Client\Pages\Test1\TestItemPageClient.designer.cs",
                            UserFileRelativePath     = @"Client\Pages\Test1\TestItemPageClient.cs",
                            TargetClassFullName      = "TestTargetNamespace.Client.Pages.Test1.TestItemPageClient",
                            SourceObjectType         = EnumSourceObjectType.WebPage,
                            ExpectedUrl = "TestWebPage.aspx"
                        }
                    }
                };
                var targetModelGenerator = new TargetModelGenerator();
                var projectResult        = targetModelGenerator.CompareProject(targetProject, sourceProject);

                Assert.AreEqual(0, projectResult.ClassesToAdd.Count);
                Assert.AreEqual(1, projectResult.ClassesToUpdate.Count);
            }
Example #5
0
            public void BasicTest()
            {
                CSProjectFile projectFile = new CSProjectFile()
                {
                    RootNamespace = "Test.Namespace",
                    ClassList     = new List <CSClass>
                    {
                        new CSClass {
                            ClassFullName = "Test1.TestClass1", FileRelativePathList = new List <string> {
                                "TestClass1.aspx"
                            }
                        },
                        new CSClass {
                            ClassFullName = "Test1.TestMaster", FileRelativePathList = new List <string> {
                                "TestMasterPage.Master"
                            }
                        },
                        new CSClass {
                            ClassFullName = "Test1.TestUserControl", FileRelativePathList = new List <string> {
                                "TestUserControl.ascx"
                            }
                        }
                    },
                    WebFormContainers = new List <WebFormContainer>()
                    {
                        new WebFormContainer {
                            ClassFullName = "Test1.TestClass1", CodeBehindFile = "TestClass1.aspx.cs", ContainerType = EnumWebFormContainerType.WebPage, FilePath = "C:\\Test\\TestClass1.aspx"
                        },
                        new WebFormContainer {
                            ClassFullName = "Test1.TestMasterPage", CodeBehindFile = "TestMasterPage.Master.cs", ContainerType = EnumWebFormContainerType.MasterPage, FilePath = "C:\\Test\\TestMasterPage.Master"
                        },
                        new WebFormContainer {
                            ClassFullName = "Test1.TestUserControl", CodeBehindFile = "TestUserControl.ascx.cs", ContainerType = EnumWebFormContainerType.UserControl, FilePath = "C:\\Test\\TestUserControl.ascx"
                        }
                    },
                    ClassFileDependencyList = new List <ClassFileDependency>
                    {
                        new ClassFileDependency {
                            ClassFullName = "Test1.TestClass1", DependentUponFile = "TestClass1.aspx"
                        },
                        new ClassFileDependency {
                            ClassFullName = "Test1.TestMasterPage", DependentUponFile = "TestMasterPage.Master"
                        },
                        new ClassFileDependency {
                            ClassFullName = "Test1.TestUserControl", DependentUponFile = "TestUserControl.ascx"
                        }
                    }
                };
                SourceWebModelParser parser = new SourceWebModelParser();
                SourceWebProject     result = parser.LoadFromProjectFile(projectFile, "C:\\Test\\Test.csproj");

                Assert.IsNotNull(result);
                Assert.AreEqual(projectFile.RootNamespace, result.RootNamespace);

                Assert.AreEqual(1, result.WebPageList.Count);
                Assert.AreEqual("Test1.TestClass1", result.WebPageList[0].ClassFullName);
                Assert.AreEqual("/TestClass1.aspx", result.WebPageList[0].PageUrl);

                Assert.AreEqual(1, result.MasterPageList.Count);
                Assert.AreEqual("Test1.TestMasterPage", result.MasterPageList[0].ClassFullName);
                Assert.AreEqual("/TestMasterPage.Master", result.MasterPageList[0].PageUrl);

                Assert.AreEqual(1, result.UserControlList.Count);
                Assert.AreEqual("Test1.TestUserControl", result.UserControlList[0].ClassFullName);
            }