You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
3.6 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using AUCMA.STORE.Entity.DAO;
using AUCMA.STORE.SqlSugar.serviceImpl;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Threading;
namespace AUCMA.STORE.UnitTest
{
/// <summary>
/// UnitTest3 的摘要说明
/// </summary>
[TestClass]
public class UnitTest3
{
public UnitTest3()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
private TestContext testContextInstance;
/// <summary>
///获取或设置测试上下文,该上下文提供
///有关当前测试运行及其功能的信息。
///</summary>
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#region 附加测试特性
//
// 编写测试时,可以使用以下附加特性:
//
// 在运行类中的第一个测试之前使用 ClassInitialize 运行代码
// [ClassInitialize()]
// public static void MyClassInitialize(TestContext testContext) { }
//
// 在类中的所有测试都已运行之后使用 ClassCleanup 运行代码
// [ClassCleanup()]
// public static void MyClassCleanup() { }
//
// 在运行每个测试之前,使用 TestInitialize 来运行代码
// [TestInitialize()]
// public void MyTestInitialize() { }
//
// 在每个测试运行完之后,使用 TestCleanup 来运行代码
// [TestCleanup()]
// public void MyTestCleanup() { }
//
#endregion
[TestMethod]
public void TestMethod1()
{
//
// TODO: 在此处添加测试逻辑
//
//test();
string info = DateTime.Now.ToString("yyMMdd").Trim() + "0001";
int result = ParseToInt(info);
}
public async void test()
{
/*BasePlcInfo basePlcInfo = new BasePlcInfo();
basePlcInfo.objid = System.Guid.NewGuid().ToString();
basePlcInfo.plcCode = 1001;
basePlcInfo.plcName = "1#RGV";
basePlcInfo.plcAddress = "10.11.41.30:102";
basePlcInfo.storeCode = "A";
basePlcInfo.deleteFlag = Entity.Enums.DeleteFlag.No;
await new BaseServices<BasePlcInfo>().Add(basePlcInfo);*/
//var info = await new BaseServices<BasePlcInfo>().Query();
List<BaseDeviceInfo> baseDeviceInfos = new List<BaseDeviceInfo>();
Expression<Func<BasePlcInfo, bool>> exp = s1 => true;
List<BasePlcInfo> basePlcInfos = new BaseServices<BasePlcInfo>().QueryList(exp);
/*basePlcInfos.ForEach(x => {
baseDeviceInfos.Add(new BaseDeviceInfo(Convert.ToUInt16(x.plcCode), x.plcAddress, x.plcType,x.plcArea));
});*/
}
/// <summary>
/// 将字符串强制转换成int转换失败则返回0
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public int ParseToInt(string str)
{
int returnInt = 0;
if (str == null || str.Trim().Length < 1)
{
return returnInt;
}
if (int.TryParse(str, out returnInt))
{
return returnInt;
}
else
{
return 0;
}
}
}
}