예제 #1
0
        public void listViewModelContents_DoubleClick_calls_OnFinish_if_EmptyModelCodeFirst_selected_and_EF_not_referenced_or_EF6_referenced()
        {
            var mockDtes = new[]
            {
                new MockDTE(".NETFramework, Version=v4.5", references: new Reference[0]),
                new MockDTE(".NETFramework, Version=v4.5",
                            references: new[] { MockDTE.CreateReference("EntityFramework", "6.0.0.0") })
            };

            foreach (var mockDte in mockDtes)
            {
                var mockWizard =
                    Mock.Get(
                        ModelBuilderWizardFormHelper.CreateWizard(
                            ModelGenerationOption.EmptyModelCodeFirst,
                            mockDte.Project,
                            serviceProvider: mockDte.ServiceProvider));

                var mockWizardPageStart =
                    CreateMockWizardPageStart(mockWizard.Object, WizardPageStart.GenerateEmptyModelCodeFirstIndex);

                mockWizard.Setup(w => w.OnFinish());

                mockWizardPageStart.Object.listViewModelContents_DoubleClick(sender: null, e: null);

                mockWizard.Verify(w => w.OnFinish(), Times.Once());
            }
        }
예제 #2
0
        DetermineIfArtifactIsVersionSafe_sets_IsVersionSafe_to_true_if_schema_is_the_latest_version_supported_by_referenced_runtime()
        {
            var mockDte = new MockDTE(
                ".NETFramework, Version=v4.5.1",
                references: new[] { MockDTE.CreateReference("EntityFramework", "6.0.0.0") });

            var modelManager   = new Mock <ModelManager>(null, null).Object;
            var modelProvider  = new Mock <XmlModelProvider>().Object;
            var mockVsArtifact =
                new Mock <VSArtifact>(modelManager, new Uri("urn:dummy"), modelProvider)
            {
                CallBase = true
            };

            mockVsArtifact.Protected().Setup <IServiceProvider>("ServiceProvider").Returns(mockDte.ServiceProvider);
            mockVsArtifact.Protected().Setup <Project>("GetProject").Returns(mockDte.Project);
            mockVsArtifact.Setup(a => a.XDocument).Returns(
                new XDocument(
                    new XElement(
                        XName.Get(
                            "Edmx",
                            SchemaManager.GetEDMXNamespaceName(EntityFrameworkVersion.Version3)))));

            var artifact = mockVsArtifact.Object;

            artifact.DetermineIfArtifactIsVersionSafe();
            Assert.True(artifact.IsVersionSafe);
        }
예제 #3
0
        public void SchemaVersionSupportedInProject_returns_true_for_v3_and_EF6_otherwise_false()
        {
            var targetNetFrameworkVersions =
                new[] { ".NETFramework, Version=v4.0", ".NETFramework, Version=v4.5" };

            foreach (var targetNetFrameworkVersion in targetNetFrameworkVersions)
            {
                var mockDte =
                    new MockDTE(
                        targetNetFrameworkVersion,
                        references: new[] { MockDTE.CreateReference("EntityFramework", "6.0.0.0") });

                Assert.False(
                    VsUtils.SchemaVersionSupportedInProject(
                        mockDte.Project, EntityFrameworkVersion.Version1, mockDte.ServiceProvider));

                Assert.False(
                    VsUtils.SchemaVersionSupportedInProject(
                        mockDte.Project, EntityFrameworkVersion.Version2, mockDte.ServiceProvider));

                Assert.True(
                    VsUtils.SchemaVersionSupportedInProject(
                        mockDte.Project, EntityFrameworkVersion.Version3, mockDte.ServiceProvider));
            }
        }
예제 #4
0
        public void GetEntityFrameworkVersion_returns_version_when_ef_installed()
        {
            var helper = new MockDTE(
                ".NETFramework,Version=v4.5", references: new[] { MockDTE.CreateReference("EntityFramework", "6.0.0.0") });

            var schemaVersion = EdmUtils.GetEntityFrameworkVersion(helper.Project, helper.ServiceProvider);

            Assert.Equal(EntityFrameworkVersion.Version3, schemaVersion);
        }
