From 2b6c54c445795782b8b0c8ee491fcc9a0abd6176 Mon Sep 17 00:00:00 2001 From: yangxiaodong Date: Wed, 23 Aug 2017 18:11:06 +0800 Subject: [PATCH] clearup --- test/DotNetCore.CAP.MySql.Test/DatabaseTestHost.cs | 1 - .../MySqlStorageConnectionTest.cs | 4 +--- test/DotNetCore.CAP.MySql.Test/MySqlStorageTest.cs | 7 +++---- test/DotNetCore.CAP.MySql.Test/TestHost.cs | 1 - .../DatabaseTestHost.cs | 2 -- .../PostgreSqlStorageConnectionTest.cs | 4 +--- .../PostgreSqlStorageTest.cs | 8 ++++---- test/DotNetCore.CAP.PostgreSql.Test/TestHost.cs | 2 +- .../SqlServerStorageConnectionTest.cs | 4 +--- .../SqlServerStorageTest.cs | 10 +++++----- test/DotNetCore.CAP.SqlServer.Test/TestHost.cs | 2 +- test/DotNetCore.CAP.Test/CAP.BuilderTest.cs | 3 +-- .../ConsumerInvokerFactoryTest.cs | 6 +++--- .../ConsumerServiceSelectorTest.cs | 5 +---- test/DotNetCore.CAP.Test/ModelBinderFactoryTest.cs | 10 +++------- .../Processor/DefaultDispatcherTest.cs | 14 +++++--------- .../Processor/StateChangerTest.cs | 2 +- .../QueueExecutorFactoryTest.cs | 7 +------ test/DotNetCore.CAP.Test/Sample.cs | 11 +---------- test/DotNetCore.CAP.Test/SubscribeFinderTest.cs | 7 +------ 20 files changed, 34 insertions(+), 76 deletions(-) diff --git a/test/DotNetCore.CAP.MySql.Test/DatabaseTestHost.cs b/test/DotNetCore.CAP.MySql.Test/DatabaseTestHost.cs index bd858e5..1fac1b6 100644 --- a/test/DotNetCore.CAP.MySql.Test/DatabaseTestHost.cs +++ b/test/DotNetCore.CAP.MySql.Test/DatabaseTestHost.cs @@ -1,4 +1,3 @@ -using System.Data; using System.Threading; using Dapper; using Microsoft.EntityFrameworkCore; diff --git a/test/DotNetCore.CAP.MySql.Test/MySqlStorageConnectionTest.cs b/test/DotNetCore.CAP.MySql.Test/MySqlStorageConnectionTest.cs index b83588e..b3df31f 100644 --- a/test/DotNetCore.CAP.MySql.Test/MySqlStorageConnectionTest.cs +++ b/test/DotNetCore.CAP.MySql.Test/MySqlStorageConnectionTest.cs @@ -85,7 +85,6 @@ namespace DotNetCore.CAP.MySql.Test [Fact] public async Task GetReceivedMessageAsync_Test() { - var sql = $@" INSERT INTO `cap.received`(`Name`,`Group`,`Content`,`Retries`,`Added`,`ExpiresAt`,`StatusName`) VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);SELECT @@IDENTITY;"; @@ -129,6 +128,5 @@ namespace DotNetCore.CAP.MySql.Test Assert.Equal("MySqlStorageConnectionTest", message.Name); Assert.Equal("mygroup", message.Group); } - } -} +} \ No newline at end of file diff --git a/test/DotNetCore.CAP.MySql.Test/MySqlStorageTest.cs b/test/DotNetCore.CAP.MySql.Test/MySqlStorageTest.cs index 085246a..715cb5c 100644 --- a/test/DotNetCore.CAP.MySql.Test/MySqlStorageTest.cs +++ b/test/DotNetCore.CAP.MySql.Test/MySqlStorageTest.cs @@ -1,5 +1,5 @@ -using Xunit; -using Dapper; +using Dapper; +using Xunit; namespace DotNetCore.CAP.MySql.Test { @@ -9,7 +9,6 @@ namespace DotNetCore.CAP.MySql.Test private readonly string _dbName; private readonly string _masterDbConnectionString; - public MySqlStorageTest() { _dbName = ConnectionUtil.GetDatabaseName(); @@ -44,4 +43,4 @@ namespace DotNetCore.CAP.MySql.Test } } } -} +} \ No newline at end of file diff --git a/test/DotNetCore.CAP.MySql.Test/TestHost.cs b/test/DotNetCore.CAP.MySql.Test/TestHost.cs index c8290ad..06dcba9 100644 --- a/test/DotNetCore.CAP.MySql.Test/TestHost.cs +++ b/test/DotNetCore.CAP.MySql.Test/TestHost.cs @@ -1,5 +1,4 @@ using System; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; namespace DotNetCore.CAP.MySql.Test diff --git a/test/DotNetCore.CAP.PostgreSql.Test/DatabaseTestHost.cs b/test/DotNetCore.CAP.PostgreSql.Test/DatabaseTestHost.cs index 1d99d84..66ae8e1 100644 --- a/test/DotNetCore.CAP.PostgreSql.Test/DatabaseTestHost.cs +++ b/test/DotNetCore.CAP.PostgreSql.Test/DatabaseTestHost.cs @@ -1,5 +1,3 @@ -using System.Data; -using System.Data.SqlClient; using System.Threading; using Dapper; using Microsoft.EntityFrameworkCore; diff --git a/test/DotNetCore.CAP.PostgreSql.Test/PostgreSqlStorageConnectionTest.cs b/test/DotNetCore.CAP.PostgreSql.Test/PostgreSqlStorageConnectionTest.cs index 89c8a37..df68d0b 100644 --- a/test/DotNetCore.CAP.PostgreSql.Test/PostgreSqlStorageConnectionTest.cs +++ b/test/DotNetCore.CAP.PostgreSql.Test/PostgreSqlStorageConnectionTest.cs @@ -85,7 +85,6 @@ namespace DotNetCore.CAP.PostgreSql.Test [Fact] public async Task GetReceivedMessageAsync_Test() { - var sql = $@" INSERT INTO ""cap"".""received""(""Name"",""Group"",""Content"",""Retries"",""Added"",""ExpiresAt"",""StatusName"") VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName) RETURNING ""Id"";"; @@ -129,6 +128,5 @@ namespace DotNetCore.CAP.PostgreSql.Test Assert.Equal("PostgreSqlStorageConnectionTest", message.Name); Assert.Equal("mygroup", message.Group); } - } -} +} \ No newline at end of file diff --git a/test/DotNetCore.CAP.PostgreSql.Test/PostgreSqlStorageTest.cs b/test/DotNetCore.CAP.PostgreSql.Test/PostgreSqlStorageTest.cs index bb8a309..c4f5748 100644 --- a/test/DotNetCore.CAP.PostgreSql.Test/PostgreSqlStorageTest.cs +++ b/test/DotNetCore.CAP.PostgreSql.Test/PostgreSqlStorageTest.cs @@ -1,5 +1,5 @@ -using Xunit; -using Dapper; +using Dapper; +using Xunit; namespace DotNetCore.CAP.PostgreSql.Test { @@ -39,9 +39,9 @@ namespace DotNetCore.CAP.PostgreSql.Test using (var connection = ConnectionUtil.CreateConnection(_dbConnectionString)) { var sql = $"SELECT to_regclass('{tableName}') is not null;"; - var result = connection.QueryFirstOrDefault(sql); + var result = connection.QueryFirstOrDefault(sql); Assert.True(result); } } } -} +} \ No newline at end of file diff --git a/test/DotNetCore.CAP.PostgreSql.Test/TestHost.cs b/test/DotNetCore.CAP.PostgreSql.Test/TestHost.cs index 1da694b..4bff8cb 100644 --- a/test/DotNetCore.CAP.PostgreSql.Test/TestHost.cs +++ b/test/DotNetCore.CAP.PostgreSql.Test/TestHost.cs @@ -29,7 +29,7 @@ namespace DotNetCore.CAP.PostgreSql.Test _connectionString = ConnectionUtil.GetConnectionString(); services.AddSingleton(new PostgreSqlOptions { ConnectionString = _connectionString }); - services.AddSingleton(); + services.AddSingleton(); _services = services; } diff --git a/test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageConnectionTest.cs b/test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageConnectionTest.cs index bd0bab4..b081d1a 100644 --- a/test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageConnectionTest.cs +++ b/test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageConnectionTest.cs @@ -85,7 +85,6 @@ namespace DotNetCore.CAP.SqlServer.Test [Fact] public async Task GetReceivedMessageAsync_Test() { - var sql = $@" INSERT INTO [Cap].[Received]([Name],[Group],[Content],[Retries],[Added],[ExpiresAt],[StatusName]) OUTPUT INSERTED.Id VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);"; @@ -129,6 +128,5 @@ namespace DotNetCore.CAP.SqlServer.Test Assert.Equal("SqlServerStorageConnectionTest", message.Name); Assert.Equal("mygroup", message.Group); } - } -} +} \ No newline at end of file diff --git a/test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageTest.cs b/test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageTest.cs index 01e9aeb..af5fc41 100644 --- a/test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageTest.cs +++ b/test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageTest.cs @@ -1,5 +1,5 @@ -using Xunit; -using Dapper; +using Dapper; +using Xunit; namespace DotNetCore.CAP.SqlServer.Test { @@ -14,7 +14,7 @@ namespace DotNetCore.CAP.SqlServer.Test { var databaseName = ConnectionUtil.GetDatabaseName(); var sql = $@" -IF EXISTS (SELECT * FROM sysdatabases WHERE name = N'{databaseName}') +IF EXISTS (SELECT * FROM sysdatabases WHERE name = N'{databaseName}') SELECT 'True' ELSE SELECT 'False'"; @@ -39,6 +39,6 @@ SELECT 'False'"; var result = connection.QueryFirst(sql); Assert.True(result); } - } + } } -} +} \ No newline at end of file diff --git a/test/DotNetCore.CAP.SqlServer.Test/TestHost.cs b/test/DotNetCore.CAP.SqlServer.Test/TestHost.cs index 5922c17..d8618af 100644 --- a/test/DotNetCore.CAP.SqlServer.Test/TestHost.cs +++ b/test/DotNetCore.CAP.SqlServer.Test/TestHost.cs @@ -29,7 +29,7 @@ namespace DotNetCore.CAP.SqlServer.Test _connectionString = ConnectionUtil.GetConnectionString(); services.AddSingleton(new SqlServerOptions { ConnectionString = _connectionString }); - services.AddSingleton(); + services.AddSingleton(); _services = services; } diff --git a/test/DotNetCore.CAP.Test/CAP.BuilderTest.cs b/test/DotNetCore.CAP.Test/CAP.BuilderTest.cs index 69968de..a151d72 100644 --- a/test/DotNetCore.CAP.Test/CAP.BuilderTest.cs +++ b/test/DotNetCore.CAP.Test/CAP.BuilderTest.cs @@ -1,8 +1,8 @@ using System; +using System.Data; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Xunit; -using System.Data; namespace DotNetCore.CAP.Test { @@ -36,7 +36,6 @@ namespace DotNetCore.CAP.Test Assert.NotNull(markService); } - [Fact] public void CanOverridePublishService() { diff --git a/test/DotNetCore.CAP.Test/ConsumerInvokerFactoryTest.cs b/test/DotNetCore.CAP.Test/ConsumerInvokerFactoryTest.cs index 22388fd..bf070fe 100644 --- a/test/DotNetCore.CAP.Test/ConsumerInvokerFactoryTest.cs +++ b/test/DotNetCore.CAP.Test/ConsumerInvokerFactoryTest.cs @@ -11,7 +11,7 @@ namespace DotNetCore.CAP.Test { public class ConsumerInvokerFactoryTest { - IConsumerInvokerFactory consumerInvokerFactory; + private IConsumerInvokerFactory consumerInvokerFactory; public ConsumerInvokerFactoryTest() { @@ -67,6 +67,6 @@ namespace DotNetCore.CAP.Test { await invoker.InvokeAsync(); }); - } + } } -} +} \ No newline at end of file diff --git a/test/DotNetCore.CAP.Test/ConsumerServiceSelectorTest.cs b/test/DotNetCore.CAP.Test/ConsumerServiceSelectorTest.cs index 97dd29b..5ed56e1 100644 --- a/test/DotNetCore.CAP.Test/ConsumerServiceSelectorTest.cs +++ b/test/DotNetCore.CAP.Test/ConsumerServiceSelectorTest.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Threading.Tasks; using DotNetCore.CAP.Abstractions; -using DotNetCore.CAP.Internal; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -20,7 +17,7 @@ namespace DotNetCore.CAP.Test services.AddScoped(); services.AddScoped(); services.AddLogging(); - services.AddCap(x=> { }); + services.AddCap(x => { }); _provider = services.BuildServiceProvider(); } diff --git a/test/DotNetCore.CAP.Test/ModelBinderFactoryTest.cs b/test/DotNetCore.CAP.Test/ModelBinderFactoryTest.cs index 6f2a59d..946db42 100644 --- a/test/DotNetCore.CAP.Test/ModelBinderFactoryTest.cs +++ b/test/DotNetCore.CAP.Test/ModelBinderFactoryTest.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Linq; +using System.Linq; using System.Reflection; using DotNetCore.CAP.Internal; using Xunit; @@ -10,7 +7,7 @@ namespace DotNetCore.CAP.Test { public class ModelBinderFactoryTest { - IModelBinderFactory _factory; + private IModelBinderFactory _factory; public ModelBinderFactoryTest() { @@ -42,6 +39,5 @@ namespace DotNetCore.CAP.Test Assert.False(binder is SimpleTypeModelBinder); Assert.True(binder is ComplexTypeModelBinder); } - } -} +} \ No newline at end of file diff --git a/test/DotNetCore.CAP.Test/Processor/DefaultDispatcherTest.cs b/test/DotNetCore.CAP.Test/Processor/DefaultDispatcherTest.cs index 7ff1d19..8ccdbf0 100644 --- a/test/DotNetCore.CAP.Test/Processor/DefaultDispatcherTest.cs +++ b/test/DotNetCore.CAP.Test/Processor/DefaultDispatcherTest.cs @@ -1,12 +1,8 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Threading; using System.Threading.Tasks; -using DotNetCore.CAP.Infrastructure; using DotNetCore.CAP.Models; using DotNetCore.CAP.Processor; -using DotNetCore.CAP.Processor.States; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Moq; @@ -64,12 +60,12 @@ namespace DotNetCore.CAP.Test public async Task ProcessAsync() { // Arrange - var job = new CapPublishedMessage { - + var job = new CapPublishedMessage + { }; - var mockFetchedJob = Mock.Get(Mock.Of(fj => fj.MessageId == 42 && fj.MessageType == MessageType.Publish )); - + var mockFetchedJob = Mock.Get(Mock.Of(fj => fj.MessageId == 42 && fj.MessageType == MessageType.Publish)); + _mockStorageConnection .Setup(m => m.FetchNextMessageAsync()) .ReturnsAsync(mockFetchedJob.Object).Verifiable(); @@ -84,7 +80,7 @@ namespace DotNetCore.CAP.Test await fixture.ProcessAsync(_context); // Assert - _mockStorageConnection.VerifyAll(); + _mockStorageConnection.VerifyAll(); } private DefaultDispatcher Create() diff --git a/test/DotNetCore.CAP.Test/Processor/StateChangerTest.cs b/test/DotNetCore.CAP.Test/Processor/StateChangerTest.cs index b57692b..9ff5208 100644 --- a/test/DotNetCore.CAP.Test/Processor/StateChangerTest.cs +++ b/test/DotNetCore.CAP.Test/Processor/StateChangerTest.cs @@ -56,4 +56,4 @@ namespace DotNetCore.CAP.Test private StateChanger Create() => new StateChanger(); } -} +} \ No newline at end of file diff --git a/test/DotNetCore.CAP.Test/QueueExecutorFactoryTest.cs b/test/DotNetCore.CAP.Test/QueueExecutorFactoryTest.cs index a5fef69..7292832 100644 --- a/test/DotNetCore.CAP.Test/QueueExecutorFactoryTest.cs +++ b/test/DotNetCore.CAP.Test/QueueExecutorFactoryTest.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -41,8 +39,5 @@ namespace DotNetCore.CAP.Test var publishExecutor = queueExecutorFactory.GetInstance(Models.MessageType.Publish); Assert.Null(publishExecutor); } - - - } -} +} \ No newline at end of file diff --git a/test/DotNetCore.CAP.Test/Sample.cs b/test/DotNetCore.CAP.Test/Sample.cs index ff997fb..f043298 100644 --- a/test/DotNetCore.CAP.Test/Sample.cs +++ b/test/DotNetCore.CAP.Test/Sample.cs @@ -1,41 +1,32 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Threading.Tasks; namespace DotNetCore.CAP.Test { public class Sample { - public void DateTimeParam(DateTime dateTime) { - } public void StringParam(string @string) { - } public void GuidParam(Guid guid) { - } public void UriParam(Uri uri) { - } public void IntegerParam(int @int) { - } public void ComplexTypeParam(ComplexType complexType) { - } public void ThrowException() @@ -67,4 +58,4 @@ namespace DotNetCore.CAP.Test public string Name { get; set; } } -} +} \ No newline at end of file diff --git a/test/DotNetCore.CAP.Test/SubscribeFinderTest.cs b/test/DotNetCore.CAP.Test/SubscribeFinderTest.cs index 54e2052..684101a 100644 --- a/test/DotNetCore.CAP.Test/SubscribeFinderTest.cs +++ b/test/DotNetCore.CAP.Test/SubscribeFinderTest.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using DotNetCore.CAP.Abstractions; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -22,7 +20,6 @@ namespace DotNetCore.CAP.Test [Fact] public void CanFindControllers() { - } [Fact] @@ -36,7 +33,6 @@ namespace DotNetCore.CAP.Test public class HomeController { - } public interface ITestService { } @@ -46,7 +42,6 @@ namespace DotNetCore.CAP.Test [CapSubscribe("test")] public void Index() { - } } @@ -56,4 +51,4 @@ namespace DotNetCore.CAP.Test { } } -} +} \ No newline at end of file