wsd_djy/WebSiteCode/Cmdjy/CmdjyTests/HisInterfaceTests.cs

75 lines
3.3 KiB
C#
Raw Normal View History

using Microsoft.VisualStudio.TestTools.UnitTesting;
using Cmdjy.ws;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CmdjyTests.HisServices;
using Newtonsoft.Json;
using Cmdjy.Dal;
using System.Reflection;
namespace Cmdjy.ws.Tests
{
[TestClass()]
public class HisInterfaceTests
{
[TestMethod()]
public void PostPrescriptionInfoTest() {
var service = new HisInterfaceSoapClient();
var newpres = new CmdjyTests.HisServices.HisPrescriptionInfo {
Area = "Area",Bed = "Bed",CardNo = "CardNo",CompanyCode = "CompanyCode",
CompanyName = "CompanyName",DepName = "DepName",Diagnosis = "Diagnosis",District = "District",
DoctorName = "DoctorName",DrugCount = "DrugCount",HosName = "HosName",HosNo = "HosNo",InvoiceNo = "InvoiceNo",
OpDatatime = "OpDatatime",OpType = "OpType",OpUser = "OpUser",PatientAge = "PatientAge",
PatientBrithday = "PatientBrithday",PatientMobile = "PatientMobile",PatientName = "PatientName",
PatientNo = "PatientNo",PatientPhone = "PatientPhone",PatientSex = "PatientSex",PostAddress = "PostAddress",
PostDatatime = "PostDatatime",PrescriptionDatatime = "PrescriptionDatatime",PrescriptionNo = "PrescriptionNo",
RawRecordId = "RawRecordId",Remark = "Remark",Sffyxh = "Sffyxh",Sfxh = 1,TakeBack = "TakeBack",
Type = CmdjyTests.HisServices.PrescriptionType.Order,Usage = "Usage",UseCount = "UseCount",Zlh = "Zlh",
};
var result = service.PostPrescriptionInfo(newpres);
Console.WriteLine($"result:{result}");
var rObj = JsonConvert.DeserializeObject<HisPrescriptionResult>(result);
Assert.IsTrue(rObj.Code == ResultCode.Success);
using(var db = new DjyDbContext()) {
var qu = db.PrescriptionInfos.Where(m => m.Id.ToString() == rObj.PrescriptionId).ToList();
Assert.IsTrue(qu.Any());
Assert.IsTrue(qu.Count == 1);
var fst = qu.First();
foreach(PropertyInfo p in newpres.GetType().GetProperties()) {
var dbp = fst.GetType().GetProperties().Where(m => m.Name == p.Name);
Assert.IsTrue(dbp.Any());
var lv = p.GetValue(newpres);
var dbv = fst.GetType().GetProperties().First(m => m.Name == p.Name).GetValue(fst);
Assert.IsTrue(dbv.Equals(lv));
}
foreach(var item in qu) {
db.Entry(item).State = System.Data.Entity.EntityState.Deleted;
db.SaveChanges();
}
}
}
}
/// <summary>
/// HIS发送处方信息应答
/// </summary>
public class HisPrescriptionResult
{
/// <summary>
/// 返回结果代码
/// </summary>
public ResultCode Code { get; set; }
/// <summary>
/// 返回信息。如执行错误包含错误信息
/// </summary>
public string Msg { get; set; }
/// <summary>
/// 处方流水号,执行错误为空
/// </summary>
public string PrescriptionId { get; set; }
}
}