Browse Source

clearup

master
yangxiaodong 7 years ago
parent
commit
2b6c54c445
20 changed files with 34 additions and 76 deletions
  1. +0
    -1
      test/DotNetCore.CAP.MySql.Test/DatabaseTestHost.cs
  2. +1
    -3
      test/DotNetCore.CAP.MySql.Test/MySqlStorageConnectionTest.cs
  3. +3
    -4
      test/DotNetCore.CAP.MySql.Test/MySqlStorageTest.cs
  4. +0
    -1
      test/DotNetCore.CAP.MySql.Test/TestHost.cs
  5. +0
    -2
      test/DotNetCore.CAP.PostgreSql.Test/DatabaseTestHost.cs
  6. +1
    -3
      test/DotNetCore.CAP.PostgreSql.Test/PostgreSqlStorageConnectionTest.cs
  7. +4
    -4
      test/DotNetCore.CAP.PostgreSql.Test/PostgreSqlStorageTest.cs
  8. +1
    -1
      test/DotNetCore.CAP.PostgreSql.Test/TestHost.cs
  9. +1
    -3
      test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageConnectionTest.cs
  10. +5
    -5
      test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageTest.cs
  11. +1
    -1
      test/DotNetCore.CAP.SqlServer.Test/TestHost.cs
  12. +1
    -2
      test/DotNetCore.CAP.Test/CAP.BuilderTest.cs
  13. +3
    -3
      test/DotNetCore.CAP.Test/ConsumerInvokerFactoryTest.cs
  14. +1
    -4
      test/DotNetCore.CAP.Test/ConsumerServiceSelectorTest.cs
  15. +3
    -7
      test/DotNetCore.CAP.Test/ModelBinderFactoryTest.cs
  16. +5
    -9
      test/DotNetCore.CAP.Test/Processor/DefaultDispatcherTest.cs
  17. +1
    -1
      test/DotNetCore.CAP.Test/Processor/StateChangerTest.cs
  18. +1
    -6
      test/DotNetCore.CAP.Test/QueueExecutorFactoryTest.cs
  19. +1
    -10
      test/DotNetCore.CAP.Test/Sample.cs
  20. +1
    -6
      test/DotNetCore.CAP.Test/SubscribeFinderTest.cs

+ 0
- 1
test/DotNetCore.CAP.MySql.Test/DatabaseTestHost.cs View File

@@ -1,4 +1,3 @@
using System.Data;
using System.Threading; using System.Threading;
using Dapper; using Dapper;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;


+ 1
- 3
test/DotNetCore.CAP.MySql.Test/MySqlStorageConnectionTest.cs View File

@@ -85,7 +85,6 @@ namespace DotNetCore.CAP.MySql.Test
[Fact] [Fact]
public async Task GetReceivedMessageAsync_Test() public async Task GetReceivedMessageAsync_Test()
{ {

var sql = $@" var sql = $@"
INSERT INTO `cap.received`(`Name`,`Group`,`Content`,`Retries`,`Added`,`ExpiresAt`,`StatusName`) INSERT INTO `cap.received`(`Name`,`Group`,`Content`,`Retries`,`Added`,`ExpiresAt`,`StatusName`)
VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);SELECT @@IDENTITY;"; 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("MySqlStorageConnectionTest", message.Name);
Assert.Equal("mygroup", message.Group); Assert.Equal("mygroup", message.Group);
} }

} }
}
}

+ 3
- 4
test/DotNetCore.CAP.MySql.Test/MySqlStorageTest.cs View File

@@ -1,5 +1,5 @@
using Xunit;
using Dapper;
using Dapper;
using Xunit;


namespace DotNetCore.CAP.MySql.Test namespace DotNetCore.CAP.MySql.Test
{ {
@@ -9,7 +9,6 @@ namespace DotNetCore.CAP.MySql.Test
private readonly string _dbName; private readonly string _dbName;
private readonly string _masterDbConnectionString; private readonly string _masterDbConnectionString;



public MySqlStorageTest() public MySqlStorageTest()
{ {
_dbName = ConnectionUtil.GetDatabaseName(); _dbName = ConnectionUtil.GetDatabaseName();
@@ -44,4 +43,4 @@ namespace DotNetCore.CAP.MySql.Test
} }
} }
} }
}
}

+ 0
- 1
test/DotNetCore.CAP.MySql.Test/TestHost.cs View File

@@ -1,5 +1,4 @@
using System; using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;


