|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- //using System;
- //using System.Threading.Tasks;
- //using DotNetCore.CAP.Infrastructure;
- //using DotNetCore.CAP.Models;
- //using Microsoft.AspNetCore.Http;
- //using Microsoft.Extensions.DependencyInjection;
- //using Microsoft.Extensions.Logging;
- //using Xunit;
-
- //namespace DotNetCore.CAP.Test
- //{
- // public abstract class MessageManagerTestBase
- // {
- // private const string NullValue = "(null)";
-
- // protected virtual bool ShouldSkipDbTests()
- // {
- // return false;
- // }
-
- // protected virtual void SetupMessageServices(IServiceCollection services, object context = null)
- // {
- // services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
- // services.AddCap();
- // AddMessageStore(services, context);
-
- // services.AddSingleton<ILogger<ICapMessageStore>>(new TestLogger<ICapMessageStore>());
- // }
-
- // protected virtual ICapMessageStore CreateManager(object context = null, IServiceCollection services = null,
- // Action<IServiceCollection> configureServices = null)
- // {
- // if (services == null)
- // {
- // services = new ServiceCollection();
- // }
- // if (context == null)
- // {
- // context = CreateTestContext();
- // }
- // SetupMessageServices(services, context);
-
- // configureServices?.Invoke(services);
-
- // return services.BuildServiceProvider().GetService<ICapMessageStore>();
- // }
-
- // protected abstract object CreateTestContext();
-
- // protected abstract CapSentMessage CreateTestSentMessage(string content = "");
- // protected abstract CapReceivedMessage CreateTestReceivedMessage(string content = "");
-
- // protected abstract void AddMessageStore(IServiceCollection services, object context = null);
-
- // [Fact]
- // public async Task CanDeleteSentMessage()
- // {
- // if (ShouldSkipDbTests())
- // {
- // return;
- // }
-
- // var manager = CreateManager();
- // var message = CreateTestSentMessage();
- // var operateResult = await manager.StoreSentMessageAsync(message);
- // Assert.NotNull(operateResult);
- // Assert.True(operateResult.Succeeded);
-
- // // operateResult = await manager.RemoveSentMessageAsync(message);
- // // Assert.NotNull(operateResult);
- // // Assert.True(operateResult.Succeeded);
- // }
-
- // //[Fact]
- // //public async Task CanUpdateReceivedMessage()
- // //{
- // // if (ShouldSkipDbTests())
- // // {
- // // return;
- // // }
-
- // // var manager = CreateManager();
- // // var message = CreateTestReceivedMessage();
- // // // var operateResult = await manager.StoreReceivedMessageAsync(message);
- // // // Assert.NotNull(operateResult);
- // // // Assert.True(operateResult.Succeeded);
-
- // // // message.StatusName = StatusName.Processing;
- // // // operateResult = await manager.UpdateReceivedMessageAsync(message);
- // // // Assert.NotNull(operateResult);
- // // // Assert.True(operateResult.Succeeded);
- // //}
-
- // [Fact]
- // public async Task CanGetNextSendMessage()
- // {
- // if (ShouldSkipDbTests())
- // {
- // return;
- // }
- // var manager = CreateManager();
- // var message = CreateTestSentMessage();
-
- // var operateResult = await manager.StoreSentMessageAsync(message);
- // Assert.NotNull(operateResult);
- // Assert.True(operateResult.Succeeded);
-
- // // var storeMessage = await manager.GetNextSentMessageToBeEnqueuedAsync();
-
- // // Assert.Equal(message, storeMessage);
- // }
- // }
- //}
|