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 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 NewTargetClassWithLabel_ShouldCreateNewTargetClassWithLabel()
            {
                SourceWebPage sourceWebPage = new SourceWebPage
                {
                    ClassFullName = "Test1.TestSourceClass",
                    PageUrl       = "TestSourceClass.aspx",
                    Controls      = new List <SourceWebControl>()
                    {
                        new SourceWebControl
                        {
                            ClassFullName = "System.Web.UI.WebControls.Label",
                            FieldName     = "TestTargetField"
                        }
                    }
                };
                TargetClass targetClass          = new TargetClass();
                var         targetModelGenerator = new TargetModelGenerator();

                targetClass = targetModelGenerator.UpdateClass(sourceWebPage, targetClass);
                Assert.AreEqual(1, targetClass.TargetFieldList.Count);
                TestValidators.ValidateTargetField(targetClass.TargetFieldList[0],
                                                   isDirty: true,
                                                   sourceClassFullName: "System.Web.UI.WebControls.Label",
                                                   sourceFieldName: "TestTargetField",
                                                   targetControlType: EnumTargetControlType.Label,
                                                   targetFieldName: "TestTargetField");
            }
            public void ExistingClassExistingIrrelevantFields()
            {
                SourceWebPage sourceWebPage = new SourceWebPage
                {
                    ClassFullName = "Test1.TestSourceClass",
                    PageUrl       = "TestSourceClass.aspx",
                    Controls      = new List <SourceWebControl>()
                    {
                        new SourceWebControl
                        {
                            ClassFullName = "System.Web.UI.WebControls.HyperLink",
                            FieldName     = "NewTargetField"
                        }
                    }
                };
                var targetClass = new TargetClass()
                {
                    TargetFieldList = new List <TargetField>()
                    {
                        new TargetField
                        {
                            IsDirty             = false,
                            SourceClassFullName = "TestSourcenamespace.TestSourceClass",
                            SourceFieldName     = "ExistingTargetField",
                            TargetControlType   = EnumTargetControlType.Unknown,
                            TargetFieldName     = "ExistingTargetFieldName"
                        }
                    }
                };
                var targetModelGenerator = new TargetModelGenerator();

                targetClass = targetModelGenerator.UpdateClass(sourceWebPage, targetClass);
                Assert.AreEqual(2, targetClass.TargetFieldList.Count);

                TestValidators.ValidateTargetField(targetClass.TargetFieldList[0],
                                                   isDirty: false,
                                                   sourceClassFullName: "TestSourcenamespace.TestSourceClass",
                                                   sourceFieldName: "ExistingTargetField",
                                                   targetControlType: EnumTargetControlType.Unknown,
                                                   targetFieldName: "ExistingTargetFieldName");

                TestValidators.ValidateTargetField(targetClass.TargetFieldList[1],
                                                   isDirty: true,
                                                   sourceClassFullName: "System.Web.UI.WebControls.HyperLink",
                                                   sourceFieldName: "NewTargetField",
                                                   targetControlType: EnumTargetControlType.Link,
                                                   targetFieldName: "NewTargetField");
            }
            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 ExistingClassChangedTargetFieldType_ShouldUpdateTargetFieldType()
            {
                SourceWebPage sourceWebPage = new SourceWebPage
                {
                    ClassFullName = "Test1.TestSourceClass",
                    PageUrl       = "TestSourceClass.aspx",
                    Controls      = new List <SourceWebControl>()
                    {
                        new SourceWebControl
                        {
                            ClassFullName = typeof(System.Web.UI.WebControls.HyperLink).FullName,
                            FieldName     = "TestTargetField"
                        }
                    }
                };
                var targetClass = new TargetClass()
                {
                    TargetFieldList = new List <TargetField>()
                    {
                        new TargetField
                        {
                            IsDirty             = false,
                            SourceClassFullName = typeof(System.Web.UI.WebControls.HyperLink).FullName,
                            SourceFieldName     = "TestTargetField",
                            TargetControlType   = EnumTargetControlType.TextBox,
                            TargetFieldName     = "TestTargetField"
                        }
                    }
                };
                var targetModelGenerator = new TargetModelGenerator();

                targetClass = targetModelGenerator.UpdateClass(sourceWebPage, targetClass);
                Assert.AreEqual(1, targetClass.TargetFieldList.Count);
                TestValidators.ValidateTargetField(targetClass.TargetFieldList[0],
                                                   isDirty: true,
                                                   sourceClassFullName: typeof(System.Web.UI.WebControls.HyperLink).FullName,
                                                   sourceFieldName: "TestTargetField",
                                                   targetControlType: EnumTargetControlType.Link,
                                                   targetFieldName: "TestTargetField");
            }
            public void BasicTargetClassTest()
            {
                CSClass csClass = new CSClass()
                {
                    ClassFullName = "Test.Target.TargetClassName",
                    AttributeList = new List <CSAttribute>()
                    {
                        new CSAttribute
                        {
                            TypeFullName = typeof(UIClientPageAttribute).FullName,
                            ArgumentList = new List <CSAttribute.CSAttributeArgument>()
                            {
                                new CSAttribute.CSAttributeArgument {
                                    ArgumentName = "sourceClassFullName", ArguementValue = "Test.Test1.SourceClassFullNameValue"
                                }                                                                                                                                                                   //,
                                //new CSAttribute.CSAttributeArgument { ArgumentName = "ExpectedUrl", ArguementValue = "SourceClassFullName.aspx" }
                            }
                        }
                    },
                    FileRelativePathList = new List <string>()
                    {
                        "TargetClassName.aspx.designer.cs",
                        "TargetClassName.aspx.cs"
                    },
                    PropertyList = new List <CSProperty>()
                    {
                        new CSProperty()
                        {
                            TypeFullName    = typeof(WatiN.Core.Link).FullName,
                            PropertyName    = "TestLink",
                            ProtectionLevel = EnumProtectionLevel.Public,
                            AttributeList   = new List <CSAttribute>()
                            {
                                new CSAttribute()
                                {
                                    TypeFullName = typeof(UIClientPropertyAttribute).FullName,
                                    ArgumentList = new List <CSAttribute.CSAttributeArgument>()
                                    {
                                        new CSAttribute.CSAttributeArgument()
                                        {
                                            ArgumentName = "sourceFieldTypeFullName", ArguementValue = typeof(System.Web.UI.WebControls.HyperLink).FullName
                                        },
                                        new CSAttribute.CSAttributeArgument()
                                        {
                                            ArgumentName = "sourceFieldName", ArguementValue = "TestLink"
                                        }
                                    }
                                }
                            }
                        },
                        new CSProperty()
                        {
                            TypeFullName    = typeof(WatiN.Core.TextField).FullName,
                            PropertyName    = "TestTextBox",
                            ProtectionLevel = EnumProtectionLevel.Public,
                            AttributeList   = new List <CSAttribute>()
                            {
                                new CSAttribute()
                                {
                                    TypeFullName = typeof(UIClientPropertyAttribute).FullName,
                                    ArgumentList = new List <CSAttribute.CSAttributeArgument>()
                                    {
                                        new CSAttribute.CSAttributeArgument()
                                        {
                                            ArgumentName = "sourceFieldTypeFullName", ArguementValue = typeof(System.Web.UI.WebControls.TextBox).FullName
                                        },
                                        new CSAttribute.CSAttributeArgument()
                                        {
                                            ArgumentName = "sourceFieldName", ArguementValue = "TestTextBox"
                                        }
                                    }
                                }
                            }
                        },
                    }
                };
                var targetClassManager = new TargetClassManager();
                var targetClass        = targetClassManager.TryLoadTargetClass(csClass);

                Assert.IsNotNull(targetClass);
                Assert.AreEqual("Test.Test1.SourceClassFullNameValue", targetClass.SourceClassFullName);
                Assert.AreEqual("Test.Target.TargetClassName", targetClass.TargetClassFullName);
                Assert.AreEqual(2, targetClass.TargetFieldList.Count);
                TestValidators.ValidateTargetField(targetField: targetClass.TargetFieldList[0],
                                                   isDirty: false,
                                                   sourceClassFullName: "System.Web.UI.WebControls.HyperLink",
                                                   sourceFieldName: "TestLink",
                                                   targetControlType: EnumTargetControlType.Link,
                                                   targetFieldName: "TestLink");
                TestValidators.ValidateTargetField(targetField: targetClass.TargetFieldList[1],
                                                   isDirty: false,
                                                   sourceClassFullName: "System.Web.UI.WebControls.TextBox",
                                                   sourceFieldName: "TestTextBox",
                                                   targetControlType: EnumTargetControlType.TextBox,
                                                   targetFieldName: "TestTextBox");
                //Assert.AreEqual("SourceClassFullName.aspx", targetClass.ExpectedUrl);
            }