namespace DotNetCore.CAP.MySql.Test namespace DotNetCore.CAP.MySql.Test


+ 0
- 2
test/DotNetCore.CAP.PostgreSql.Test/DatabaseTestHost.cs View File

@@ -1,5 +1,3 @@
using System.Data;
using System.Data.SqlClient;
using System.Threading; using System.Threading;
using Dapper; using Dapper;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;


+ 1
- 3
test/DotNetCore.CAP.PostgreSql.Test/PostgreSqlStorageConnectionTest.cs View File

@@ -85,7 +85,6 @@ namespace DotNetCore.CAP.PostgreSql.Test
[Fact] [Fact]
public async Task GetReceivedMessageAsync_Test() public async Task GetReceivedMessageAsync_Test()
{ {

var sql = $@" var sql = $@"
INSERT INTO ""cap"".""received""(""Name"",""Group"",""Content"",""Retries"",""Added"",""ExpiresAt"",""StatusName"") INSERT INTO ""cap"".""received""(""Name"",""Group"",""Content"",""Retries"",""Added"",""ExpiresAt"",""StatusName"")
VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName) RETURNING ""Id"";"; 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("PostgreSqlStorageConnectionTest", message.Name);
Assert.Equal("mygroup", message.Group); Assert.Equal("mygroup", message.Group);
} }

} }
}
}

+ 4
- 4
test/DotNetCore.CAP.PostgreSql.Test/PostgreSqlStorageTest.cs View File

@@ -1,5 +1,5 @@
using Xunit;
using Dapper;
using Dapper;
using Xunit;


namespace DotNetCore.CAP.PostgreSql.Test namespace DotNetCore.CAP.PostgreSql.Test
{ {
@@ -39,9 +39,9 @@ namespace DotNetCore.CAP.PostgreSql.Test
using (var connection = ConnectionUtil.CreateConnection(_dbConnectionString)) using (var connection = ConnectionUtil.CreateConnection(_dbConnectionString))
{ {
var sql = $"SELECT to_regclass('{tableName}') is not null;"; var sql = $"SELECT to_regclass('{tableName}') is not null;";
var result = connection.QueryFirstOrDefault<bool>(sql);
var result = connection.QueryFirstOrDefault<bool>(sql);
Assert.True(result); Assert.True(result);
} }
} }
} }
}
}

+ 1
- 1
test/DotNetCore.CAP.PostgreSql.Test/TestHost.cs View File

@@ -29,7 +29,7 @@ namespace DotNetCore.CAP.PostgreSql.Test


_connectionString = ConnectionUtil.GetConnectionString(); _connectionString = ConnectionUtil.GetConnectionString();
services.AddSingleton(new PostgreSqlOptions { ConnectionString = _connectionString }); services.AddSingleton(new PostgreSqlOptions { ConnectionString = _connectionString });
services.AddSingleton<PostgreSqlStorage>();
services.AddSingleton<PostgreSqlStorage>();


_services = services; _services = services;
} }


+ 1
- 3
test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageConnectionTest.cs View File

@@ -85,7 +85,6 @@ namespace DotNetCore.CAP.SqlServer.Test
[Fact] [Fact]
public async Task GetReceivedMessageAsync_Test() public async Task GetReceivedMessageAsync_Test()
{ {

var sql = $@" var sql = $@"
INSERT INTO [Cap].[Received]([Name],[Group],[Content],[Retries],[Added],[ExpiresAt],[StatusName]) OUTPUT INSERTED.Id INSERT INTO [Cap].[Received]([Name],[Group],[Content],[Retries],[Added],[ExpiresAt],[StatusName]) OUTPUT INSERTED.Id
VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);"; VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);";
@@ -129,6 +128,5 @@ namespace DotNetCore.CAP.SqlServer.Test
Assert.Equal("SqlServerStorageConnectionTest", message.Name); Assert.Equal("SqlServerStorageConnectionTest", message.Name);
Assert.Equal("mygroup", message.Group); Assert.Equal("mygroup", message.Group);
} }

} }
}
}

+ 5
- 5
test/DotNetCore.CAP.SqlServer.Test/SqlServerStorageTest.cs View File

@@ -1,5 +1,5 @@
using Xunit;
using Dapper;
using Dapper;
using Xunit;


