Skip to content

Commit 36e7740

Browse files
Added additional netcoreapp3.1 target framework for integration testing
1 parent 59f8604 commit 36e7740

File tree

7 files changed

+140
-69
lines changed

7 files changed

+140
-69
lines changed

test/DotNetToolkit.Repository.Integration.Test/Data/TestBase.cs

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected void ForRepositoryFactoryWithAllCachingProvidersAsync(ContextProviderT
6767
ApplyCachingProvider(cachingProvider, builder);
6868

6969
await HandleExceptionAsync(() => action(
70-
new RepositoryFactory(builder.Options),
70+
new RepositoryFactory(builder.Options),
7171
cachingProvider));
7272
});
7373

@@ -204,6 +204,7 @@ protected RepositoryOptionsBuilder GetRepositoryOptionsBuilder(ContextProviderTy
204204
builder.UseXmlDatabase(Path.GetTempPath() + Guid.NewGuid().ToString("N"));
205205
break;
206206
}
207+
#if NETFULL
207208
case ContextProviderType.AdoNet:
208209
{
209210
builder.UseAdoNet(DbConnectionHelper.CreateConnection(), ensureDatabaseCreated: true);
@@ -245,16 +246,6 @@ protected RepositoryOptionsBuilder GetRepositoryOptionsBuilder(ContextProviderTy
245246
builder.UseEntityFramework<TestEfDbContext>(DbConnectionHelper.CreateConnection());
246247
break;
247248
}
248-
case ContextProviderType.EntityFrameworkCore:
249-
{
250-
builder.UseEntityFrameworkCore<TestEfCoreDbContext>(options =>
251-
{
252-
options
253-
.UseInMemoryDatabase(Guid.NewGuid().ToString())
254-
.ConfigureWarnings(x => x.Ignore(InMemoryEventId.TransactionIgnoredWarning));
255-
});
256-
break;
257-
}
258249
case ContextProviderType.AzureStorageBlob:
259250
{
260251
builder.UseAzureStorageBlob(
@@ -271,6 +262,18 @@ protected RepositoryOptionsBuilder GetRepositoryOptionsBuilder(ContextProviderTy
271262
createIfNotExists: true);
272263
break;
273264
}
265+
#else
266+
case ContextProviderType.EntityFrameworkCore:
267+
{
268+
builder.UseEntityFrameworkCore<TestEfCoreDbContext>(options =>
269+
{
270+
options
271+
.UseInMemoryDatabase(Guid.NewGuid().ToString())
272+
.ConfigureWarnings(x => x.Ignore(InMemoryEventId.TransactionIgnoredWarning));
273+
});
274+
break;
275+
}
276+
#endif
274277
default:
275278
throw new ArgumentOutOfRangeException(nameof(provider));
276279
}
@@ -299,6 +302,7 @@ private static void ApplyCachingProvider(CachingProviderType cachingProvider, Re
299302

300303
break;
301304
}
305+
#if NETFULL
302306
case CachingProviderType.Memcached:
303307
{
304308
var provider = new MemcachedCacheProvider("127.0.0.1", 11211);
@@ -309,6 +313,7 @@ private static void ApplyCachingProvider(CachingProviderType cachingProvider, Re
309313

310314
break;
311315
}
316+
#endif
312317
case CachingProviderType.Couchbase:
313318
{
314319
var provider = new CouchbaseCacheProvider("http://localhost:8091", "default", "password");
@@ -334,7 +339,9 @@ protected static ContextProviderType[] InMemoryContextProviders()
334339
=> new[]
335340
{
336341
ContextProviderType.InMemory,
337-
ContextProviderType.EntityFrameworkCore,
342+
#if NETSTANDARD2_0
343+
ContextProviderType.EntityFrameworkCore,
344+
#endif
338345
};
339346

340347
protected static ContextProviderType[] FileStreamContextProviders()
@@ -345,26 +352,36 @@ protected static ContextProviderType[] FileStreamContextProviders()
345352
};
346353

347354
protected static ContextProviderType[] SqlServerContextProviders()
355+
#if NETFULL
348356
=> new[]
349357
{
350-
ContextProviderType.AdoNet,
351358
ContextProviderType.NHibernate,
359+
ContextProviderType.AdoNet,
352360
ContextProviderType.EntityFramework,
353361
};
362+
#else
363+
=> Array.Empty<ContextProviderType>();
364+
#endif
354365

355366
protected static ContextProviderType[] AzureStorageContextProviders()
367+
#if NETFULL
356368
=> new[]
357369
{
358370
ContextProviderType.AzureStorageBlob,
359371
ContextProviderType.AzureStorageTable,
360372
};
373+
#else
374+
=> Array.Empty<ContextProviderType>();
375+
#endif
361376

362377
private static CachingProviderType[] CachingProviders()
363378
=> new[]
364379
{
365380
CachingProviderType.MicrosoftInMemory,
366381
CachingProviderType.Redis,
367-
CachingProviderType.Memcached,
382+
#if NETFULL
383+
CachingProviderType.Memcached,
384+
#endif
368385
//TODO: Cannot test when Appveyor is running tests.
369386
//I am not able to find the pre-built binaries so that I can manually run
370387
//the server (similar to redis and memcached). I am going to comment out testing couchbase for now
@@ -404,4 +421,4 @@ public enum CachingProviderType
404421
Couchbase,
405422
}
406423
}
407-
}
424+
}

