public void GetMetadataFileNamesFromArtifactFileName_creates_metadata_file_names_for_non_null_edmx_ProjectItem()
        {
            var mockDte = new MockDTE(".NETFramework, Version=v4.5", references: new Reference[0]);

            mockDte.SetProjectProperties(new Dictionary <string, object> {
                { "FullPath", @"D:\Projects\Project\Folder" }
            });
            var mockParentProjectItem = new Mock <ProjectItem>();

            mockParentProjectItem.Setup(p => p.Collection).Returns(Mock.Of <ProjectItems>());
            mockParentProjectItem.Setup(p => p.Name).Returns("Folder");

            var mockModelProjectItem = new Mock <ProjectItem>();
            var mockCollection       = new Mock <ProjectItems>();

            mockCollection.Setup(p => p.Parent).Returns(mockParentProjectItem.Object);
            mockModelProjectItem.Setup(p => p.Collection).Returns(mockCollection.Object);

            var metadataFileNames =
                ConnectionManager.GetMetadataFileNamesFromArtifactFileName(
                    mockDte.Project, @"c:\temp\myModel.edmx", mockDte.ServiceProvider, (_, __) => mockModelProjectItem.Object);

            Assert.Equal(@".\Folder\myModel.csdl", metadataFileNames[0]);
            Assert.Equal(@".\Folder\myModel.ssdl", metadataFileNames[1]);
            Assert.Equal(@".\Folder\myModel.msl", metadataFileNames[2]);
        }
        public void GetTextBoxConnectionStringValue_returns_entity_connection_string_for_EDMX_ModelFirst()
        {
            var guid = new Guid("42424242-4242-4242-4242-424242424242");

            var mockDte = new MockDTE(".NETFramework, Version=v4.5", references: new Reference[0]);

            mockDte.SetProjectProperties(new Dictionary <string, object> {
                { "FullPath", @"C:\Project" }
            });
            var mockParentProjectItem = new Mock <ProjectItem>();

            mockParentProjectItem.Setup(p => p.Collection).Returns(Mock.Of <ProjectItems>());
            mockParentProjectItem.Setup(p => p.Name).Returns("Folder");

            var mockModelProjectItem = new Mock <ProjectItem>();
            var mockCollection       = new Mock <ProjectItems>();

            mockCollection.Setup(p => p.Parent).Returns(mockParentProjectItem.Object);
            mockModelProjectItem.Setup(p => p.Collection).Returns(mockCollection.Object);

            var wizardPageDbConfig =
                new WizardPageDbConfig(
                    ModelBuilderWizardFormHelper.CreateWizard(ModelGenerationOption.GenerateDatabaseScript, mockDte.Project, @"C:\Project\myModel.edmx"));

            Assert.Equal(
                "metadata=res://*/myModel.csdl|res://*/myModel.ssdl|res://*/myModel.msl;provider=System.Data.SqlClient;" +
                "provider connection string=\"integrated security=SSPI;MultipleActiveResultSets=True;App=EntityFramework\"",
                wizardPageDbConfig.GetTextBoxConnectionStringValue(
                    CreateDataProviderManager(guid),
                    guid,
                    "Integrated Security=SSPI"));
        }
        public void GetMetadataFileNamesFromArtifactFileName_creates_metadata_file_names_for_null_edmx_ProjectItem()
        {
            var mockDte = new MockDTE(".NETFramework, Version=v4.5", references: new Reference[0]);

            mockDte.SetProjectProperties(new Dictionary <string, object> {
                { "FullPath", @"C:\Projects\Project\Folder" }
            });

            var metadataFileNames =
                ConnectionManager.GetMetadataFileNamesFromArtifactFileName(
                    mockDte.Project, @"c:\temp\myModel.edmx", mockDte.ServiceProvider, (_, __) => null);

            Assert.Equal(@".\..\..\..\temp\myModel.csdl", metadataFileNames[0]);
            Assert.Equal(@".\..\..\..\temp\myModel.ssdl", metadataFileNames[1]);
            Assert.Equal(@".\..\..\..\temp\myModel.msl", metadataFileNames[2]);
        }