namespace DotNetCore.CAP.SqlServer.Test namespace DotNetCore.CAP.SqlServer.Test
{ {
@@ -14,7 +14,7 @@ namespace DotNetCore.CAP.SqlServer.Test
{ {
var databaseName = ConnectionUtil.GetDatabaseName(); var databaseName = ConnectionUtil.GetDatabaseName();
var sql = $@" var sql = $@"
IF EXISTS (SELECT * FROM sysdatabases WHERE name = N'{databaseName}')
IF EXISTS (SELECT * FROM sysdatabases WHERE name = N'{databaseName}')
SELECT 'True' SELECT 'True'
ELSE ELSE
SELECT 'False'"; SELECT 'False'";
@@ -39,6 +39,6 @@ SELECT 'False'";
var result = connection.QueryFirst<bool>(sql); var result = connection.QueryFirst<bool>(sql);
Assert.True(result); Assert.True(result);
} }
}
}
} }
}
}

+ 1
- 1
test/DotNetCore.CAP.SqlServer.Test/TestHost.cs View File

@@ -29,7 +29,7 @@ namespace DotNetCore.CAP.SqlServer.Test


_connectionString = ConnectionUtil.GetConnectionString(); _connectionString = ConnectionUtil.GetConnectionString();
services.AddSingleton(new SqlServerOptions { ConnectionString = _connectionString }); services.AddSingleton(new SqlServerOptions { ConnectionString = _connectionString });
services.AddSingleton<SqlServerStorage>();
services.AddSingleton<SqlServerStorage>();


_services = services; _services = services;
} }


+ 1
- 2
test/DotNetCore.CAP.Test/CAP.BuilderTest.cs View File

@@ -1,8 +1,8 @@
using System; using System;
using System.Data;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Xunit; using Xunit;
using System.Data;


namespace DotNetCore.CAP.Test namespace DotNetCore.CAP.Test
{ {
@@ -36,7 +36,6 @@ namespace DotNetCore.CAP.Test
Assert.NotNull(markService); Assert.NotNull(markService);
} }



[Fact] [Fact]
public void CanOverridePublishService() public void CanOverridePublishService()
{ {


+ 3
- 3
test/DotNetCore.CAP.Test/ConsumerInvokerFactoryTest.cs View File

@@ -11,7 +11,7 @@ namespace DotNetCore.CAP.Test
{ {
public class ConsumerInvokerFactoryTest public class ConsumerInvokerFactoryTest
{ {
IConsumerInvokerFactory consumerInvokerFactory;
private IConsumerInvokerFactory consumerInvokerFactory;


public ConsumerInvokerFactoryTest() public ConsumerInvokerFactoryTest()
{ {
@@ -67,6 +67,6 @@ namespace DotNetCore.CAP.Test
{ {
await invoker.InvokeAsync(); await invoker.InvokeAsync();
}); });
}
}
} }
}
}

+ 1
- 4
test/DotNetCore.CAP.Test/ConsumerServiceSelectorTest.cs View File

@@ -1,9 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using DotNetCore.CAP.Abstractions; using DotNetCore.CAP.Abstractions;
using DotNetCore.CAP.Internal;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Xunit; using Xunit;


@@ -20,7 +17,7 @@ namespace DotNetCore.CAP.Test
services.AddScoped<IFooTest, CandidatesFooTest>(); services.AddScoped<IFooTest, CandidatesFooTest>();
services.AddScoped<IBarTest, CandidatesBarTest>(); services.AddScoped<IBarTest, CandidatesBarTest>();
services.AddLogging(); services.AddLogging();
services.AddCap(x=> { });
services.AddCap(x => { });
_provider = services.BuildServiceProvider(); _provider = services.BuildServiceProvider();
} }




+ 3
- 7
test/DotNetCore.CAP.Test/ModelBinderFactoryTest.cs View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Linq;
using System.Reflection; using System.Reflection;
using DotNetCore.CAP.Internal; using DotNetCore.CAP.Internal;
using Xunit; using Xunit;
@@ -10,7 +7,7 @@ namespace DotNetCore.CAP.Test
{ {
public class ModelBinderFactoryTest public class ModelBinderFactoryTest
{ {
IModelBinderFactory _factory;
private IModelBinderFactory _factory;


public ModelBinderFactoryTest() public ModelBinderFactoryTest()
{ {
@@ -42,6 +39,5 @@ namespace DotNetCore.CAP.Test
Assert.False(binder is SimpleTypeModelBinder); Assert.False(binder is SimpleTypeModelBinder);
Assert.True(binder is ComplexTypeModelBinder); Assert.True(binder is ComplexTypeModelBinder);
} }

} }
}
}