test/DotNetToolkit.Repository.Integration.Test/Data/TestEfCoreDbContext.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
{
33
using Microsoft.EntityFrameworkCore;
44

5-
public class TestEfCoreDbContext : Microsoft.EntityFrameworkCore.DbContext
5+
public class TestEfCoreDbContext : DbContext
66
{
7-
public System.Data.Entity.DbSet<Customer> Customers { get; set; }
8-
public System.Data.Entity.DbSet<CustomerAddress> CustomerAddresses { get; set; }
9-
public System.Data.Entity.DbSet<CustomerWithMultipleAddresses> CustomerWithMultipleAddresses { get; set; }
10-
public System.Data.Entity.DbSet<CustomerWithCompositeAddress> CustomersWithCompositeAddress { get; set; }
11-
public System.Data.Entity.DbSet<CustomerWithTwoCompositePrimaryKey> CustomersWithTwoCompositePrimaryKey { get; set; }
12-
public System.Data.Entity.DbSet<CustomerWithThreeCompositePrimaryKey> CustomersWithThreeCompositePrimaryKey { get; set; }
13-
public System.Data.Entity.DbSet<CustomerWithNoIdentity> CustomersWithNoIdentity { get; set; }
7+
public DbSet<Customer> Customers { get; set; }
8+
public DbSet<CustomerAddress> CustomerAddresses { get; set; }
9+
public DbSet<CustomerWithMultipleAddresses> CustomerWithMultipleAddresses { get; set; }
10+
public DbSet<CustomerWithCompositeAddress> CustomersWithCompositeAddress { get; set; }
11+
public DbSet<CustomerWithTwoCompositePrimaryKey> CustomersWithTwoCompositePrimaryKey { get; set; }
12+
public DbSet<CustomerWithThreeCompositePrimaryKey> CustomersWithThreeCompositePrimaryKey { get; set; }
13+
public DbSet<CustomerWithNoIdentity> CustomersWithNoIdentity { get; set; }
1414

1515
public TestEfCoreDbContext(DbContextOptions options) : base(options) { }
1616

test/DotNetToolkit.Repository.Integration.Test/Data/TestEfDbContext.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
namespace DotNetToolkit.Repository.Integration.Test.Data
1+
#if NETFULL
2+
namespace DotNetToolkit.Repository.Integration.Test.Data
23
{
34
using System.Data.Common;
45
using System.Data.Entity;
56

6-
public class TestEfDbContext : System.Data.Entity.DbContext
7+
public class TestEfDbContext : DbContext
78
{
8-
public System.Data.Entity.DbSet<Customer> Customers { get; set; }
9-
public System.Data.Entity.DbSet<CustomerAddress> CustomerAddresses { get; set; }
10-
public System.Data.Entity.DbSet<CustomerWithMultipleAddresses> CustomerWithMultipleAddresses { get; set; }
11-
public System.Data.Entity.DbSet<CustomerWithCompositeAddress> CustomersWithCompositeAddress { get; set; }
12-
public System.Data.Entity.DbSet<CustomerWithTwoCompositePrimaryKey> CustomersWithTwoCompositePrimaryKey { get; set; }
13-
public System.Data.Entity.DbSet<CustomerWithThreeCompositePrimaryKey> CustomersWithThreeCompositePrimaryKey { get; set; }
14-
public System.Data.Entity.DbSet<CustomerWithNoIdentity> CustomersWithNoIdentity { get; set; }
9+
public DbSet<Customer> Customers { get; set; }
10+
public DbSet<CustomerAddress> CustomerAddresses { get; set; }
11+
public DbSet<CustomerWithMultipleAddresses> CustomerWithMultipleAddresses { get; set; }
12+
public DbSet<CustomerWithCompositeAddress> CustomersWithCompositeAddress { get; set; }
13+
public DbSet<CustomerWithTwoCompositePrimaryKey> CustomersWithTwoCompositePrimaryKey { get; set; }
14+
public DbSet<CustomerWithThreeCompositePrimaryKey> CustomersWithThreeCompositePrimaryKey { get; set; }
15+
public DbSet<CustomerWithNoIdentity> CustomersWithNoIdentity { get; set; }
1516

1617
public TestEfDbContext(DbConnection connection, bool contextOwnsConnection)
1718
: base(connection, contextOwnsConnection) { }
@@ -44,3 +45,5 @@ protected override void OnModelCreating(DbModelBuilder modelBuilder)
4445
}
4546
}
4647
}
48+
49+
#endif

test/DotNetToolkit.Repository.Integration.Test/Data/TestEntity.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
using System.ComponentModel.DataAnnotations;
66
using System.ComponentModel.DataAnnotations.Schema;
77

8+
#if NETFULL
89
public class Customer : Microsoft.WindowsAzure.Storage.Table.TableEntity
10+
#else
11+
public class Customer
12+
#endif
913
{
1014
private int _id;
1115

@@ -17,12 +21,15 @@ public int Id
1721
set
1822
{
1923
_id = value;
24+
#if NETFULL
2025
RowKey = _id.ToString();
26+
#endif
2127
}
2228
}
2329
public string Name { get; set; }
2430
public CustomerAddress Address { get; set; }
2531

32+
#if NETFULL
2633
// for azure table compability (do not map since DateTimeOffset is not supported for sql)
2734
[NotMapped]
2835
public new DateTimeOffset Timestamp { get; set; }
@@ -31,6 +38,7 @@ public Customer()
3138
{
3239
PartitionKey = string.Empty;
3340
}
41+
#endif
3442
}
3543

