diff --git a/test/DotNetCore.CAP.EntityFrameworkCore.Test/CapMessageStoreTest.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/CapMessageStoreTest.cs deleted file mode 100644 index efda431..0000000 --- a/test/DotNetCore.CAP.EntityFrameworkCore.Test/CapMessageStoreTest.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Xunit; - -namespace DotNetCore.CAP.EntityFrameworkCore.Test -{ - public class CapMessageStoreTest - { - } -} \ No newline at end of file diff --git a/test/DotNetCore.CAP.EntityFrameworkCore.Test/ConnectionUtil.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/ConnectionUtil.cs deleted file mode 100644 index 80fa0c8..0000000 --- a/test/DotNetCore.CAP.EntityFrameworkCore.Test/ConnectionUtil.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Data.SqlClient; - -namespace DotNetCore.CAP.EntityFrameworkCore.Test -{ - public static class ConnectionUtil - { - private const string DatabaseVariable = "Cap_SqlServer_DatabaseName"; - private const string ConnectionStringTemplateVariable = "Cap_SqlServer_ConnectionStringTemplate"; - - private const string MasterDatabaseName = "master"; - private const string DefaultDatabaseName = @"DotNetCore.CAP.EntityFrameworkCore.Test"; - - private const string DefaultConnectionStringTemplate = - @"Server=192.168.2.206;Initial Catalog={0};User Id=sa;Password=123123;MultipleActiveResultSets=True"; - - public static string GetDatabaseName() - { - return Environment.GetEnvironmentVariable(DatabaseVariable) ?? DefaultDatabaseName; - } - - public static string GetMasterConnectionString() - { - return string.Format(GetConnectionStringTemplate(), MasterDatabaseName); - } - - public static string GetConnectionString() - { - return string.Format(GetConnectionStringTemplate(), GetDatabaseName()); - } - - private static string GetConnectionStringTemplate() - { - return - Environment.GetEnvironmentVariable(ConnectionStringTemplateVariable) ?? - DefaultConnectionStringTemplate; - } - - public static SqlConnection CreateConnection(string connectionString = null) - { - connectionString = connectionString ?? GetConnectionString(); - var connection = new SqlConnection(connectionString); - connection.Open(); - return connection; - } - } -} \ No newline at end of file diff --git a/test/DotNetCore.CAP.EntityFrameworkCore.Test/DatabaseTestHost.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/DatabaseTestHost.cs deleted file mode 100644 index d6b21b6..0000000 --- a/test/DotNetCore.CAP.EntityFrameworkCore.Test/DatabaseTestHost.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.Data; -using System.Threading.Tasks; -using Dapper; -using Microsoft.EntityFrameworkCore; - -namespace DotNetCore.CAP.EntityFrameworkCore.Test -{ - //public abstract class DatabaseTestHost : TestHost - //{ - // private static bool _sqlObjectInstalled; - - // protected override void PostBuildServices() - // { - // base.PostBuildServices(); - // InitializeDatabase(); - // } - - // public override void Dispose() - // { - // DeleteAllData(); - // base.Dispose(); - // } - - // private void InitializeDatabase() - // { - // if (!_sqlObjectInstalled) - // { - // using (CreateScope()) - // { - // var context = GetService(); - // context.Database.EnsureDeleted(); - // context.Database.Migrate(); - // _sqlObjectInstalled = true; - // } - // } - // } - - // private void DeleteAllData() - // { - // using (CreateScope()) - // { - // var context = GetService(); - - // 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 diff --git a/test/DotNetCore.CAP.EntityFrameworkCore.Test/DotNetCore.CAP.EntityFrameworkCore.Test.csproj b/test/DotNetCore.CAP.EntityFrameworkCore.Test/DotNetCore.CAP.EntityFrameworkCore.Test.csproj deleted file mode 100644 index 17da1b0..0000000 --- a/test/DotNetCore.CAP.EntityFrameworkCore.Test/DotNetCore.CAP.EntityFrameworkCore.Test.csproj +++ /dev/null @@ -1,49 +0,0 @@ - - - - netcoreapp1.1 - true - DotNetCore.CAP.EntityFrameworkCore.Test - DotNetCore.CAP.EntityFrameworkCore.Test - true - $(PackageTargetFallback);dnxcore50;portable-net451+win8 - 1.1.1 - false - false - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/DotNetCore.CAP.EntityFrameworkCore.Test/EFMessageStoreTest.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/EFMessageStoreTest.cs deleted file mode 100644 index e59f393..0000000 --- a/test/DotNetCore.CAP.EntityFrameworkCore.Test/EFMessageStoreTest.cs +++ /dev/null @@ -1,168 +0,0 @@ -namespace DotNetCore.CAP.EntityFrameworkCore.Test -{ - //public class EFMessageStoreTest : DatabaseTestHost - //{ - // [Fact] - // public void CanCreateSentMessageUsingEF() - // { - // using (var db = CreateContext()) - // { - // var guid = Guid.NewGuid().ToString(); - // var message = new CapPublishedMessage - // { - // Id = guid, - // Content = "this is message body", - // StatusName = StatusName.Enqueued - // }; - // db.Attach(message).State = Microsoft.EntityFrameworkCore.EntityState.Added; - - // db.SaveChanges(); - - // Assert.True(db.CapSentMessages.Any(u => u.Id == guid)); - // Assert.NotNull(db.CapSentMessages.FirstOrDefault(u => u.StatusName == StatusName.Enqueued)); - // } - // } - - // [Fact] - // public void CanUpdateSentMessageUsingEF() - // { - // using (var db = CreateContext()) - // { - // var guid = Guid.NewGuid().ToString(); - // var message = new CapPublishedMessage - // { - // Id = guid, - // Content = "this is message body", - // StatusName = StatusName.Enqueued - // }; - // db.Attach(message).State = Microsoft.EntityFrameworkCore.EntityState.Added; - - // db.SaveChanges(); - - // var selectedMessage = db.CapSentMessages.FirstOrDefault(u => u.StatusName == StatusName.Enqueued); - // Assert.NotNull(selectedMessage); - - // selectedMessage.StatusName = StatusName.Succeeded; - // selectedMessage.Content = "Test"; - // db.SaveChanges(); - - // selectedMessage = db.CapSentMessages.FirstOrDefault(u => u.StatusName == StatusName.Succeeded); - // Assert.NotNull(selectedMessage); - // Assert.True(selectedMessage.Content == "Test"); - // } - // } - - // [Fact] - // public void CanRemoveSentMessageUsingEF() - // { - // using (var db = CreateContext()) - // { - // var guid = Guid.NewGuid().ToString(); - // var message = new CapPublishedMessage - // { - // Id = guid, - // Content = "this is message body", - // StatusName = StatusName.Enqueued - // }; - // db.Attach(message).State = Microsoft.EntityFrameworkCore.EntityState.Added; - - // db.SaveChanges(); - - // var selectedMessage = db.CapSentMessages.FirstOrDefault(u => u.StatusName == StatusName.Enqueued); - // Assert.NotNull(selectedMessage); - - // db.CapSentMessages.Remove(selectedMessage); - // db.SaveChanges(); - // selectedMessage = db.CapSentMessages.FirstOrDefault(u => u.StatusName == StatusName.Enqueued); - // Assert.Null(selectedMessage); - // } - // } - - // [Fact] - // public void CanCreateReceivedMessageUsingEF() - // { - // using (var db = CreateContext()) - // { - // var guid = Guid.NewGuid().ToString(); - // var message = new CapReceivedMessage - // { - // Id = guid, - // Content = "this is message body", - // StatusName = StatusName.Enqueued - // }; - // db.Attach(message).State = Microsoft.EntityFrameworkCore.EntityState.Added; - - // db.SaveChanges(); - - // Assert.True(db.CapReceivedMessages.Any(u => u.Id == guid)); - // Assert.NotNull(db.CapReceivedMessages.FirstOrDefault(u => u.StatusName == StatusName.Enqueued)); - // } - // } - - // [Fact] - // public void CanUpdateReceivedMessageUsingEF() - // { - // using (var db = CreateContext()) - // { - // var guid = Guid.NewGuid().ToString(); - // var message = new CapReceivedMessage - // { - // Id = guid, - // Content = "this is message body", - // StatusName = StatusName.Enqueued - // }; - // db.Attach(message).State = Microsoft.EntityFrameworkCore.EntityState.Added; - - // db.SaveChanges(); - - // var selectedMessage = db.CapReceivedMessages.FirstOrDefault(u => u.StatusName == StatusName.Enqueued); - // Assert.NotNull(selectedMessage); - - // selectedMessage.StatusName = StatusName.Succeeded; - // selectedMessage.Content = "Test"; - // db.SaveChanges(); - - // selectedMessage = db.CapReceivedMessages.FirstOrDefault(u => u.StatusName == StatusName.Succeeded); - // Assert.NotNull(selectedMessage); - // Assert.True(selectedMessage.Content == "Test"); - // } - // } - - // [Fact] - // public void CanRemoveReceivedMessageUsingEF() - // { - // using (var db = CreateContext()) - // { - // var guid = Guid.NewGuid().ToString(); - // var message = new CapReceivedMessage - // { - // Id = guid, - // Content = "this is message body", - // StatusName = StatusName.Enqueued - // }; - // db.Attach(message).State = Microsoft.EntityFrameworkCore.EntityState.Added; - - // db.SaveChanges(); - - // var selectedMessage = db.CapReceivedMessages.FirstOrDefault(u => u.StatusName == StatusName.Enqueued); - // Assert.NotNull(selectedMessage); - - // db.CapReceivedMessages.Remove(selectedMessage); - // db.SaveChanges(); - // selectedMessage = db.CapReceivedMessages.FirstOrDefault(u => u.StatusName == StatusName.Enqueued); - // Assert.Null(selectedMessage); - // } - // } - - // public TestDbContext CreateContext(bool delete = false) - // { - // var db = Provider.GetRequiredService(); - // if (delete) - // { - // db.Database.EnsureDeleted(); - // } - // db.Database.EnsureCreated(); - // return db; - // } - //} -} \ No newline at end of file diff --git a/test/DotNetCore.CAP.EntityFrameworkCore.Test/Properties/AssemblyInfo.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/Properties/AssemblyInfo.cs deleted file mode 100644 index a995715..0000000 --- a/test/DotNetCore.CAP.EntityFrameworkCore.Test/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("DotNetCore.CAP.EntityFrameworkCore.Test")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("7442c942-1ddc-40e4-8f1b-654e721eaa45")] \ No newline at end of file diff --git a/test/DotNetCore.CAP.EntityFrameworkCore.Test/TestHost.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/TestHost.cs deleted file mode 100644 index fbc1a94..0000000 --- a/test/DotNetCore.CAP.EntityFrameworkCore.Test/TestHost.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; - -namespace DotNetCore.CAP.EntityFrameworkCore.Test -{ - public abstract class TestHost : IDisposable - { - protected IServiceCollection _services; - private IServiceProvider _provider; - private IServiceProvider _scopedProvider; - - public TestHost() - { - CreateServiceCollection(); - PreBuildServices(); - BuildServices(); - PostBuildServices(); - } - - protected IServiceProvider Provider => _scopedProvider ?? _provider; - - private void CreateServiceCollection() - { - var services = new ServiceCollection(); - - services.AddOptions(); - services.AddLogging(); - - var connectionString = ConnectionUtil.GetConnectionString(); - //services.AddSingleton(new SqlServerOptions { ConnectionString = connectionString }); - //services.AddDbContext(options => options.UseSqlServer(connectionString)); - - _services = services; - } - - protected virtual void PreBuildServices() - { - } - - private void BuildServices() - { - _provider = _services.BuildServiceProvider(); - } - - protected virtual void PostBuildServices() - { - } - - public IDisposable CreateScope() - { - var scope = CreateScope(_provider); - var loc = scope.ServiceProvider; - _scopedProvider = loc; - return new DelegateDisposable(() => - { - if (_scopedProvider == loc) - { - _scopedProvider = null; - } - scope.Dispose(); - }); - } - - public IServiceScope CreateScope(IServiceProvider provider) - { - var scope = provider.GetService().CreateScope(); - return scope; - } - - public T GetService() => Provider.GetService(); - - public T Ensure(ref T service) - where T : class - => service ?? (service = GetService()); - - public virtual void Dispose() - { - (_provider as IDisposable)?.Dispose(); - } - - private class DelegateDisposable : IDisposable - { - private Action _dispose; - - public DelegateDisposable(Action dispose) - { - _dispose = dispose; - } - - public void Dispose() - { - _dispose(); - } - } - } -} \ No newline at end of file