+ 5
- 9
test/DotNetCore.CAP.Test/Processor/DefaultDispatcherTest.cs View File

@@ -1,12 +1,8 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Models; using DotNetCore.CAP.Models;
using DotNetCore.CAP.Processor; using DotNetCore.CAP.Processor;
using DotNetCore.CAP.Processor.States;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Moq; using Moq;
@@ -64,12 +60,12 @@ namespace DotNetCore.CAP.Test
public async Task ProcessAsync() public async Task ProcessAsync()
{ {
// Arrange // Arrange
var job = new CapPublishedMessage {
var job = new CapPublishedMessage
{
}; };


var mockFetchedJob = Mock.Get(Mock.Of<IFetchedMessage>(fj => fj.MessageId == 42 && fj.MessageType == MessageType.Publish ));
var mockFetchedJob = Mock.Get(Mock.Of<IFetchedMessage>(fj => fj.MessageId == 42 && fj.MessageType == MessageType.Publish));
_mockStorageConnection _mockStorageConnection
.Setup(m => m.FetchNextMessageAsync()) .Setup(m => m.FetchNextMessageAsync())
.ReturnsAsync(mockFetchedJob.Object).Verifiable(); .ReturnsAsync(mockFetchedJob.Object).Verifiable();
@@ -84,7 +80,7 @@ namespace DotNetCore.CAP.Test
await fixture.ProcessAsync(_context); await fixture.ProcessAsync(_context);


// Assert // Assert
_mockStorageConnection.VerifyAll();
_mockStorageConnection.VerifyAll();
} }


private DefaultDispatcher Create() private DefaultDispatcher Create()


+ 1
- 1
test/DotNetCore.CAP.Test/Processor/StateChangerTest.cs View File

@@ -56,4 +56,4 @@ namespace DotNetCore.CAP.Test


private StateChanger Create() => new StateChanger(); private StateChanger Create() => new StateChanger();
} }
}
}

+ 1
- 6
test/DotNetCore.CAP.Test/QueueExecutorFactoryTest.cs View File

@@ -1,6 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Xunit; using Xunit;


@@ -41,8 +39,5 @@ namespace DotNetCore.CAP.Test
var publishExecutor = queueExecutorFactory.GetInstance(Models.MessageType.Publish); var publishExecutor = queueExecutorFactory.GetInstance(Models.MessageType.Publish);
Assert.Null(publishExecutor); Assert.Null(publishExecutor);
} }



} }
}
}

+ 1
- 10
test/DotNetCore.CAP.Test/Sample.cs View File

@@ -1,41 +1,32 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;


namespace DotNetCore.CAP.Test namespace DotNetCore.CAP.Test
{ {
public class Sample public class Sample
{ {

public void DateTimeParam(DateTime dateTime) public void DateTimeParam(DateTime dateTime)
{ {

} }


public void StringParam(string @string) public void StringParam(string @string)
{ {

} }


public void GuidParam(Guid guid) public void GuidParam(Guid guid)
{ {

} }


public void UriParam(Uri uri) public void UriParam(Uri uri)
{ {

} }


public void IntegerParam(int @int) public void IntegerParam(int @int)
{ {

} }


public void ComplexTypeParam(ComplexType complexType) public void ComplexTypeParam(ComplexType complexType)
{ {

} }


public void ThrowException() public void ThrowException()
@@ -67,4 +58,4 @@ namespace DotNetCore.CAP.Test


public string Name { get; set; } public string Name { get; set; }
} }
}
}

+ 1
- 6
test/DotNetCore.CAP.Test/SubscribeFinderTest.cs View File

@@ -1,6 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using DotNetCore.CAP.Abstractions; using DotNetCore.CAP.Abstractions;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Xunit; using Xunit;
@@ -22,7 +20,6 @@ namespace DotNetCore.CAP.Test
[Fact] [Fact]
public void CanFindControllers() public void CanFindControllers()
{ {
} }


[Fact] [Fact]
@@ -36,7 +33,6 @@ namespace DotNetCore.CAP.Test


public class HomeController public class HomeController
{ {

} }


public interface ITestService { } public interface ITestService { }
@@ -46,7 +42,6 @@ namespace DotNetCore.CAP.Test
[CapSubscribe("test")] [CapSubscribe("test")]
public void Index() public void Index()
{ {

} }
} }


@@ -56,4 +51,4 @@ namespace DotNetCore.CAP.Test
{ {
} }
} }
}
}

Loading…
Cancel
Save