From acb284f0a1e87cddcbb0e15875bfd4c6c6c639bf Mon Sep 17 00:00:00 2001 From: Erik Ejlskov Jensen Date: Thu, 9 Jan 2025 19:37:33 +0100 Subject: [PATCH] Fix missing mapping and add test --- .../ClassicHumanizerPluralizerTest.cs | 5 +- src/Core/NUnitTestCore/CliConfigMapperTest.cs | 72 ++++++++++++++++ src/Core/NUnitTestCore/CliObjectListTest.cs | 82 +++++++++---------- .../ConnectionStringResolverTest.cs | 11 ++- .../CustomHumanizerPluralizerTest.cs | 5 +- .../Dacpac/DacpacConsolidatorTest.cs | 5 +- src/Core/NUnitTestCore/Dacpac/DacpacTest.cs | 69 ++++++++-------- .../NUnitTestCore/DbContextSplitterTest.cs | 3 +- src/Core/NUnitTestCore/Dgml/DgmlTest.cs | 43 +++++----- src/Core/NUnitTestCore/NUnitTestCore.csproj | 4 +- .../ReplacingCandidateNamingServiceTests.cs | 2 +- .../SqlServerTypeExtensionsTest.cs | 21 +++-- src/GUI/RevEng.Shared/Cli/CliConfigMapper.cs | 15 +++- tools/code-sign.txt | 5 +- 14 files changed, 209 insertions(+), 133 deletions(-) create mode 100644 src/Core/NUnitTestCore/CliConfigMapperTest.cs diff --git a/src/Core/NUnitTestCore/ClassicHumanizerPluralizerTest.cs b/src/Core/NUnitTestCore/ClassicHumanizerPluralizerTest.cs index c511af0c6..13bd45687 100644 --- a/src/Core/NUnitTestCore/ClassicHumanizerPluralizerTest.cs +++ b/src/Core/NUnitTestCore/ClassicHumanizerPluralizerTest.cs @@ -1,5 +1,4 @@ using NUnit.Framework; -using NUnit.Framework.Legacy; using RevEng.Core; namespace UnitTests @@ -12,7 +11,7 @@ public void SingularizeUserData() var sut = new HumanizerPluralizer(); var result = sut.Singularize("UserData"); - ClassicAssert.AreEqual("UserDatum", result); + Assert.AreEqual("UserDatum", result); } [Test] @@ -21,7 +20,7 @@ public void PluralizeUserStatus() var sut = new HumanizerPluralizer(); var result = sut.Pluralize("UserStatus"); - ClassicAssert.AreEqual("UserStatuses", result); + Assert.AreEqual("UserStatuses", result); } } } diff --git a/src/Core/NUnitTestCore/CliConfigMapperTest.cs b/src/Core/NUnitTestCore/CliConfigMapperTest.cs new file mode 100644 index 000000000..2b945cd3c --- /dev/null +++ b/src/Core/NUnitTestCore/CliConfigMapperTest.cs @@ -0,0 +1,72 @@ +using AutoFixture.NUnit3; +using FluentAssertions; +using NUnit.Framework; +using RevEng.Common; +//using NUnit.Framework.Legacy; +using RevEng.Common.Cli; +using RevEng.Common.Cli.Configuration; + +namespace UnitTests +{ + [TestFixture] + public class CliConfigMapperTest + { + [Test, AutoData] + public void CanGetOptions(CliConfig config) + { + var options = CliConfigMapper.ToOptions(config, "C:\temp", "C:\tempo"); + + options.CodeGenerationMode.Should().Be(CodeGenerationMode.EFCore8); + options.ConnectionString.Should().Be(null); + options.ContextClassName.Should().Be(config.Names.DbContextName); + options.ContextNamespace.Should().Be(config.Names.DbContextNamespace); + options.DatabaseType.Should().Be(DatabaseType.Undefined); + options.Dacpac.Should().Be(null); + options.DefaultDacpacSchema.Should().Be(null); + options.FilterSchemas.Should().Be(false); + options.IncludeConnectionString.Should().Be(config.CodeGeneration.EnableOnConfiguring); + options.InstallNuGetPackage.Should().Be(false); + options.ModelNamespace.Should().Be(config.Names.ModelNamespace); + options.OptionsPath.Should().Be(null); + options.OutputContextPath.Should().Be(config.FileLayout.OutputDbContextPath); + options.OutputPath.Should().Be(config.FileLayout.OutputPath); + options.ProjectPath.Should().Be("C:\temp"); + options.ProjectRootNamespace.Should().Be(config.Names.RootNamespace); + options.PreserveCasingWithRegex.Should().Be(config.Replacements.PreserveCasingWithRegex); + options.SelectedHandlebarsLanguage.Should().Be(0); + options.SelectedToBeGenerated.Should().Be(0); + options.Tables.Count.Should().BeGreaterThanOrEqualTo(config.Tables.Count); + options.UncountableWords.Should().NotBeEmpty(); + options.UseBoolPropertiesWithoutDefaultSql.Should().Be(config.CodeGeneration.RemoveDefaultSqlFromBoolProperties); + options.UseDatabaseNames.Should().Be(config.CodeGeneration.UseDatabaseNames); + options.UseDatabaseNamesForRoutines.Should().Be(config.CodeGeneration.UseDatabaseNamesForRoutines); + options.UseDateOnlyTimeOnly.Should().Be(config.TypeMappings.UseDateOnlyTimeOnly); + options.UseDbContextSplitting.Should().Be(config.FileLayout.SplitDbContextPreview); + options.UseFluentApiOnly.Should().Be(!config.CodeGeneration.UseDataAnnotations); + options.UseHandleBars.Should().Be(false); + options.UseHierarchyId.Should().Be(config.TypeMappings.UseHierarchyId); + options.UseInflector.Should().Be(config.CodeGeneration.UseInflector); + options.UseLegacyPluralizer.Should().Be(config.CodeGeneration.UseLegacyInflector); + options.UseManyToManyEntity.Should().Be(config.CodeGeneration.UseManyToManyEntity); + options.UseNodaTime.Should().Be(config.TypeMappings.UseNodaTime); + options.UseNoDefaultConstructor.Should().Be(false); + options.UseNoNavigations.Should().Be(config.CodeGeneration.UseNoNavigationsPreview); + options.UseNoObjectFilter.Should().Be(false); + options.UseNullableReferences.Should().Be(config.CodeGeneration.UseNullableReferenceTypes); + options.UseSchemaFolders.Should().Be(config.FileLayout.UseSchemaFoldersPreview); + options.UseSchemaNamespaces.Should().Be(config.FileLayout.UseSchemaNamespacesPreview); + options.UseSpatial.Should().Be(config.TypeMappings.UseSpatial); + options.UseT4.Should().Be(config.CodeGeneration.UseT4); + options.UseT4Split.Should().Be(config.CodeGeneration.UseT4Split); + + options.GetType().GetProperties().Length.Should().Be(50); + + config.GetType().GetProperties().Length.Should().Be(10); + config.Names.GetType().GetProperties().Length.Should().Be(4); + config.CodeGeneration.GetType().GetProperties().Length.Should().Be(23); + config.FileLayout.GetType().GetProperties().Length.Should().Be(5); + config.Replacements.GetType().GetProperties().Length.Should().Be(2); + config.TypeMappings.GetType().GetProperties().Length.Should().Be(4); + } + } +} diff --git a/src/Core/NUnitTestCore/CliObjectListTest.cs b/src/Core/NUnitTestCore/CliObjectListTest.cs index dc801ebc3..644dd991d 100644 --- a/src/Core/NUnitTestCore/CliObjectListTest.cs +++ b/src/Core/NUnitTestCore/CliObjectListTest.cs @@ -1,11 +1,11 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Text.Json; using NUnit.Framework; -using NUnit.Framework.Legacy; +//using NUnit.Framework.Legacy; using RevEng.Common; using RevEng.Common.Cli; using RevEng.Common.Cli.Configuration; @@ -34,9 +34,9 @@ public void CanGetConfig() var result = CliConfigMapper.BuildObjectList(config); - ClassicAssert.NotNull(result); + Assert.NotNull(result); - ClassicAssert.AreEqual(6, result.Count); + Assert.AreEqual(6, result.Count); } [Test] @@ -49,9 +49,9 @@ public void CanUseGobalFilter() var result = CliConfigMapper.BuildObjectList(config); - ClassicAssert.NotNull(result); + Assert.NotNull(result); - ClassicAssert.IsEmpty(result); + Assert.IsEmpty(result); } [Test] @@ -63,9 +63,9 @@ public void CanAddStartsWithFilter() var result = CliConfigMapper.BuildObjectList(config); - ClassicAssert.NotNull(result); + Assert.NotNull(result); - ClassicAssert.AreEqual(2, result.Count); + Assert.AreEqual(2, result.Count); } [Test] @@ -77,9 +77,9 @@ public void CanAddStartsWithFilter_2() var result = CliConfigMapper.BuildObjectList(config); - ClassicAssert.NotNull(result); + Assert.NotNull(result); - ClassicAssert.AreEqual(5, result.Count); + Assert.AreEqual(5, result.Count); } [Test] @@ -93,9 +93,9 @@ public void CanAddStartsWithFilterAndExplicitInclude() var result = CliConfigMapper.BuildObjectList(config); - ClassicAssert.NotNull(result); + Assert.NotNull(result); - ClassicAssert.AreEqual(3, result.Count); + Assert.AreEqual(3, result.Count); } [Test] @@ -109,9 +109,9 @@ public void MultipleExclusionWildcardExcludes() var result = CliConfigMapper.BuildObjectList(config); - ClassicAssert.NotNull(result); + Assert.NotNull(result); - ClassicAssert.AreEqual(3, result.Count); + Assert.AreEqual(3, result.Count); } [Test] @@ -123,9 +123,9 @@ public void CanAddEndsWithFilter() var result = CliConfigMapper.BuildObjectList(config); - ClassicAssert.NotNull(result); + Assert.NotNull(result); - ClassicAssert.AreEqual(4, result.Count); + Assert.AreEqual(4, result.Count); } [Test] @@ -139,9 +139,9 @@ public void CanAddEndsWithFilterAndExplicitInclude() var result = CliConfigMapper.BuildObjectList(config); - ClassicAssert.NotNull(result); + Assert.NotNull(result); - ClassicAssert.AreEqual(4, result.Count); + Assert.AreEqual(4, result.Count); } [Test] @@ -153,9 +153,9 @@ public void CanAddContainsFilter() var result = CliConfigMapper.BuildObjectList(config); - ClassicAssert.NotNull(result); + Assert.NotNull(result); - ClassicAssert.AreEqual(4, result.Count); + Assert.AreEqual(4, result.Count); } [Test] @@ -169,9 +169,9 @@ public void CanAddContainsFilterAndExplicitInclude() var result = CliConfigMapper.BuildObjectList(config); - ClassicAssert.NotNull(result); + Assert.NotNull(result); - ClassicAssert.AreEqual(5, result.Count); + Assert.AreEqual(5, result.Count); } [Test] @@ -190,17 +190,17 @@ public void TryGetCliConfigWithExistingFileReturnsExpectedConfig() out CliConfig resultConfig, out List warnings); - ClassicAssert.True(fetchedConfigSuccess); + Assert.True(fetchedConfigSuccess); - ClassicAssert.NotNull(resultConfig); + Assert.NotNull(resultConfig); - ClassicAssert.True(config.Tables.Count == resultConfig.Tables.Count); + Assert.True(config.Tables.Count == resultConfig.Tables.Count); for (var i = 0; i < config.Tables.Count; i++) { - ClassicAssert.AreEqual(config.Tables[i].Name, resultConfig.Tables[i].Name); - ClassicAssert.AreEqual(config.Tables[i].Exclude, resultConfig.Tables[i].Exclude); - ClassicAssert.AreEqual(config.Tables[i].ExclusionWildcard, resultConfig.Tables[i].ExclusionWildcard); + Assert.AreEqual(config.Tables[i].Name, resultConfig.Tables[i].Name); + Assert.AreEqual(config.Tables[i].Exclude, resultConfig.Tables[i].Exclude); + Assert.AreEqual(config.Tables[i].ExclusionWildcard, resultConfig.Tables[i].ExclusionWildcard); } } finally @@ -248,26 +248,26 @@ public void TryGetCliConfigWithExcludedColumnsReturns() out CliConfig resultConfig, out List warnings); - ClassicAssert.True(fetchedConfigSuccess); + Assert.True(fetchedConfigSuccess); - ClassicAssert.NotNull(resultConfig); + Assert.NotNull(resultConfig); - ClassicAssert.True(config.Tables.Count == resultConfig.Tables.Count); + Assert.True(config.Tables.Count == resultConfig.Tables.Count); for (var i = 0; i < config.Tables.Count; i++) { - ClassicAssert.AreEqual(config.Tables[i].Name, resultConfig.Tables[i].Name); - ClassicAssert.AreEqual(config.Tables[i].Exclude, resultConfig.Tables[i].Exclude); - ClassicAssert.AreEqual(config.Tables[i].ExclusionWildcard, resultConfig.Tables[i].ExclusionWildcard); + Assert.AreEqual(config.Tables[i].Name, resultConfig.Tables[i].Name); + Assert.AreEqual(config.Tables[i].Exclude, resultConfig.Tables[i].Exclude); + Assert.AreEqual(config.Tables[i].ExclusionWildcard, resultConfig.Tables[i].ExclusionWildcard); } - ClassicAssert.True(warnings.Count == 4); - ClassicAssert.True(resultConfig.Tables[0].ExcludedColumns.Count == 3); - ClassicAssert.True(resultConfig.Tables[0].ExcludedColumns[0] == "UserId"); - ClassicAssert.True(resultConfig.Views[0].ExcludedColumns.Count == 3); - ClassicAssert.True(resultConfig.Views[0].ExcludedColumns[0] == "UserId"); - ClassicAssert.IsNull(resultConfig.Functions[0].ExcludedColumns); - ClassicAssert.IsNull(resultConfig.StoredProcedures[0].ExcludedColumns); + Assert.True(warnings.Count == 4); + Assert.True(resultConfig.Tables[0].ExcludedColumns.Count == 3); + Assert.True(resultConfig.Tables[0].ExcludedColumns[0] == "UserId"); + Assert.True(resultConfig.Views[0].ExcludedColumns.Count == 3); + Assert.True(resultConfig.Views[0].ExcludedColumns[0] == "UserId"); + Assert.IsNull(resultConfig.Functions[0].ExcludedColumns); + Assert.IsNull(resultConfig.StoredProcedures[0].ExcludedColumns); } finally { diff --git a/src/Core/NUnitTestCore/ConnectionStringResolverTest.cs b/src/Core/NUnitTestCore/ConnectionStringResolverTest.cs index 7ca246bea..e99656797 100644 --- a/src/Core/NUnitTestCore/ConnectionStringResolverTest.cs +++ b/src/Core/NUnitTestCore/ConnectionStringResolverTest.cs @@ -3,7 +3,6 @@ using MySqlConnector; using Npgsql; using NUnit.Framework; -using NUnit.Framework.Legacy; using Oracle.ManagedDataAccess.Client; using RevEng.Core; @@ -24,7 +23,7 @@ public void CanRedactSql() var result = resolver.Redact(); - ClassicAssert.AreEqual("data source=.", result); + Assert.AreEqual("data source=.", result); } @@ -40,7 +39,7 @@ public void CanRedactNpgsql() var result = resolver.Redact(); - ClassicAssert.AreEqual("host=localhost", result); + Assert.AreEqual("host=localhost", result); } [Test] @@ -55,7 +54,7 @@ public void CanRedactMysql() var result = resolver.Redact(); - ClassicAssert.AreEqual("server=localhost", result); + Assert.AreEqual("server=localhost", result); } [Test] @@ -70,7 +69,7 @@ public void CanRedactOracle() var result = resolver.Redact(); - ClassicAssert.AreEqual("data source=localhost", result); + Assert.AreEqual("data source=localhost", result); } [Test] @@ -85,7 +84,7 @@ public void CanRedactFirebird() var result = resolver.Redact(); - ClassicAssert.AreEqual("data source=localhost", result); + Assert.AreEqual("data source=localhost", result); } } } diff --git a/src/Core/NUnitTestCore/CustomHumanizerPluralizerTest.cs b/src/Core/NUnitTestCore/CustomHumanizerPluralizerTest.cs index b5c36ca12..9f57971bd 100644 --- a/src/Core/NUnitTestCore/CustomHumanizerPluralizerTest.cs +++ b/src/Core/NUnitTestCore/CustomHumanizerPluralizerTest.cs @@ -1,6 +1,5 @@ using Humanizer.Inflections; using NUnit.Framework; -using NUnit.Framework.Legacy; using RevEng.Core; namespace UnitTests @@ -42,7 +41,7 @@ private static void Pluralize(string word) var sut = new HumanizerPluralizer(); var result = sut.Pluralize(word); - ClassicAssert.True(word == result); + Assert.True(word == result); } private static void Singularize(string word) @@ -51,7 +50,7 @@ private static void Singularize(string word) var sut = new HumanizerPluralizer(); var result = sut.Singularize(word); - ClassicAssert.True(word == result); + Assert.True(word == result); } } } diff --git a/src/Core/NUnitTestCore/Dacpac/DacpacConsolidatorTest.cs b/src/Core/NUnitTestCore/Dacpac/DacpacConsolidatorTest.cs index 6cb50091d..10aba4c59 100644 --- a/src/Core/NUnitTestCore/Dacpac/DacpacConsolidatorTest.cs +++ b/src/Core/NUnitTestCore/Dacpac/DacpacConsolidatorTest.cs @@ -1,6 +1,5 @@ using GOEddie.Dacpac.References; using NUnit.Framework; -using NUnit.Framework.Legacy; namespace UnitTests { @@ -15,7 +14,7 @@ public void CanConsolidate_Issue_274() var result = DacpacConsolidator.Consolidate(@"C:\Users\Erik\Downloads\CompositeDatabase\CompositeDatabase\CompositeDatabase\bin\Debug\CompositeDatabase.dacpac"); // Assert - ClassicAssert.IsTrue(result.Contains("\\efpt-")); + Assert.IsTrue(result.Contains("\\efpt-")); } [Test] @@ -28,7 +27,7 @@ public void CanConsolidate_Without_References_Issue_274() var result = DacpacConsolidator.Consolidate(dacPath); // Assert - ClassicAssert.AreEqual(result, dacPath); + Assert.AreEqual(result, dacPath); } private string TestPath(string file) diff --git a/src/Core/NUnitTestCore/Dacpac/DacpacTest.cs b/src/Core/NUnitTestCore/Dacpac/DacpacTest.cs index 46fbb2b1a..e3959a5ba 100644 --- a/src/Core/NUnitTestCore/Dacpac/DacpacTest.cs +++ b/src/Core/NUnitTestCore/Dacpac/DacpacTest.cs @@ -5,7 +5,6 @@ using Microsoft.EntityFrameworkCore.Scaffolding; using Microsoft.EntityFrameworkCore.SqlServer.Metadata.Internal; using NUnit.Framework; -using NUnit.Framework.Legacy; using RevEng.Core.Abstractions; namespace UnitTests @@ -35,7 +34,7 @@ public void CanEnumerateTables() var dbModel = factory.Create(dacpac, options); // Assert - ClassicAssert.AreEqual(11, dbModel.Tables.Count()); + Assert.AreEqual(11, dbModel.Tables.Count()); } [Test] @@ -50,10 +49,10 @@ public void CanEnumerateSelectedTables() var dbModel = factory.Create(dacpac, options); // Assert - ClassicAssert.AreEqual(3, dbModel.Tables.Count()); - ClassicAssert.AreEqual("Album", dbModel.Tables[0].Name); - ClassicAssert.AreEqual(1, dbModel.Tables[0].ForeignKeys.Count); - ClassicAssert.AreEqual(3, dbModel.Tables[0].Columns.Count); + Assert.AreEqual(3, dbModel.Tables.Count()); + Assert.AreEqual("Album", dbModel.Tables[0].Name); + Assert.AreEqual(1, dbModel.Tables[0].ForeignKeys.Count); + Assert.AreEqual(3, dbModel.Tables[0].Columns.Count); } [Test] @@ -68,14 +67,14 @@ public void CanEnumerateSelectedQuirkObjects() var dbModel = factory.Create(dacpacQuirk, options); // Assert - ClassicAssert.AreEqual(2, dbModel.Tables.Count()); + Assert.AreEqual(2, dbModel.Tables.Count()); - ClassicAssert.AreEqual("FilteredIndexTable", dbModel.Tables[1].Name); - ClassicAssert.AreEqual(0, dbModel.Tables[1].ForeignKeys.Count); - ClassicAssert.AreEqual(2, dbModel.Tables[1].Columns.Count); + Assert.AreEqual("FilteredIndexTable", dbModel.Tables[1].Name); + Assert.AreEqual(0, dbModel.Tables[1].ForeignKeys.Count); + Assert.AreEqual(2, dbModel.Tables[1].Columns.Count); - ClassicAssert.AreEqual("DefaultComputedValues", dbModel.Tables[0].Name); - ClassicAssert.AreEqual(5, dbModel.Tables[0].Columns.Count); + Assert.AreEqual("DefaultComputedValues", dbModel.Tables[0].Name); + Assert.AreEqual(5, dbModel.Tables[0].Columns.Count); } [Test] @@ -90,10 +89,10 @@ public void CanEnumerateSelectedComputed() var dbModel = factory.Create(dacpacQuirk, options); // Assert - ClassicAssert.AreEqual(1, dbModel.Tables.Count()); + Assert.AreEqual(1, dbModel.Tables.Count()); - ClassicAssert.AreEqual("DefaultComputedValues", dbModel.Tables[0].Name); - ClassicAssert.AreEqual(5, dbModel.Tables[0].Columns.Count); + Assert.AreEqual("DefaultComputedValues", dbModel.Tables[0].Name); + Assert.AreEqual(5, dbModel.Tables[0].Columns.Count); } [Test] @@ -108,12 +107,12 @@ public void CanEnumerateTypeAlias() var dbModel = factory.Create(dacpacQuirk, options); // Assert - ClassicAssert.AreEqual(1, dbModel.Tables.Count()); + Assert.AreEqual(1, dbModel.Tables.Count()); - ClassicAssert.AreEqual("TypeAlias", dbModel.Tables[0].Name); - ClassicAssert.AreEqual(2, dbModel.Tables[0].Columns.Count); + Assert.AreEqual("TypeAlias", dbModel.Tables[0].Name); + Assert.AreEqual(2, dbModel.Tables[0].Columns.Count); - ClassicAssert.AreEqual("nvarchar(max)", dbModel.Tables[0].Columns[1].StoreType); + Assert.AreEqual("nvarchar(max)", dbModel.Tables[0].Columns[1].StoreType); } [Test] @@ -128,8 +127,8 @@ public void CanHandleDefaultValues() var dbModel = factory.Create(dacpacQuirk, options); // Assert - ClassicAssert.AreEqual(1, dbModel.Tables.Count()); - ClassicAssert.AreEqual(1, dbModel.Tables + Assert.AreEqual(1, dbModel.Tables.Count()); + Assert.AreEqual(1, dbModel.Tables .Count(t => t.Columns.Any(c => c.DefaultValueSql != null))); } @@ -144,7 +143,7 @@ public void CanBuildAW2014() var dbModel = factory.Create(TestPath("AdventureWorks2014.dacpac"), options); // Assert - ClassicAssert.AreEqual(91, dbModel.Tables.Count()); + Assert.AreEqual(91, dbModel.Tables.Count()); } [Test] @@ -158,7 +157,7 @@ public void Issue208ComputedConstraint() var dbModel = factory.Create(TestPath("Issue208.dacpac"), options); // Assert - ClassicAssert.AreEqual(1, dbModel.Tables.Count()); + Assert.AreEqual(1, dbModel.Tables.Count()); } [Test] @@ -172,7 +171,7 @@ public void Issue210ComputedConstraintIsFK() var dbModel = factory.Create(TestPath("Issue210.dacpac"), options); // Assert - ClassicAssert.AreEqual(2, dbModel.Tables.Count()); + Assert.AreEqual(2, dbModel.Tables.Count()); } [Test] @@ -185,8 +184,8 @@ public void Issue1262_ConsiderSchemaArgument() var dbModel = factory.Create(TestPath("Issue1262.dacpac"), options); // Assert - ClassicAssert.AreEqual(1, dbModel.Tables.Count()); - ClassicAssert.AreEqual("mat", dbModel.Tables.Single().Schema); + Assert.AreEqual(1, dbModel.Tables.Count()); + Assert.AreEqual("mat", dbModel.Tables.Single().Schema); } [Test] @@ -199,9 +198,9 @@ public void Issue1262_BehaviourWithoutSchemaArgument() var dbModel = factory.Create(TestPath("Issue1262.dacpac"), options); // Assert - ClassicAssert.AreEqual(2, dbModel.Tables.Count()); - ClassicAssert.AreEqual(1, dbModel.Tables.Count(x => x.Schema == "mat")); - ClassicAssert.AreEqual(1, dbModel.Tables.Count(x => x.Schema == "mat2")); + Assert.AreEqual(2, dbModel.Tables.Count()); + Assert.AreEqual(1, dbModel.Tables.Count(x => x.Schema == "mat")); + Assert.AreEqual(1, dbModel.Tables.Count(x => x.Schema == "mat2")); } [Test] @@ -215,8 +214,8 @@ public void Temporal_Support() var dbModel = factory.Create(TestPath("Temporal.dacpac"), options); // Assert - ClassicAssert.AreEqual(1, dbModel.Tables.Count()); - ClassicAssert.NotNull(dbModel.Tables.Single().FindAnnotation(SqlServerAnnotationNames.IsTemporal)); + Assert.AreEqual(1, dbModel.Tables.Count()); + Assert.NotNull(dbModel.Tables.Single().FindAnnotation(SqlServerAnnotationNames.IsTemporal)); } [Test] @@ -230,10 +229,10 @@ public void Issue_2322_Tvp_Sproc_Parameters() var dbModel = factory.Create(TestPath("TvpParams.dacpac"), options); // Assert - ClassicAssert.AreEqual(1, dbModel.Routines.Count); - ClassicAssert.AreEqual(2, dbModel.Routines[0].Parameters.Count); - ClassicAssert.AreEqual("[Constant].[NumberIDList]", dbModel.Routines[0].Parameters[0].TypeName); - ClassicAssert.AreEqual("structured", dbModel.Routines[0].Parameters[0].StoreType); + Assert.AreEqual(1, dbModel.Routines.Count); + Assert.AreEqual(2, dbModel.Routines[0].Parameters.Count); + Assert.AreEqual("[Constant].[NumberIDList]", dbModel.Routines[0].Parameters[0].TypeName); + Assert.AreEqual("structured", dbModel.Routines[0].Parameters[0].StoreType); } private string TestPath(string file) diff --git a/src/Core/NUnitTestCore/DbContextSplitterTest.cs b/src/Core/NUnitTestCore/DbContextSplitterTest.cs index a9ba481bb..c7608cc6b 100644 --- a/src/Core/NUnitTestCore/DbContextSplitterTest.cs +++ b/src/Core/NUnitTestCore/DbContextSplitterTest.cs @@ -1,5 +1,4 @@ using NUnit.Framework; -using NUnit.Framework.Legacy; using RevEng.Core; namespace UnitTests @@ -12,7 +11,7 @@ public void CanSplit() { var result = DbContextSplitter.Split("C:\\Code\\Github\\EFCorePowerTools\\test\\Ef7Playground\\Ef7Playground\\Models\\NorthwindContext.cs", "Test", false, "NorthwindContext"); - ClassicAssert.NotNull(result); + Assert.NotNull(result); } } } diff --git a/src/Core/NUnitTestCore/Dgml/DgmlTest.cs b/src/Core/NUnitTestCore/Dgml/DgmlTest.cs index aa84280a5..e516f5b15 100644 --- a/src/Core/NUnitTestCore/Dgml/DgmlTest.cs +++ b/src/Core/NUnitTestCore/Dgml/DgmlTest.cs @@ -5,7 +5,6 @@ using System.Text; using Dgml; using NUnit.Framework; -using NUnit.Framework.Legacy; namespace UnitTests { @@ -30,10 +29,10 @@ public void ParseDebugViewSample1() var result = DebugViewParser.Parse(debugView, "Test"); // Assert - ClassicAssert.AreEqual(110, result.Nodes.Count); - ClassicAssert.AreEqual(122, result.Links.Count); + Assert.AreEqual(110, result.Nodes.Count); + Assert.AreEqual(122, result.Links.Count); - ClassicAssert.AreEqual(2, result.Links.Count(n => n.Contains("IsUnique=\"True\""))); + Assert.AreEqual(2, result.Links.Count(n => n.Contains("IsUnique=\"True\""))); } [Test] @@ -46,10 +45,10 @@ public void ParseDebugViewFkBug() var result = DebugViewParser.Parse(debugView, "Test"); // Assert - ClassicAssert.AreEqual(129, result.Nodes.Count); - ClassicAssert.AreEqual(141, result.Links.Count); + Assert.AreEqual(129, result.Nodes.Count); + Assert.AreEqual(141, result.Links.Count); - ClassicAssert.AreEqual(0, result.Links.Count(n => n.Contains("IsUnique=\"True\""))); + Assert.AreEqual(0, result.Links.Count(n => n.Contains("IsUnique=\"True\""))); } [Test] @@ -62,8 +61,8 @@ public void ParseDebugViewMultiColFk() var result = DebugViewParser.Parse(debugView, "Test"); // Assert - ClassicAssert.AreEqual(160, result.Nodes.Count); - ClassicAssert.AreEqual(172, result.Links.Count); + Assert.AreEqual(160, result.Nodes.Count); + Assert.AreEqual(172, result.Links.Count); } [Test] @@ -76,8 +75,8 @@ public void ParseDebugViewIssue604() var result = DebugViewParser.Parse(debugView, "Test"); // Assert - ClassicAssert.AreEqual(124, result.Nodes.Count); - ClassicAssert.AreEqual(150, result.Links.Count); + Assert.AreEqual(124, result.Nodes.Count); + Assert.AreEqual(150, result.Links.Count); } [Test] @@ -87,7 +86,7 @@ public void BuildChinook() var result = DgmlBuilder.Build(ReadAllText("ChinookContext.txt"), "test", template); // Assert - ClassicAssert.AreNotEqual(null, result); + Assert.AreNotEqual(null, result); File.WriteAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, @"Chinook.dgml"), result, Encoding.UTF8); } @@ -99,7 +98,7 @@ public void BuildSample1() var result = DgmlBuilder.Build(ReadAllText("Aw2014Person.txt"), "test", template); // Assert - ClassicAssert.AreNotEqual(null, result); + Assert.AreNotEqual(null, result); File.WriteAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, @"Aw2014Person.dgml"), result, Encoding.UTF8); } @@ -111,7 +110,7 @@ public void BuildNorthwind() var result = DgmlBuilder.Build(ReadAllText("Northwind.txt"), "test", template); // Assert - ClassicAssert.AreNotEqual(null, result); + Assert.AreNotEqual(null, result); File.WriteAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, @"northwind.dgml"), result, Encoding.UTF8); } @@ -123,7 +122,7 @@ public void BuildPfizer() var result = DgmlBuilder.Build(ReadAllText("Pfizer.txt"), "test", template); // Assert - ClassicAssert.AreNotEqual(null, result); + Assert.AreNotEqual(null, result); File.WriteAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, @"pfizer.dgml"), result, Encoding.UTF8); } @@ -135,7 +134,7 @@ public void BuildBNoFk() var result = DgmlBuilder.Build(ReadAllText("NoFk.txt"), "test", template); // Assert - ClassicAssert.AreNotEqual(null, result); + Assert.AreNotEqual(null, result); File.WriteAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, "nofk.dgml"), result, Encoding.UTF8); } @@ -147,7 +146,7 @@ public void BuildSingleNav() var result = DgmlBuilder.Build(ReadAllText("SingleNav.txt"), "test", template); // Assert - ClassicAssert.AreNotEqual(null, result); + Assert.AreNotEqual(null, result); File.WriteAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, @"singlenav.dgml"), result, Encoding.UTF8); } @@ -159,7 +158,7 @@ public void BuildSamurai() var result = DgmlBuilder.Build(ReadAllText("Samurai.txt"), "test", template); // Assert - ClassicAssert.AreNotEqual(null, result); + Assert.AreNotEqual(null, result); File.WriteAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, @"Samurai.dgml"), result, Encoding.UTF8); } @@ -171,7 +170,7 @@ public void BuildIssue604() var result = DgmlBuilder.Build(ReadAllText("Issue604.txt"), "test", template); // Assert - ClassicAssert.AreNotEqual(null, result); + Assert.AreNotEqual(null, result); File.WriteAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, @"Issue604.dgml"), result, Encoding.UTF8); } @@ -183,7 +182,7 @@ public void BuildIssue687() var result = DgmlBuilder.Build(ReadAllText("Issue687.txt"), "test", template); // Assert - ClassicAssert.AreNotEqual(null, result); + Assert.AreNotEqual(null, result); File.WriteAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, @"Issue604.dgml"), result, Encoding.UTF8); } @@ -195,7 +194,7 @@ public void BuildIdentity() var result = DgmlBuilder.Build(ReadAllText("Identity.txt"), "test", template); // Assert - ClassicAssert.AreNotEqual(null, result); + Assert.AreNotEqual(null, result); File.WriteAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, @"Identity.dgml"), result, Encoding.UTF8); } @@ -207,7 +206,7 @@ public void BuildLongView50() var result = DgmlBuilder.Build(ReadAllText("longview50.txt"), "test", template); // Assert - ClassicAssert.AreNotEqual(null, result); + Assert.AreNotEqual(null, result); File.WriteAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, @"LongView50.dgml"), result, Encoding.UTF8); } diff --git a/src/Core/NUnitTestCore/NUnitTestCore.csproj b/src/Core/NUnitTestCore/NUnitTestCore.csproj index 90909e8c7..623b31f8b 100644 --- a/src/Core/NUnitTestCore/NUnitTestCore.csproj +++ b/src/Core/NUnitTestCore/NUnitTestCore.csproj @@ -91,7 +91,9 @@ - + + + diff --git a/src/Core/NUnitTestCore/ReplacingCandidateNamingServiceTests.cs b/src/Core/NUnitTestCore/ReplacingCandidateNamingServiceTests.cs index c1de7ab24..2852e9df0 100644 --- a/src/Core/NUnitTestCore/ReplacingCandidateNamingServiceTests.cs +++ b/src/Core/NUnitTestCore/ReplacingCandidateNamingServiceTests.cs @@ -2,7 +2,7 @@ using System.Reflection; using Microsoft.EntityFrameworkCore.Scaffolding.Metadata; using NUnit.Framework; -using NUnit.Framework.Legacy; +//using NUnit.Framework.Legacy; using RevEng.Common; using RevEng.Core; diff --git a/src/Core/NUnitTestCore/SqlServerTypeExtensionsTest.cs b/src/Core/NUnitTestCore/SqlServerTypeExtensionsTest.cs index 6431b753a..f5da656f0 100644 --- a/src/Core/NUnitTestCore/SqlServerTypeExtensionsTest.cs +++ b/src/Core/NUnitTestCore/SqlServerTypeExtensionsTest.cs @@ -1,6 +1,5 @@ using System; using NUnit.Framework; -using NUnit.Framework.Legacy; using RevEng.Core.Routines.Extensions; namespace UnitTests @@ -59,24 +58,24 @@ public void CanParseTypes() if (typeName == "date") { - ClassicAssert.AreEqual(typeof(DateTime?), res1); + Assert.AreEqual(typeof(DateTime?), res1); } if (typeName == "time") { - ClassicAssert.AreEqual(typeof(TimeSpan?), res1); + Assert.AreEqual(typeof(TimeSpan?), res1); } var res2 = SqlServerSqlTypeExtensions.GetClrType(typeName, false); if (typeName == "date") { - ClassicAssert.AreEqual(typeof(DateTime), res2); + Assert.AreEqual(typeof(DateTime), res2); } if (typeName == "time") { - ClassicAssert.AreEqual(typeof(TimeSpan), res2); + Assert.AreEqual(typeof(TimeSpan), res2); } SqlServerSqlTypeExtensions.UseDateOnlyTimeOnly = true; @@ -85,34 +84,34 @@ public void CanParseTypes() if (typeName == "date") { - ClassicAssert.AreEqual(typeof(DateOnly?), res3); + Assert.AreEqual(typeof(DateOnly?), res3); } if (typeName == "time") { - ClassicAssert.AreEqual(typeof(TimeOnly?), res3); + Assert.AreEqual(typeof(TimeOnly?), res3); } var res4 = SqlServerSqlTypeExtensions.GetClrType(typeName, false); if (typeName == "date") { - ClassicAssert.AreEqual(typeof(DateOnly), res4); + Assert.AreEqual(typeof(DateOnly), res4); } if (typeName == "time") { - ClassicAssert.AreEqual(typeof(TimeOnly), res4); + Assert.AreEqual(typeof(TimeOnly), res4); } } catch { System.Diagnostics.Debug.WriteLine("problem type: " + typeName); - ClassicAssert.Fail(); + Assert.Fail(); } } - ClassicAssert.Pass(); + Assert.Pass(); } } } diff --git a/src/GUI/RevEng.Shared/Cli/CliConfigMapper.cs b/src/GUI/RevEng.Shared/Cli/CliConfigMapper.cs index 79379d09b..6a669f061 100644 --- a/src/GUI/RevEng.Shared/Cli/CliConfigMapper.cs +++ b/src/GUI/RevEng.Shared/Cli/CliConfigMapper.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Runtime.Serialization; using System.Runtime.Serialization.Json; using System.Text; using System.Text.Json; @@ -185,20 +186,28 @@ public static ReverseEngineerOptions ToOptions(this CliConfig config, string pro ProjectRootNamespace = names.RootNamespace, UseDecimalDataAnnotationForSprocResult = config.CodeGeneration.UseDecimalDataAnnotation, UsePrefixNavigationNaming = config.CodeGeneration.UsePrefixNavigationNaming, + UseDatabaseNamesForRoutines = config.CodeGeneration.UseDatabaseNamesForRoutines, UseInternalAccessModifiersForSprocsAndFunctions = config.CodeGeneration.UseInternalAccessModifiersForSprocsAndFunctions, // HandleBars templates are not supported: UseHandleBars = false, SelectedHandlebarsLanguage = 0, // handlebars support, will not support it - OptionsPath = null, // handlebars support, will not support it + OptionsPath = null, // handlebars support, will not support it (not in use!) - [IgnoreDataMember] // Not implemented: UseNoDefaultConstructor = false, // not implemented, will consider if asked for - DefaultDacpacSchema = null, // not implemented, will consider if asked for + DefaultDacpacSchema = null, // not implemented, will consider if asked for - [IgnoreDataMember] UseNoObjectFilter = false, // will add all objects and use exclusions to filter list - "refresh-object-lists" allows you to avoid this (switch to manual) UseAsyncStoredProcedureCalls = true, // not implemented FilterSchemas = false, // not implemented - Schemas = null, // not implemented + Schemas = null, // not implemented, + + CodeGenerationMode = CodeGenerationMode.EFCore8, // not implemented/persisted + + ConnectionString = null, // not persisted, set at runtime - [IgnoreDataMember] + DatabaseType = DatabaseType.Undefined, // not persisted, set at runtime - [IgnoreDataMember] + InstallNuGetPackage = false, // not persisted, set at runtime - [IgnoreDataMember] + UiHint = null, // not persisted, set in .user file }; if (config.FileLayout is null) diff --git a/tools/code-sign.txt b/tools/code-sign.txt index 4e15c2e2e..079f1ee9c 100644 --- a/tools/code-sign.txt +++ b/tools/code-sign.txt @@ -16,8 +16,9 @@ fileslist.txt: EFCorePowerTools.dll RevEng.Common.dll --k = Key container id vist af certutil --cfp = +-k = Key container id vist af certutil - certutil -user -store my "" + +-cfp = fingerprint: Get-FileHash -Algorithm SHA256 | Format-Table -AutoSize 5: Upload to MarketPlace