Browse Source

update samples.

undefined
Savorboard 7 years ago
parent
commit
fec299fb95
7 changed files with 17 additions and 16 deletions
  1. +1
    -1
      appveyor.yml
  2. +1
    -1
      samples/Sample.RabbitMQ.MySql/AppDbContext.cs
  3. +2
    -2
      src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs
  4. +1
    -1
      test/DotNetCore.CAP.MySql.Test/ConnectionUtil.cs
  5. +6
    -5
      test/DotNetCore.CAP.MySql.Test/MySqlStorageConnectionTest.cs
  6. +4
    -4
      test/DotNetCore.CAP.Test/ConsumerInvokerFactoryTest.cs
  7. +2
    -2
      test/DotNetCore.CAP.Test/OperateResultTest.cs

+ 1
- 1
appveyor.yml View File

@@ -4,7 +4,7 @@ environment:
BUILDING_ON_PLATFORM: win
BuildEnvironment: appveyor
Cap_SqlServer_ConnectionStringTemplate: Server=(local)\SQL2014;Database={0};User ID=sa;Password=Password12!
Cap_MySql_ConnectionStringTemplate: Server=localhost;Database={0};Uid=root;Pwd=Password12!
Cap_MySql_ConnectionStringTemplate: Server=localhost;Database={0};Uid=root;Pwd=Password12!;Allow User Variables=True
Cap_PostgreSql_ConnectionStringTemplate: Server=localhost;Database={0};UserId=postgres;Password=Password12!
services:
- mssql2014


+ 1
- 1
samples/Sample.RabbitMQ.MySql/AppDbContext.cs View File

@@ -10,7 +10,7 @@ namespace Sample.RabbitMQ.MySql
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseMySql("Server=localhost;Database=Sample.RabbitMQ.MySql;UserId=root;Password=123123;");
optionsBuilder.UseMySql("Server=localhost;Database=Sample.RabbitMQ.MySql;UserId=root;Password=123123;Allow User Variables=True");
//optionsBuilder.UseMySql("Server=192.168.2.206;Database=Sample.RabbitMQ.MySql;UserId=root;Password=123123;");
}
}


+ 2
- 2
src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs View File

@@ -41,8 +41,8 @@ namespace DotNetCore.CAP.MySql
public Task<IFetchedMessage> FetchNextMessageAsync()
{
var sql = $@"
SELECT @MessageId:=`MessageId` as MessageId, @MessageType:=`MessageType` as MessageType FROM `{_prefix}.queue` LIMIT 1;
DELETE FROM `{_prefix}.queue` where `MessageId` = @MessageId AND `MessageType`=@MessageType;";
SELECT @MId:=`MessageId` as MessageId, @MType:=`MessageType` as MessageType FROM `{_prefix}.queue` LIMIT 1;
DELETE FROM `{_prefix}.queue` where `MessageId` = @MId AND `MessageType`=@MType;";

return FetchNextMessageCoreAsync(sql);
}


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

@@ -12,7 +12,7 @@ namespace DotNetCore.CAP.MySql.Test
private const string DefaultDatabaseName = @"DotNetCore.CAP.MySql.Test";

private const string DefaultConnectionStringTemplate =
@"Server=localhost;Database={0};Uid=root;Pwd=123123;";
@"Server=localhost;Database={0};Uid=root;Pwd=123123;Allow User Variables=True;";

public static string GetDatabaseName()
{


+ 6
- 5
test/DotNetCore.CAP.MySql.Test/MySqlStorageConnectionTest.cs View File

@@ -52,11 +52,12 @@ namespace DotNetCore.CAP.MySql.Test
{
connection.Execute(sql, queue);
}
var fetchedMessage = await _storage.FetchNextMessageAsync();
fetchedMessage.Dispose();
Assert.NotNull(fetchedMessage);
Assert.Equal(MessageType.Publish, fetchedMessage.MessageType);
Assert.Equal(3333, fetchedMessage.MessageId);
using (var fetchedMessage = await _storage.FetchNextMessageAsync())
{
Assert.NotNull(fetchedMessage);
Assert.Equal(MessageType.Publish, fetchedMessage.MessageType);
Assert.Equal(3333, fetchedMessage.MessageId);
}
}

[Fact]


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

@@ -48,7 +48,7 @@ namespace DotNetCore.CAP.Test
[Theory]
[InlineData(nameof(Sample.ThrowException))]
[InlineData(nameof(Sample.AsyncMethod))]
public async void InvokeMethodTest(string methodName)
public void InvokeMethodTest(string methodName)
{
var methodInfo = typeof(Sample).GetRuntimeMethods()
.Single(x => x.Name == methodName);
@@ -64,10 +64,10 @@ namespace DotNetCore.CAP.Test

var invoker = consumerInvokerFactory.CreateInvoker(context);

await Assert.ThrowsAsync(typeof(Exception), async () =>
Assert.Throws<Exception>(() =>
{
await invoker.InvokeAsync();
});
invoker.InvokeAsync().GetAwaiter().GetResult();
});
}
}
}

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

@@ -11,7 +11,7 @@ namespace DotNetCore.CAP.Test
var result = new OperateResult();

Assert.False(result.Succeeded);
Assert.Equal(0, result.Errors.Count());
Assert.Empty(result.Errors);
}

[Fact]
@@ -20,7 +20,7 @@ namespace DotNetCore.CAP.Test
var result = OperateResult.Failed();

Assert.False(result.Succeeded);
Assert.Equal(0, result.Errors.Count());
Assert.Empty(result.Errors);
}
}
}

Loading…
Cancel
Save