|
@@ -1,4 +1,8 @@
|
|
|
-using Hotline.EventBus;
|
|
|
+using Hotline.Api.Controllers;
|
|
|
+using Hotline.Application.Tests.Mock;
|
|
|
+using Hotline.EventBus;
|
|
|
+using Hotline.Identity.Accounts;
|
|
|
+using Hotline.Identity.Roles;
|
|
|
using Hotline.Orders;
|
|
|
using Hotline.Push.FWMessage;
|
|
|
using Hotline.Push.Notifies;
|
|
@@ -7,29 +11,34 @@ using Hotline.Share.Dtos.Push;
|
|
|
using Hotline.Share.Enums.Order;
|
|
|
using Hotline.Share.Enums.Push;
|
|
|
using Hotline.Share.Tools;
|
|
|
+using Hotline.Users;
|
|
|
using Mapster;
|
|
|
+using Microsoft.Extensions.DependencyInjection;
|
|
|
using Shouldly;
|
|
|
using XF.Domain.Repository;
|
|
|
|
|
|
namespace Hotline.Application.Tests.Domain;
|
|
|
-public class OrderVisitDomainServiceTest
|
|
|
+public class OrderVisitDomainServiceTest : TestBase
|
|
|
{
|
|
|
private readonly IOrderVisitDomainService _orderVisitDomainService;
|
|
|
private readonly IOrderVisitRepository _orderVisitRepository;
|
|
|
private readonly IRepository<OrderVisitDetail> _orderVisitDetailRepository;
|
|
|
private readonly Publisher _publisher;
|
|
|
private readonly IOrderRepository _orderRepository;
|
|
|
+ private readonly OrderServiceMock _orderServiceMock;
|
|
|
|
|
|
-
|
|
|
- public OrderVisitDomainServiceTest(IOrderVisitDomainService orderVisitDomainService, IOrderVisitRepository orderVisitRepository, IRepository<OrderVisitDetail> orderVisitDetailRepository, Publisher publisher, IOrderRepository orderRepository)
|
|
|
+ public OrderVisitDomainServiceTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IOrderVisitDomainService orderVisitDomainService, IOrderVisitRepository orderVisitRepository, IRepository<OrderVisitDetail> orderVisitDetailRepository, Publisher publisher, IOrderRepository orderRepository, OrderServiceMock orderServiceMock) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository)
|
|
|
{
|
|
|
_orderVisitDomainService = orderVisitDomainService;
|
|
|
_orderVisitRepository = orderVisitRepository;
|
|
|
_orderVisitDetailRepository = orderVisitDetailRepository;
|
|
|
_publisher = publisher;
|
|
|
_orderRepository = orderRepository;
|
|
|
+ _orderServiceMock = orderServiceMock;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
//[Fact]
|
|
|
public async Task UpdateSmsReplyDefault_Test()
|
|
|
{
|
|
@@ -95,6 +104,17 @@ public class OrderVisitDomainServiceTest
|
|
|
[InlineData("非常不满意", "SMSUnsatisfied", "2", "不满意")]
|
|
|
public async Task UpdateSmsReply_Test(string content, string visitState, string orgResuktKey, string orgResuktValue)
|
|
|
{
|
|
|
+ SetZuoXi();
|
|
|
+ var order = _orderServiceMock.CreateOrder()
|
|
|
+ .办理到一级部门()
|
|
|
+ .办理到二级部门(Set一级部门)
|
|
|
+ .办理一级部门汇总(Set二级部门)
|
|
|
+ .办理到归档(Set一级部门)
|
|
|
+ .发布工单(SetZuoXi)
|
|
|
+ .发送回访短信(SetZuoXi)
|
|
|
+ .GetCreateResult();
|
|
|
+ order.Id.ShouldNotBeNull();
|
|
|
+
|
|
|
var visit = await _orderVisitRepository.Queryable()
|
|
|
.Includes(m => m.Order)
|
|
|
.Where(m => m.VisitState == EVisitState.SMSVisiting)
|
|
@@ -108,21 +128,38 @@ public class OrderVisitDomainServiceTest
|
|
|
await _orderVisitDomainService.UpdateSmsReplyAsync(message);
|
|
|
visit = _orderVisitRepository.Get(visit.Id);
|
|
|
visit.VisitState.ShouldBe(visitState.ToEnum<EVisitState>());
|
|
|
+ visit.NowEvaluate.ShouldNotBeNull();
|
|
|
visit.NowEvaluate.Key.ShouldBe(orgResuktKey);
|
|
|
visit.NowEvaluate.Value.ShouldBe(orgResuktValue);
|
|
|
-
|
|
|
+ var orderEntity = await _orderRepository.GetAsync(order.Id);
|
|
|
+ orderEntity.ShouldNotBeNull();
|
|
|
if (content == "4" || content == "5" || content == "不满意" || content == "非常不满意")
|
|
|
+ {
|
|
|
visit.VisitType.ShouldBeNull();
|
|
|
+ orderEntity.Status.ShouldNotBe(EOrderStatus.Visited);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ orderEntity.Status.ShouldBe(EOrderStatus.Visited);
|
|
|
+ }
|
|
|
|
|
|
await _orderVisitDetailRepository.Queryable()
|
|
|
.Where(m => m.VisitId == visit.Id && m.VisitTarget == EVisitTarget.Org)
|
|
|
.FirstAsync()
|
|
|
- .Then(async org =>
|
|
|
+ .Then(org =>
|
|
|
{
|
|
|
+ org.OrgProcessingResults.ShouldNotBeNull();
|
|
|
org.OrgProcessingResults.Key.ShouldBe(orgResuktKey);
|
|
|
org.OrgProcessingResults.Value.ShouldBe(orgResuktValue);
|
|
|
+
|
|
|
+ orderEntity.OrgProcessingResults.ShouldNotBeNull();
|
|
|
+ orderEntity.OrgProcessingResults.Key.ShouldBe(orgResuktKey);
|
|
|
+ orderEntity.OrgProcessingResults.Value.ShouldBe(orgResuktValue);
|
|
|
+
|
|
|
+ org.OrgHandledAttitude.ShouldNotBeNull();
|
|
|
org.OrgHandledAttitude.Key.ShouldBe(orgResuktKey);
|
|
|
org.OrgHandledAttitude.Value.ShouldBe(orgResuktValue);
|
|
|
+ return Task.CompletedTask;
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -132,7 +169,7 @@ public class OrderVisitDomainServiceTest
|
|
|
[InlineData("3", "一般", "Visited", "Normal", "Normal", "满意|4")]
|
|
|
[InlineData("4", "不满意", "SMSUnsatisfied", "NoSatisfied", "NoSatisfied", "不满意|2")]
|
|
|
[InlineData("5", "非常不满意", "SMSUnsatisfied", "NoSatisfied", "VeryNoSatisfied", "不满意|2")]
|
|
|
- [InlineData("默认满意", "默认满意", "Visited", "DefaultSatisfied", "DefaultSatisfied", "满意|4")]
|
|
|
+ [InlineData("默认满意", "默认满意", "Visited", "DefaultSatisfied", "DefaultSatisfied", "默认满意|0")]
|
|
|
public void GetVisitEvaluateByReplyTxt_Test(string replyTxt, string assertReplyTxt, string visitState, string seatEvaluate, string voiceEvaluate, string kv)
|
|
|
{
|
|
|
var replyString = _orderVisitDomainService.GetVisitEvaluateByReplyTxt<string>(replyTxt);
|