3644
[Table("CustomersWithNoIdentity")]
@@ -65,7 +73,11 @@ public class CustomerWithThreeCompositePrimaryKeyAndNoOrder
6573
public string Name { get; set; }
6674
}
6775

76+
#if NETFULL
6877
public class CustomerWithTwoCompositePrimaryKey : Microsoft.WindowsAzure.Storage.Table.TableEntity
78+
#else
79+
public class CustomerWithTwoCompositePrimaryKey
80+
#endif
6981
{
7082
private int _id1;
7183
private string _id2;
@@ -78,7 +90,9 @@ public int Id1
7890
set
7991
{
8092
_id1 = value;
93+
#if NETFULL
8194
PartitionKey = _id1.ToString();
95+
#endif
8296
}
8397
}
8498
[Key]
@@ -89,14 +103,18 @@ public string Id2
89103
set
90104
{
91105
_id2 = value;
106+
#if NETFULL
92107
RowKey = _id2;
108+
#endif
93109
}
94110
}
95111
public string Name { get; set; }
96112

113+
#if NETFULL
97114
// for azure table compability (do not map since DateTimeOffset is not supported for sql)
98115
[NotMapped]
99116
public new DateTimeOffset Timestamp { get; set; }
117+
#endif
100118

101119
public override int GetHashCode()
102120
{
@@ -216,4 +234,4 @@ public interface IHaveTimeStamp
216234
string CreateUser { get; set; }
217235
string ModUser { get; set; }
218236
}
219-
}
237+
}

test/DotNetToolkit.Repository.Integration.Test/DotNetToolkit.Repository.Integration.Test.csproj

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="..\..\build\common.props" />
44

55
<PropertyGroup>
6-
<TargetFramework>net461</TargetFramework>
6+
<TargetFrameworks>net461;netcoreapp3.1</TargetFrameworks>
77

88
<IsPackable>false</IsPackable>
99
</PropertyGroup>
@@ -16,11 +16,28 @@
1616
<NoWarn>1701;1702;1705;1591</NoWarn>
1717
</PropertyGroup>
1818

19+
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
20+
<DefineConstants>NETCORE;NETSTANDARD;NETSTANDARD2_0</DefineConstants>
21+
</PropertyGroup>
22+
23+
<PropertyGroup Condition="'$(TargetFramework)' == 'net461'">
24+
<DefineConstants>NETFULL</DefineConstants>
25+
</PropertyGroup>
26+
27+
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
28+
<PackageReference Include="EntityFramework.SqlServerCompact" Version="6.4.0" />
29+
<Reference Include="System.Configuration" />
30+
<Reference Include="System.ComponentModel.DataAnnotations" />
31+
</ItemGroup>
32+
33+
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
34+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.2" />
35+
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
36+
</ItemGroup>
37+
1938
<ItemGroup>
2039
<PackageReference Include="CouchbaseNetClient" Version="2.7.16" />
21-
<PackageReference Include="EntityFramework.SqlServerCompact" Version="6.4.0" />
2240
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.2" />
23-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.2" />
2441
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
2542
<PackageReference Include="Moq" Version="4.13.1" />
2643
<PackageReference Include="xunit" Version="2.4.1" />

0 commit comments

Comments
 (0)