예제 #5
0
        public void GetInstalledEntityFrameworkAssemblyVersion_returns_EF_version_when_EF_and_SDE()
        {
            var project = MockDTE.CreateProject(
                new[]
            {
                MockDTE.CreateReference("System.Data.Entity", "4.0.0.0"),
                MockDTE.CreateReference("EntityFramework", "5.0.0.0")
            });

            Assert.Equal(RuntimeVersion.Version5Net45, VsUtils.GetInstalledEntityFrameworkAssemblyVersion(project));
        }
예제 #6
0
        public void GetProjectReferenceAssemblyNames_returns_references()
        {
            var project = MockDTE.CreateProject(
                new[]
            {
                MockDTE.CreateReference("System.Data.Entity", "4.0.0.0"),
                MockDTE.CreateReference("EntityFramework", "5.0.0.0")
            });

            var referenceAssemblyNames = VsUtils.GetProjectReferenceAssemblyNames(project).ToArray();

            Assert.Equal(2, referenceAssemblyNames.Count());
            Assert.Equal("EntityFramework", referenceAssemblyNames.Last().Key);
            Assert.Equal(new Version(5, 0, 0, 0), referenceAssemblyNames.Last().Value);
        }
예제 #7
0
        public void SchemaVersionSupportedInProject_returns_true_for_v3_and_EF5_on_NetFramework_4_5_otherwise_false()
        {
            var mockDte =
                new MockDTE(
                    ".NETFramework, Version=v4.5",
                    references: new[] { MockDTE.CreateReference("System.Data.Entity", "4.0.0.0") });

            Assert.False(
                VsUtils.SchemaVersionSupportedInProject(
                    mockDte.Project, EntityFrameworkVersion.Version1, mockDte.ServiceProvider));

            Assert.False(
                VsUtils.SchemaVersionSupportedInProject(
                    mockDte.Project, EntityFrameworkVersion.Version2, mockDte.ServiceProvider));

            Assert.True(
                VsUtils.SchemaVersionSupportedInProject(
                    mockDte.Project, EntityFrameworkVersion.Version3, mockDte.ServiceProvider));
        }
예제 #8
0
        public void SchemaVersionSupportedInProject_returns_true_for_v2_and_v3_if_EF4_and_EF6_present()
        {
            var mockDte =
                new MockDTE(
                    ".NETFramework, Version=v4.0",
                    references:
                    new[]
            {
                MockDTE.CreateReference("System.Data.Entity", "4.0.0.0"),
                MockDTE.CreateReference("EntityFramework", "6.0.0.0")
            });

            Assert.False(
                VsUtils.SchemaVersionSupportedInProject(
                    mockDte.Project, EntityFrameworkVersion.Version1, mockDte.ServiceProvider));

            Assert.True(
                VsUtils.SchemaVersionSupportedInProject(
                    mockDte.Project, EntityFrameworkVersion.Version2, mockDte.ServiceProvider));

            Assert.True(
                VsUtils.SchemaVersionSupportedInProject(
                    mockDte.Project, EntityFrameworkVersion.Version3, mockDte.ServiceProvider));
        }
예제 #9
0
        public void GetInstalledEntityFrameworkAssemblyVersion_returns_version_when_only_EF()
        {
            var project = MockDTE.CreateProject(new[] { MockDTE.CreateReference("EntityFramework", "6.0.0.0") });

            Assert.Equal(RuntimeVersion.Version6, VsUtils.GetInstalledEntityFrameworkAssemblyVersion(project));
        }
예제 #10
0
        public void GetInstalledEntityFrameworkAssemblyVersion_returns_version_when_only_SDE()
        {
            var project = MockDTE.CreateProject(new[] { MockDTE.CreateReference("System.Data.Entity", "4.0.0.0") });

            Assert.Equal(new Version(4, 0, 0, 0), VsUtils.GetInstalledEntityFrameworkAssemblyVersion(project));
        }