Skip to content

Commit 1d63b3f

Browse files
committed
#774 Testing
1 parent 4c6574a commit 1d63b3f

14 files changed

+1205
-1208
lines changed

Generator.Tests.Integration/SingleDatabaseTestBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ protected static void SetupDatabase(
3434
Settings.DisableGeographyTypes = false;
3535
Settings.AddUnitTestingDbContext = true;
3636
Settings.UsePascalCase = true;
37+
Settings.UseMappingTables = false;
3738

3839
ResetFilters();
3940
}

Generator.Tests.Integration/SingleDatabaseTestSqlServer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public void NonPascalCased(TemplateType templateType, string singleDbContextSubN
9797
SetupSqlServer("EfrpgTest", "My_db_context", "Efrpg_db_context", templateType, GeneratorType.EfCore, ForeignKeyNamingStrategy.Legacy);
9898
Settings.GenerateSeparateFiles = false;
9999
Settings.UsePascalCase = false;
100+
Settings.UseMappingTables = true;
100101

101102
// Act
102103
const string filename = "NonPascalCased";

Generator.Tests.Integration/TestComparison/EfrpgTestIncludeFilter_SqlServer_EfCore3_FkLegacy.cs

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
279279

280280

281281
// Stored Procedures
282-
public int AddTwoValues(int? a, int? b)
282+
public int AddTwoValues(int? a = null, int? b = null)
283283
{
284284
var aParam = new SqlParameter { ParameterName = "@a", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.Input, Value = a.GetValueOrDefault(), Precision = 10, Scale = 0 };
285285
if (!a.HasValue)
@@ -340,7 +340,7 @@ public int ASimpleExample()
340340

341341
// ASimpleExampleAsync() cannot be created due to having out parameters, or is relying on the procedure result (int)
342342

343-
public int Beta_Overclock(DateTime? parameter)
343+
public int Beta_Overclock(DateTime? parameter = null)
344344
{
345345
var parameterParam = new SqlParameter { ParameterName = "@Parameter", SqlDbType = SqlDbType.DateTime, Direction = ParameterDirection.Input, Value = parameter.GetValueOrDefault() };
346346
if (!parameter.HasValue)
@@ -355,9 +355,9 @@ public int Beta_Overclock(DateTime? parameter)
355355

356356
// Beta_OverclockAsync() cannot be created due to having out parameters, or is relying on the procedure result (int)
357357

358-
// public C182Test2ReturnModel C182Test2(int? flag) Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
358+
// public C182Test2ReturnModel C182Test2(int? flag = null) Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
359359

360-
// public async Task<C182Test2ReturnModel> C182Test2Async(int? flag) Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
360+
// public async Task<C182Test2ReturnModel> C182Test2Async(int? flag = null) Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
361361

362362
// public CheckIfApplicationIsCompleteReturnModel CheckIfApplicationIsComplete(int? applicationId, out bool? isApplicationComplete) Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
363363

@@ -423,7 +423,7 @@ public int ConvertToString(int? someValue, out string someString)
423423

424424
// ConvertToStringAsync() cannot be created due to having out parameters, or is relying on the procedure result (int)
425425

426-
public List<DboProcDataFromFfrsReturnModel> DboProcDataFromFfrs(int? maxId)
426+
public List<DboProcDataFromFfrsReturnModel> DboProcDataFromFfrs(int? maxId = null)
427427
{
428428
int procResult;
429429
return DboProcDataFromFfrs(maxId, out procResult);
@@ -445,7 +445,7 @@ public List<DboProcDataFromFfrsReturnModel> DboProcDataFromFfrs(int? maxId, out
445445
return procResultData;
446446
}
447447

448-
public async Task<List<DboProcDataFromFfrsReturnModel>> DboProcDataFromFfrsAsync(int? maxId)
448+
public async Task<List<DboProcDataFromFfrsReturnModel>> DboProcDataFromFfrsAsync(int? maxId = null)
449449
{
450450
var maxIdParam = new SqlParameter { ParameterName = "@maxId", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.Input, Value = maxId.GetValueOrDefault(), Precision = 10, Scale = 0 };
451451
if (!maxId.HasValue)
@@ -515,7 +515,7 @@ public async Task<List<DsOpeProcReturnModel>> DsOpeProcAsync()
515515
return procResultData;
516516
}
517517

518-
public List<GetSmallDecimalTestReturnModel> GetSmallDecimalTest(int? maxId)
518+
public List<GetSmallDecimalTestReturnModel> GetSmallDecimalTest(int? maxId = null)
519519
{
520520
int procResult;
521521
return GetSmallDecimalTest(maxId, out procResult);
@@ -537,7 +537,7 @@ public List<GetSmallDecimalTestReturnModel> GetSmallDecimalTest(int? maxId, out
537537
return procResultData;
538538
}
539539

540-
public async Task<List<GetSmallDecimalTestReturnModel>> GetSmallDecimalTestAsync(int? maxId)
540+
public async Task<List<GetSmallDecimalTestReturnModel>> GetSmallDecimalTestAsync(int? maxId = null)
541541
{
542542
var maxIdParam = new SqlParameter { ParameterName = "@maxId", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.Input, Value = maxId.GetValueOrDefault(), Precision = 10, Scale = 0 };
543543
if (!maxId.HasValue)
@@ -764,21 +764,21 @@ public int SpatialTypesWithParams(NetTopologySuite.Geometries.Geometry geometry,
764764

765765
// SpatialTypesWithParamsAsync() cannot be created due to having out parameters, or is relying on the procedure result (int)
766766

767-
// public StpMultipleIdenticalResultsReturnModel StpMultipleIdenticalResults(int? someVar) Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
767+
// public StpMultipleIdenticalResultsReturnModel StpMultipleIdenticalResults(int? someVar = null) Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
768768

769-
// public async Task<StpMultipleIdenticalResultsReturnModel> StpMultipleIdenticalResultsAsync(int? someVar) Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
769+
// public async Task<StpMultipleIdenticalResultsReturnModel> StpMultipleIdenticalResultsAsync(int? someVar = null) Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
770770

771-
// public StpMultipleMultipleResultsWithParamsReturnModel StpMultipleMultipleResultsWithParams(int? firstVal, int? secondVal, int? thirdVal) Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
771+
// public StpMultipleMultipleResultsWithParamsReturnModel StpMultipleMultipleResultsWithParams(int? firstVal = null, int? secondVal = null, int? thirdVal = null) Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
772772

773-
// public async Task<StpMultipleMultipleResultsWithParamsReturnModel> StpMultipleMultipleResultsWithParamsAsync(int? firstVal, int? secondVal, int? thirdVal) Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
773+
// public async Task<StpMultipleMultipleResultsWithParamsReturnModel> StpMultipleMultipleResultsWithParamsAsync(int? firstVal = null, int? secondVal = null, int? thirdVal = null) Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
774774

775775
// public StpMultipleResultsReturnModel StpMultipleResults() Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
776776

777777
// public async Task<StpMultipleResultsReturnModel> StpMultipleResultsAsync() Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
778778

779-
// public StpMultipleResultsWithParamsReturnModel StpMultipleResultsWithParams(int? firstVal, int? secondVal) Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
779+
// public StpMultipleResultsWithParamsReturnModel StpMultipleResultsWithParams(int? firstVal = null, int? secondVal = null) Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
780780

781-
// public async Task<StpMultipleResultsWithParamsReturnModel> StpMultipleResultsWithParamsAsync(int? firstVal, int? secondVal) Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
781+
// public async Task<StpMultipleResultsWithParamsReturnModel> StpMultipleResultsWithParamsAsync(int? firstVal = null, int? secondVal = null) Cannot be created as EF Core does not yet support stored procedures with multiple result sets.
782782

783783
public List<StpNoParamsTestReturnModel> StpNoParamsTest()
784784
{
@@ -819,7 +819,7 @@ public int StpNoReturnFields()
819819

820820
// StpNoReturnFieldsAsync() cannot be created due to having out parameters, or is relying on the procedure result (int)
821821

822-
public List<StpNullableParamsTestReturnModel> StpNullableParamsTest(int? aVal, int? bVal)
822+
public List<StpNullableParamsTestReturnModel> StpNullableParamsTest(int? aVal = null, int? bVal = null)
823823
{
824824
int procResult;
825825
return StpNullableParamsTest(aVal, bVal, out procResult);
@@ -845,7 +845,7 @@ public List<StpNullableParamsTestReturnModel> StpNullableParamsTest(int? aVal, i
845845
return procResultData;
846846
}
847847

848-
public async Task<List<StpNullableParamsTestReturnModel>> StpNullableParamsTestAsync(int? aVal, int? bVal)
848+
public async Task<List<StpNullableParamsTestReturnModel>> StpNullableParamsTestAsync(int? aVal = null, int? bVal = null)
849849
{
850850
var aValParam = new SqlParameter { ParameterName = "@a_val", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.Input, Value = aVal.GetValueOrDefault(), Precision = 10, Scale = 0 };
851851
if (!aVal.HasValue)
@@ -941,7 +941,7 @@ public async Task<List<StpTestUnderscoreTestReturnModel>> StpTestUnderscoreTestA
941941
return procResultData;
942942
}
943943

944-
public int StupidStoredProcedureParams(string reqType, short? dept, short? @class, short? item)
944+
public int StupidStoredProcedureParams(string reqType, short? dept = null, short? @class = null, short? item = null)
945945
{
946946
var reqTypeParam = new SqlParameter { ParameterName = "@ReqType", SqlDbType = SqlDbType.VarChar, Direction = ParameterDirection.Input, Value = reqType, Size = 25 };
947947
if (reqTypeParam.Value == null)
@@ -968,7 +968,7 @@ public int StupidStoredProcedureParams(string reqType, short? dept, short? @clas
968968

969969
// StupidStoredProcedureParamsAsync() cannot be created due to having out parameters, or is relying on the procedure result (int)
970970

971-
public int StupidStoredProcedureParams2(string @override, short? @readonly, short? @class, short? @enum)
971+
public int StupidStoredProcedureParams2(string @override, short? @readonly = null, short? @class = null, short? @enum = null)
972972
{
973973
var @overrideParam = new SqlParameter { ParameterName = "@override", SqlDbType = SqlDbType.VarChar, Direction = ParameterDirection.Input, Value = @override, Size = 25 };
974974
if (@overrideParam.Value == null)
@@ -1023,7 +1023,42 @@ public async Task<List<TestReturnStringReturnModel>> TestReturnStringAsync()
10231023
return procResultData;
10241024
}
10251025

1026-
public int UserDefinedTypeSampleStoredProc(int? a, DataTable type, int? b)
1026+
public int ThisHasMixedOutParameters(DateTime? foo, out int? firstOutParam, DateTime? bar, out int? secondOutParam, DateTime? baz = null)
1027+
{
1028+
var fooParam = new SqlParameter { ParameterName = "@Foo", SqlDbType = SqlDbType.DateTime, Direction = ParameterDirection.Input, Value = foo.GetValueOrDefault() };
1029+
if (!foo.HasValue)
1030+
fooParam.Value = DBNull.Value;
1031+
1032+
var firstOutParamParam = new SqlParameter { ParameterName = "@FirstOutParam", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.Output, Precision = 10, Scale = 0 };
1033+
var barParam = new SqlParameter { ParameterName = "@Bar", SqlDbType = SqlDbType.DateTime, Direction = ParameterDirection.Input, Value = bar.GetValueOrDefault() };
1034+
if (!bar.HasValue)
1035+
barParam.Value = DBNull.Value;
1036+
1037+
var secondOutParamParam = new SqlParameter { ParameterName = "@SecondOutParam", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.Output, Precision = 10, Scale = 0 };
1038+
var bazParam = new SqlParameter { ParameterName = "@Baz", SqlDbType = SqlDbType.DateTime, Direction = ParameterDirection.Input, Value = baz.GetValueOrDefault() };
1039+
if (!baz.HasValue)
1040+
bazParam.Value = DBNull.Value;
1041+
1042+
var procResultParam = new SqlParameter { ParameterName = "@procResult", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.Output };
1043+
1044+
Database.ExecuteSqlRaw("EXEC @procResult = [dbo].[ThisHasMixedOutParameters] @Foo, @FirstOutParam OUTPUT, @Bar, @SecondOutParam OUTPUT, @Baz", fooParam, firstOutParamParam, barParam, secondOutParamParam, bazParam, procResultParam);
1045+
1046+
if (IsSqlParameterNull(firstOutParamParam))
1047+
firstOutParam = null;
1048+
else
1049+
firstOutParam = (int) firstOutParamParam.Value;
1050+
1051+
if (IsSqlParameterNull(secondOutParamParam))
1052+
secondOutParam = null;
1053+
else
1054+
secondOutParam = (int) secondOutParamParam.Value;
1055+
1056+
return (int)procResultParam.Value;
1057+
}
1058+
1059+
// ThisHasMixedOutParametersAsync() cannot be created due to having out parameters, or is relying on the procedure result (int)
1060+
1061+
public int UserDefinedTypeSampleStoredProc(int? a, DataTable type, int? b = null)
10271062
{
10281063
var aParam = new SqlParameter { ParameterName = "@a", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.Input, Value = a.GetValueOrDefault(), Precision = 10, Scale = 0 };
10291064
if (!a.HasValue)
@@ -1089,7 +1124,7 @@ public int XmlDataV2()
10891124
// Table Valued Functions
10901125

10911126
// dbo.182_test1
1092-
public IQueryable<C182Test1ReturnModel> C182Test1(int? test)
1127+
public IQueryable<C182Test1ReturnModel> C182Test1(int? test = null)
10931128
{
10941129
return Set<C182Test1ReturnModel>()
10951130
.FromSqlRaw("SELECT * FROM [dbo].[182_test1]({0})", test)
@@ -1107,7 +1142,7 @@ public IQueryable<CsvToIntReturnModel> CsvToInt(string array, string array2)
11071142
// Scalar Valued Functions
11081143

11091144
[DbFunction("udfNetSale", "dbo")]
1110-
public decimal UdfNetSale(int? quantity, decimal? listPrice, decimal? discount)
1145+
public decimal UdfNetSale(int? quantity = null, decimal? listPrice = null, decimal? discount = null)
11111146
{
11121147
throw new Exception("Don't call this directly. Use LINQ to call the scalar valued function as part of your query");
11131148
}

0 commit comments

Comments
 (0)