public void PushETest(RealStatePtr L, ETest val) { if (ETest_TypeID == -1) { bool is_first; ETest_TypeID = getTypeId(L, typeof(ETest), out is_first); if (ETest_EnumRef == -1) { Utils.LoadCSTable(L, typeof(ETest)); ETest_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX); } } if (LuaAPI.xlua_tryget_cachedud(L, (int)val, ETest_EnumRef) == 1) { return; } IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, ETest_TypeID); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail fail for ETest ,value=" + val); } LuaAPI.lua_getref(L, ETest_EnumRef); LuaAPI.lua_pushvalue(L, -2); LuaAPI.xlua_rawseti(L, -2, (int)val); LuaAPI.lua_pop(L, 1); }
public TestBase(string aInterface, Logger aLog, ETest aTest) { iInterface = aInterface; iLog = aLog; iTest = aTest; iKill = false; }
internal void OnEnd(ETest aTest) { if (evEnd != null) { evEnd(aTest); } }
//------------------------------- // Internal event handler methods //------------------------------- // C# events can only be published by the declaring class (and its subclasses). There // is no way for a contained instance (ie. the Logger) to publish these events itself. // Hence, to keep the Diagnostics class as the only public interface (rather than letting // the Logger become public), these methods are declared as internal, and the Logger // receives a reference to its containing Diagnostics instance at startup. This enables // it to call these events directly using its reference to the Diagnostics instance. internal void OnStart(ETest aTest) { if (evStart != null) { evStart(aTest); } }
public void Dump_Enum_ValuesGetReturned() { ETest t1 = ETest.Test1; ETest t2 = ETest.Test2; Assert.AreEqual("ETest.Test1", t1.ToDumpString()); Assert.AreEqual("ETest.Test2", t2.ToDumpString()); }
public LogMessage(EType aType, DateTime aTime, ETest aTest, string aSubtest, string aText) { iSubtest = aSubtest; iText = aText; iTime = aTime; iTest = aTest; iType = aType; }
public static Tuple <List <EQuestion>, List <EUserResult> > GetContentOfTest(ETest test) { List <EQuestion> questions = QuestionContext.GetByTest(test.Id); //get list answers List <EUserResult> answers = UserResultContext.GetByTest(test.Id); Tuple <List <EQuestion>, List <EUserResult> > list = Tuple.Create(questions, answers); return(list); }
public void StringVectorParseEnumTest() { var v = new StringVector("name/First/3"); v[0].Should().Be("name"); ETest e = v.Get <ETest>(1); v.Get <int>(2).Should().Be(3); }
//-------------------------------------------------------------- // Execute tests - specified individually, as a list or as 'all' //-------------------------------------------------------------- public void Run(ETest aTest, string aInterface, string aDeviceIp = null) { lock (iTestList) { iAllComplete = false; iTestList.Add(new TestInfo(aTest, aInterface, aDeviceIp)); iTestAvail.Release(); } }
public void StartTest(ETest aTest) { iTest = aTest; iSubtest = ""; lock (iMessageQ) { iMessageQ.Enqueue(new LogMessage(EType.eStart, DateTime.Now, iTest, iSubtest, "")); iMessageAvail.Release(); } }
public static void EnumTest() { /* * // < Enum Formatting > * * 1. Enum 값을 {#}으로 Formatting 할 경우 숫자가 아닌 문자열 값이 나온다. * 만일 숫자를 나오게 하려면 {#:D}를 사용한다. */ ETest e = ETest.EA; Array arrEnum = Enum.GetValues(e.GetType()); for (int i = 0; i < arrEnum.Length; i++) { Console.WriteLine("{0}, {0:D}", arrEnum.GetValue(i)); } }
public ActionResult ViewTest(int IdTest) { ETest test = TestContext.GetTestOfUser(IdTest); Tuple <List <EQuestion>, List <EUserResult> > data = BLTest.GetContentOfTest(test); List <Answer> listAnserIsTrue = AnswerContext.GetByTest(IdTest); List <EQuestion> eQuestions = data.Item1.OrderBy(i => i.Id).ToList(); List <EUserResult> userResults = data.Item2.OrderBy(i => i.IdQuestion).ToList(); for (int i = 0; i < data.Item2.Count; i++) { if (data.Item2[i].IdAnswer == listAnserIsTrue[i].Id) { data.Item2[i].isTrue = listAnserIsTrue[i].result; } } ViewData["ContentTest"] = Tuple.Create(eQuestions, userResults); ViewData["Test"] = test; return(View()); }
public static ETest CheckIsFinish(int Id) { ////if is Finish then count score ETest test = TestContext.GetTestOfUser(Id); if (test == null) { return(null); } if ((test.TimeStart + test.Time) < DateTime.Now) { TestContext.UpdateStatus(test.Id); } if (test.Status.ToUpper() == TAMS.Entity.baseEmun.StaticTest.Finish.ToString().ToUpper()) { TestContext.UpdateScore(test.Id); } return(TestContext.GetTestOfUser(test.Id)); }
public IActionResult Update([FromBody] ETest eTest) { try { using (var context = new Context(_dbContextOptions)) { context.ETests.Update(eTest); context.SaveChanges(); return(Ok(eTest)); } } catch (Exception e) { return(new ObjectResult(e) { StatusCode = (int)HttpStatusCode.InternalServerError }); } }
public void UpdateETest(RealStatePtr L, int index, ETest val) { if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != ETest_TypeID) { throw new Exception("invalid userdata for ETest"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail for ETest ,value=" + val); } } else { throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index)); } }
private bool TestString(string num, ETest testSign) { bool success; switch (testSign) { case ETest.Equal: success = num.Equals(_testValue); break; case ETest.NotEqual: success = !num.Equals(_testValue); break; default: success = false; break; } return(success); }
private bool TestBool(bool value, ETest testSign) { var success = true; switch (testSign) { case ETest.IsTrue: success = value; break; case ETest.IsFalse: success = !value; break; default: success = false; break; } return(success); }
//public static int Update_ModifyTimeTest(int IdTest) //{ // using(var context = MasterDBContext()) // { // return context.StoredProcedure("Test_UpdateModifyTime") // .Parameter("idTest", IdTest) // .Execute(); // } //} public static int SaveResultOfUser(List <UserResult> userResults, int IdTest) { int count = 0; using (var context = MasterDBContext()) { //getUserTest DateTime now = DateTime.Now; ETest test = GetTestOfUser(IdTest); if (test == null) { return(0); } TimeSpan?v = (TimeSpan)(now - test.TimeStart) - new TimeSpan(0, 0, 10); if (v > test.Time) { return(0); } if (test.Status != baseEmun.StaticTest.Doing.ToString()) { return(0); } foreach (UserResult item in userResults) { if (context.StoredProcedure("UserResult_Update") .Parameter("IdAnswer", item.IdAnswer) .Parameter("TextAnswer", item.TextAnswer) .Parameter("result", item.result) .Parameter("IdQuestion", item.IdQuestion) .Parameter("IdUserTest", test.Id) .Execute() > 0 ) { count++; } } } return(count); }
public IEnumerable getQuestions(int id) { ETest test = TestContext.GetTestOfUser(id); if (test == null) { return(null); } if (test.Status == Entity.baseEmun.StaticTest.Finish.ToString()) { return(null); } if (test.TimeStart != null) { DateTime timeNow = DateTime.Now; if (timeNow - test.TimeStart > test.Time) { return(null); } test.Time = test.Time - (TimeSpan)(timeNow - test.TimeStart); } return(JsonConvert.SerializeObject(BLTest.GetContentOfTest(test))); }
private bool TestFloat(float num, ETest testSign) { bool success; switch (testSign) { case ETest.Equal: success = Math.Abs(num - _testValue) < float.Epsilon; break; case ETest.MoreOrEqual: success = num >= _testValue; break; case ETest.LessOrEqual: success = num <= _testValue; break; case ETest.More: success = num > _testValue; break; case ETest.Less: success = num < _testValue; break; case ETest.NotEqual: success = Math.Abs(num - _testValue) > float.Epsilon; break; default: success = false; break; } return(success); }
private bool TestInt(int num, ETest testSign) { bool success; switch (testSign) { case ETest.Equal: success = num == _testValue; break; case ETest.MoreOrEqual: success = num >= _testValue; break; case ETest.LessOrEqual: success = num <= _testValue; break; case ETest.More: success = num > _testValue; break; case ETest.Less: success = num < _testValue; break; case ETest.NotEqual: success = num != _testValue; break; default: success = false; break; } return(success); }
public void Get(RealStatePtr L, int index, out ETest val) { LuaTypes type = LuaAPI.lua_type(L, index); if (type == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != ETest_TypeID) { throw new Exception("invalid userdata for ETest"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); int e; if (!CopyByValue.UnPack(buff, 0, out e)) { throw new Exception("unpack fail for ETest"); } val = (ETest)e; } else { val = (ETest)objectCasters.GetCaster(typeof(ETest))(L, index, null); } }
public ActionResult Test(int IdTest) { var user = (User)Session[Common.USER_SESSION]; ETest test = TestContext.SearchTestOfUser(IdTest, user.Id); if (test == null) { return(null); } // new Test if (test.Status.ToUpper() == "NotStart".ToUpper()) { int count = UserResultContext.AddTest(test.Id); if (count == 0) { return(RedirectToAction("Index")); } } else if (test.Status == Entity.baseEmun.StaticTest.Finish.ToString()) { return(RedirectToAction("Index")); } else if (test.TimeStart != null) { DateTime timeNow = DateTime.Now; if (timeNow - test.TimeStart > test.Time) { BLTest.CheckIsFinish(test.Id); return(RedirectToAction("Index")); } test.Time = test.Time - (TimeSpan)(timeNow - test.TimeStart); } ViewData["user"] = user; ViewData["Test"] = test; return(View()); }
public IntCondition(string conditionPath, int testValue, ETest test) { ConditionPath = conditionPath; _testValue = testValue; _test = test; }
public static void MethodD(ETest s) { Debug.Log("MethodD----" + s); }
public void LogEnum(ETest e) { Debug.Log(e.ToString()); }
// DHCP messages use port 68 on client and port 67 on server(s) public TestDhcp(string aInterface, Logger aLog, ETest aTest) : base(aInterface, aLog, aTest) { }
public static extern ETest enumTest(ETest a);
public StringCondition(string conditionPath, string testValue, ETest test) { ConditionPath = conditionPath; _testValue = testValue; _test = test; }
/// <summary> /// INI文件操作测试 /// </summary> private void IniFileOperateTest() { string iniPath = Path.Combine(Environment.CurrentDirectory, "TestConfig.ini"); PrintLogLn(MsgType.Info, $"INI文件路径: {iniPath}"); PrintLogLn(MsgType.Warn, "静态方法测试!"); string value0 = GetRandomString(10); PrintLogLn(MsgType.Info, $"生成随机字符串: {value0}"); IniOperate.CF_WriteConfig(iniPath, "TestSection", "StringKey", value0.ToString()); PrintLogLn(MsgType.Info, $"写入配置: TestSection->StringKey -> {value0}"); string result0 = IniOperate.CF_ReadConfig(iniPath, "TestSection", "StringKey"); PrintLogLn(MsgType.Info, $"读取配置: TestSection->StringKey -> {result0}"); if (value0 == result0) { PrintLogLn(MsgType.Success, $"写入值与读取值比对成功!"); } else { PrintLogLn(MsgType.Error, $"写入值与读取值比对失败!"); } double value1 = Math.Round(new Random().NextDouble(), 10); PrintLogLn(MsgType.Info, $"生成随机小数: {value1}"); IniOperate.CF_WriteConfig <double>(iniPath, "TestSection", "DoubleKey", value1); PrintLogLn(MsgType.Info, $"写入配置: TestSection->DoubleKey -> {value1}"); double result1 = IniOperate.CF_ReadConfig <double>(iniPath, "TestSection", "DoubleKey"); PrintLogLn(MsgType.Info, $"读取配置: TestSection->DoubleKey -> {result1}"); if (value1 == result1) { PrintLogLn(MsgType.Success, $"写入值与读取值比对成功!"); } else { PrintLogLn(MsgType.Error, $"写入值与读取值比对失败!"); } ETest value2 = (ETest) new Random().Next(1, 6); PrintLogLn(MsgType.Info, $"生成随机枚举值: {value2}"); IniOperate.CF_WriteConfig <ETest>(iniPath, "TestSection", "EnumKey", value2); PrintLogLn(MsgType.Info, $"写入配置: TestSection->EnumKey -> {value2}"); ETest result2 = IniOperate.CF_ReadConfig <ETest>(iniPath, "TestSection", "EnumKey"); PrintLogLn(MsgType.Info, $"读取配置: TestSection->EnumKey -> {result2}"); if (value2 == result2) { PrintLogLn(MsgType.Success, $"写入值与读取值比对成功!"); } else { PrintLogLn(MsgType.Error, $"写入值与读取值比对失败!"); } PrintLogLn(MsgType.Warn, "动态方法测试!"); IniOperate iniOperate = new IniOperate(iniPath); value0 = GetRandomString(10); PrintLogLn(MsgType.Info, $"生成随机字符串: {value0}"); iniOperate.CF_WriteConfig("TestSection", "StringKey", value0.ToString()); PrintLogLn(MsgType.Info, $"写入配置: TestSection->StringKey -> {value0}"); result0 = iniOperate.CF_ReadConfig("TestSection", "StringKey"); PrintLogLn(MsgType.Info, $"读取配置: TestSection->StringKey -> {result0}"); if (value0 == result0) { PrintLogLn(MsgType.Success, $"写入值与读取值比对成功!"); } else { PrintLogLn(MsgType.Error, $"写入值与读取值比对失败!"); } value1 = Math.Round(new Random().NextDouble(), 10); PrintLogLn(MsgType.Info, $"生成随机小数: {value1}"); iniOperate.CF_WriteConfig("TestSection", "DoubleKey", value1); PrintLogLn(MsgType.Info, $"写入配置: TestSection->DoubleKey -> {value1}"); result1 = iniOperate.CF_ReadConfig <double>("TestSection", "DoubleKey"); PrintLogLn(MsgType.Info, $"读取配置: TestSection->DoubleKey -> {result1}"); if (value1 == result1) { PrintLogLn(MsgType.Success, $"写入值与读取值比对成功!"); } else { PrintLogLn(MsgType.Error, $"写入值与读取值比对失败!"); } value2 = (ETest) new Random().Next(1, 6); PrintLogLn(MsgType.Info, $"生成随机枚举值: {value2}"); iniOperate.CF_WriteConfig("TestSection", "EnumKey", value2); PrintLogLn(MsgType.Info, $"写入配置: TestSection->EnumKey -> {value2}"); result2 = iniOperate.CF_ReadConfig <ETest>("TestSection", "EnumKey"); PrintLogLn(MsgType.Info, $"读取配置: TestSection->EnumKey -> {result2}"); if (value2 == result2) { PrintLogLn(MsgType.Success, $"写入值与读取值比对成功!"); } else { PrintLogLn(MsgType.Error, $"写入值与读取值比对失败!"); } List <string> sections = iniOperate.CF_ReadSections(); PrintLogLn(MsgType.Info, $"读取节点个数:{sections.Count}"); PrintLog(MsgType.Info, $"读取节点:"); foreach (string section in sections) { PrintMsg(MsgType.Info, $"{section};"); } PrintMsgLn(MsgType.Info, ""); List <string> keys = iniOperate.CF_ReadKeys("TestSection"); PrintLogLn(MsgType.Info, $"读取键名个数:{keys.Count}"); PrintLog(MsgType.Info, $"读取键名:"); foreach (string key in keys) { PrintMsg(MsgType.Info, $"{key};"); } PrintMsgLn(MsgType.Info, ""); File.Delete(iniPath); }
public FloatCondition(string conditionPath, float testValue, ETest test) { ConditionPath = conditionPath; _testValue = testValue; _test = test; }