Procházet zdrojové kódy

rename namespace.

master
yangxiaodong před 7 roky
rodič
revize
c89c2917f9
7 změnil soubory, kde provedl 0 přidání a 452 odebrání
  1. +0
    -11
      test/DotNetCore.CAP.EntityFrameworkCore.Test/CapMessageStoreTest.cs
  2. +0
    -47
      test/DotNetCore.CAP.EntityFrameworkCore.Test/ConnectionUtil.cs
  3. +0
    -62
      test/DotNetCore.CAP.EntityFrameworkCore.Test/DatabaseTestHost.cs
  4. +0
    -49
      test/DotNetCore.CAP.EntityFrameworkCore.Test/DotNetCore.CAP.EntityFrameworkCore.Test.csproj
  5. +0
    -168
      test/DotNetCore.CAP.EntityFrameworkCore.Test/EFMessageStoreTest.cs
  6. +0
    -18
      test/DotNetCore.CAP.EntityFrameworkCore.Test/Properties/AssemblyInfo.cs
  7. +0
    -97
      test/DotNetCore.CAP.EntityFrameworkCore.Test/TestHost.cs

+ 0
- 11
test/DotNetCore.CAP.EntityFrameworkCore.Test/CapMessageStoreTest.cs Zobrazit soubor

@@ -1,11 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using Xunit;

namespace DotNetCore.CAP.EntityFrameworkCore.Test
{
public class CapMessageStoreTest
{
}
}

+ 0
- 47
test/DotNetCore.CAP.EntityFrameworkCore.Test/ConnectionUtil.cs Zobrazit soubor

@@ -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;
}
}
}

+ 0
- 62
test/DotNetCore.CAP.EntityFrameworkCore.Test/DatabaseTestHost.cs Zobrazit soubor

@@ -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<TestDbContext>();
// context.Database.EnsureDeleted();
// context.Database.Migrate();
// _sqlObjectInstalled = true;
// }
// }
// }

// 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);
// }
// }
// }
//}
}

+ 0
- 49
test/DotNetCore.CAP.EntityFrameworkCore.Test/DotNetCore.CAP.EntityFrameworkCore.Test.csproj Zobrazit soubor

@@ -1,49 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AssemblyName>DotNetCore.CAP.EntityFrameworkCore.Test</AssemblyName>
<PackageId>DotNetCore.CAP.EntityFrameworkCore.Test</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50;portable-net451+win8</PackageTargetFallback>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Shared\*.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\DotNetCore.CAP.SqlServer\DotNetCore.CAP.SqlServer.csproj" />
<ProjectReference Include="..\..\src\DotNetCore.CAP\DotNetCore.CAP.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Dapper" Version="1.50.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="1.1.1" />
<PackageReference Include="Moq" Version="4.7.63" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.2" />
<PackageReference Include="System.Data.SqlClient" Version="4.3.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.1" />
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>

</Project>

+ 0
- 168
test/DotNetCore.CAP.EntityFrameworkCore.Test/EFMessageStoreTest.cs Zobrazit soubor

@@ -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<TestDbContext>();
// if (delete)
// {
// db.Database.EnsureDeleted();
// }
// db.Database.EnsureCreated();
// return db;
// }
//}
}

+ 0
- 18
test/DotNetCore.CAP.EntityFrameworkCore.Test/Properties/AssemblyInfo.cs Zobrazit soubor

@@ -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")]

+ 0
- 97
test/DotNetCore.CAP.EntityFrameworkCore.Test/TestHost.cs Zobrazit soubor

@@ -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<TestDbContext>(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<IServiceScopeFactory>().CreateScope();
return scope;
}

public T GetService<T>() => Provider.GetService<T>();

public T Ensure<T>(ref T service)
where T : class
=> service ?? (service = GetService<T>());

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();
}
}
}
}

Načítá se…
Zrušit
Uložit