Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CAP
Commits
14a3d4a5
Commit
14a3d4a5
authored
Jul 16, 2017
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temporarily remove
parent
8294a586
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
216 additions
and
429 deletions
+216
-429
DatabaseTestHost.cs
...tNetCore.CAP.EntityFrameworkCore.Test/DatabaseTestHost.cs
+49
-49
EFMessageStoreTest.cs
...etCore.CAP.EntityFrameworkCore.Test/EFMessageStoreTest.cs
+166
-173
20170708050416_InitDB.Designer.cs
...orkCore.Test/Migrations/20170708050416_InitDB.Designer.cs
+0
-69
20170708050416_InitDB.cs
...ityFrameworkCore.Test/Migrations/20170708050416_InitDB.cs
+0
-56
TestDbContextModelSnapshot.cs
...ameworkCore.Test/Migrations/TestDbContextModelSnapshot.cs
+0
-68
TestDbContext.cs
.../DotNetCore.CAP.EntityFrameworkCore.Test/TestDbContext.cs
+0
-13
TestHost.cs
test/DotNetCore.CAP.EntityFrameworkCore.Test/TestHost.cs
+1
-1
No files found.
test/DotNetCore.CAP.EntityFrameworkCore.Test/DatabaseTestHost.cs
View file @
14a3d4a5
...
...
@@ -5,58 +5,58 @@ using Microsoft.EntityFrameworkCore;
namespace
DotNetCore.CAP.EntityFrameworkCore.Test
{
public
abstract
class
DatabaseTestHost
:
TestHost
{
private
static
bool
_sqlObjectInstalled
;
//
public abstract class DatabaseTestHost : TestHost
//
{
//
private static bool _sqlObjectInstalled;
protected
override
void
PostBuildServices
()
{
base
.
PostBuildServices
();
InitializeDatabase
();
}
//
protected override void PostBuildServices()
//
{
//
base.PostBuildServices();
//
InitializeDatabase();
//
}
public
override
void
Dispose
()
{
DeleteAllData
();
base
.
Dispose
();
}
//
public override void Dispose()
//
{
//
DeleteAllData();
//
base.Dispose();
//
}
private
void
InitializeDatabase
()
{
if
(!
_sqlObjectInstalled
)
{
using
(
CreateScope
())
{
var
context
=
GetService
<
TestDbContext
>();
context
.
Database
.
EnsureDeleted
();
context
.
Database
.
Migrate
();
_sqlObjectInstalled
=
true
;
}
}
}
//
private void InitializeDatabase()
//
{
//
if (!_sqlObjectInstalled)
//
{
//
using (CreateScope())
//
{
//
var context = GetService<TestDbContext>();
//
context.Database.EnsureDeleted();
//
context.Database.Migrate();
//
_sqlObjectInstalled = true;
//
}
//
}
//
}
private
void
DeleteAllData
()
{
using
(
CreateScope
())
{
var
context
=
GetService
<
TestDbContext
>();
//
private void DeleteAllData()
//
{
//
using (CreateScope())
//
{
//
var context = GetService<TestDbContext>();
var
commands
=
new
[]
{
"DISABLE TRIGGER ALL ON ?"
,
"ALTER TABLE ? NOCHECK CONSTRAINT ALL"
,
"DELETE FROM ?"
,
"ALTER TABLE ? CHECK CONSTRAINT ALL"
,
"ENABLE TRIGGER ALL ON ?"
};
foreach
(
var
command
in
commands
)
{
context
.
Database
.
GetDbConnection
().
Execute
(
"sp_MSforeachtable"
,
new
{
command1
=
command
},
commandType
:
CommandType
.
StoredProcedure
);
}
}
}
}
//
var commands = new[]
//
{
//
"DISABLE TRIGGER ALL ON ?",
//
"ALTER TABLE ? NOCHECK CONSTRAINT ALL",
//
"DELETE FROM ?",
//
"ALTER TABLE ? CHECK CONSTRAINT ALL",
//
"ENABLE TRIGGER ALL ON ?"
//
};
//
foreach (var command in commands)
//
{
//
context.Database.GetDbConnection().Execute(
//
"sp_MSforeachtable",
//
new {command1 = command},
//
commandType: CommandType.StoredProcedure);
//
}
//
}
//
}
//
}
}
\ No newline at end of file
test/DotNetCore.CAP.EntityFrameworkCore.Test/EFMessageStoreTest.cs
View file @
14a3d4a5
This diff is collapsed.
Click to expand it.
test/DotNetCore.CAP.EntityFrameworkCore.Test/Migrations/20170708050416_InitDB.Designer.cs
deleted
100644 → 0
View file @
8294a586
using
System
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Metadata
;
using
Microsoft.EntityFrameworkCore.Migrations
;
using
DotNetCore.CAP.EntityFrameworkCore.Test
;
namespace
DotNetCore.CAP.EntityFrameworkCore.Test.Migrations
{
[
DbContext
(
typeof
(
TestDbContext
))]
[
Migration
(
"20170708050416_InitDB"
)]
partial
class
InitDB
{
protected
override
void
BuildTargetModel
(
ModelBuilder
modelBuilder
)
{
modelBuilder
.
HasAnnotation
(
"ProductVersion"
,
"1.1.2"
)
.
HasAnnotation
(
"SqlServer:ValueGenerationStrategy"
,
SqlServerValueGenerationStrategy
.
IdentityColumn
);
modelBuilder
.
Entity
(
"DotNetCore.CAP.Infrastructure.CapReceivedMessage"
,
b
=>
{
b
.
Property
<
string
>(
"Id"
)
.
ValueGeneratedOnAdd
();
b
.
Property
<
DateTime
>(
"Added"
);
b
.
Property
<
string
>(
"Content"
);
b
.
Property
<
string
>(
"Group"
);
b
.
Property
<
string
>(
"KeyName"
);
b
.
Property
<
DateTime
>(
"LastRun"
);
b
.
Property
<
int
>(
"Retries"
);
b
.
Property
<
string
>(
"StatusName"
)
.
HasMaxLength
(
50
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"CapReceivedMessages"
);
});
modelBuilder
.
Entity
(
"DotNetCore.CAP.Infrastructure.CapSentMessage"
,
b
=>
{
b
.
Property
<
string
>(
"Id"
)
.
ValueGeneratedOnAdd
();
b
.
Property
<
DateTime
>(
"Added"
);
b
.
Property
<
string
>(
"Content"
);
b
.
Property
<
string
>(
"KeyName"
);
b
.
Property
<
DateTime
>(
"LastRun"
);
b
.
Property
<
int
>(
"Retries"
);
b
.
Property
<
string
>(
"StatusName"
)
.
HasMaxLength
(
50
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"CapSentMessages"
);
});
}
}
}
test/DotNetCore.CAP.EntityFrameworkCore.Test/Migrations/20170708050416_InitDB.cs
deleted
100644 → 0
View file @
8294a586
using
System
;
using
System.Collections.Generic
;
using
Microsoft.EntityFrameworkCore.Migrations
;
namespace
DotNetCore.CAP.EntityFrameworkCore.Test.Migrations
{
public
partial
class
InitDB
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
CreateTable
(
name
:
"CapReceivedMessages"
,
columns
:
table
=>
new
{
Id
=
table
.
Column
<
string
>(
nullable
:
false
),
Added
=
table
.
Column
<
DateTime
>(
nullable
:
false
),
Content
=
table
.
Column
<
string
>(
nullable
:
true
),
Group
=
table
.
Column
<
string
>(
nullable
:
true
),
KeyName
=
table
.
Column
<
string
>(
nullable
:
true
),
LastRun
=
table
.
Column
<
DateTime
>(
nullable
:
false
),
Retries
=
table
.
Column
<
int
>(
nullable
:
false
),
StatusName
=
table
.
Column
<
string
>(
maxLength
:
50
,
nullable
:
true
)
},
constraints
:
table
=>
{
table
.
PrimaryKey
(
"PK_CapReceivedMessages"
,
x
=>
x
.
Id
);
});
migrationBuilder
.
CreateTable
(
name
:
"CapSentMessages"
,
columns
:
table
=>
new
{
Id
=
table
.
Column
<
string
>(
nullable
:
false
),
Added
=
table
.
Column
<
DateTime
>(
nullable
:
false
),
Content
=
table
.
Column
<
string
>(
nullable
:
true
),
KeyName
=
table
.
Column
<
string
>(
nullable
:
true
),
LastRun
=
table
.
Column
<
DateTime
>(
nullable
:
false
),
Retries
=
table
.
Column
<
int
>(
nullable
:
false
),
StatusName
=
table
.
Column
<
string
>(
maxLength
:
50
,
nullable
:
true
)
},
constraints
:
table
=>
{
table
.
PrimaryKey
(
"PK_CapSentMessages"
,
x
=>
x
.
Id
);
});
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropTable
(
name
:
"CapReceivedMessages"
);
migrationBuilder
.
DropTable
(
name
:
"CapSentMessages"
);
}
}
}
test/DotNetCore.CAP.EntityFrameworkCore.Test/Migrations/TestDbContextModelSnapshot.cs
deleted
100644 → 0
View file @
8294a586
using
System
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Metadata
;
using
Microsoft.EntityFrameworkCore.Migrations
;
using
DotNetCore.CAP.EntityFrameworkCore.Test
;
namespace
DotNetCore.CAP.EntityFrameworkCore.Test.Migrations
{
[
DbContext
(
typeof
(
TestDbContext
))]
partial
class
TestDbContextModelSnapshot
:
ModelSnapshot
{
protected
override
void
BuildModel
(
ModelBuilder
modelBuilder
)
{
modelBuilder
.
HasAnnotation
(
"ProductVersion"
,
"1.1.2"
)
.
HasAnnotation
(
"SqlServer:ValueGenerationStrategy"
,
SqlServerValueGenerationStrategy
.
IdentityColumn
);
modelBuilder
.
Entity
(
"DotNetCore.CAP.Infrastructure.CapReceivedMessage"
,
b
=>
{
b
.
Property
<
string
>(
"Id"
)
.
ValueGeneratedOnAdd
();
b
.
Property
<
DateTime
>(
"Added"
);
b
.
Property
<
string
>(
"Content"
);
b
.
Property
<
string
>(
"Group"
);
b
.
Property
<
string
>(
"KeyName"
);
b
.
Property
<
DateTime
>(
"LastRun"
);
b
.
Property
<
int
>(
"Retries"
);
b
.
Property
<
string
>(
"StatusName"
)
.
HasMaxLength
(
50
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"CapReceivedMessages"
);
});
modelBuilder
.
Entity
(
"DotNetCore.CAP.Infrastructure.CapSentMessage"
,
b
=>
{
b
.
Property
<
string
>(
"Id"
)
.
ValueGeneratedOnAdd
();
b
.
Property
<
DateTime
>(
"Added"
);
b
.
Property
<
string
>(
"Content"
);
b
.
Property
<
string
>(
"KeyName"
);
b
.
Property
<
DateTime
>(
"LastRun"
);
b
.
Property
<
int
>(
"Retries"
);
b
.
Property
<
string
>(
"StatusName"
)
.
HasMaxLength
(
50
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"CapSentMessages"
);
});
}
}
}
test/DotNetCore.CAP.EntityFrameworkCore.Test/TestDbContext.cs
deleted
100644 → 0
View file @
8294a586
using
Microsoft.EntityFrameworkCore
;
namespace
DotNetCore.CAP.EntityFrameworkCore.Test
{
public
class
TestDbContext
:
CapDbContext
{
protected
override
void
OnConfiguring
(
DbContextOptionsBuilder
optionsBuilder
)
{
var
connectionString
=
ConnectionUtil
.
GetConnectionString
();
optionsBuilder
.
UseSqlServer
(
connectionString
);
}
}
}
\ No newline at end of file
test/DotNetCore.CAP.EntityFrameworkCore.Test/TestHost.cs
View file @
14a3d4a5
...
...
@@ -29,7 +29,7 @@ namespace DotNetCore.CAP.EntityFrameworkCore.Test
var
connectionString
=
ConnectionUtil
.
GetConnectionString
();
//services.AddSingleton(new SqlServerOptions { ConnectionString = connectionString });
services
.
AddDbContext
<
TestDbContext
>(
options
=>
options
.
UseSqlServer
(
connectionString
));
//
services.AddDbContext<TestDbContext>(options => options.UseSqlServer(connectionString));
_services
=
services
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment