/// <summary> /// Parses a substring from an engine file name, determines which property that substring represents, and assigns the corresponding enum /// </summary> /// <param name="engineObject">original engine object</param> /// <param name="engineSubstring">substring taken from an engine's filename e.g. arg, xl, or mk2</param> /// <returns>object with the new property added</returns> private EngineModel ParseEngineSubstring(EngineModel engineObject, string engineSubstring) { if (engineObject.Version == null && int.TryParse(engineSubstring, out int engineVersion)) { engineObject.Version = engineVersion; return engineObject; } if (engineObject.Faction == null && Enum.TryParse(engineSubstring, true, out FactionType engineFaction)) { engineObject.Faction = engineFaction; return engineObject; } if (engineObject.Size == null && Enum.TryParse(engineSubstring, true, out EngineSize engineSize)) { engineObject.Size = engineSize; return engineObject; } if (engineObject.Type == null && Enum.TryParse(engineSubstring, true, out EngineType engineType)) { engineObject.Type = engineType; return engineObject; } if (engineObject.Grade == null && Enum.TryParse(engineSubstring, true, out EngineGrade engineGrade)) { engineObject.Grade = engineGrade; return engineObject; } throw new Exception($"Failed to parse engine substring \"{engineSubstring}\""); }
public ActionResult Edit(int id) { EngineDataAccess engineDataAccess = new EngineDataAccess(); EngineModel model = engineDataAccess.Read(id); return(View(model)); }
/// <summary> /// 当网络返回,逻辑正确的时候 /// </summary> /// <param name="request">Request.</param> /// <param name="response">Response.</param> public override void Http_OnReceive_OK(BaseHttpRequest request, BaseResponse response) { base.Http_OnReceive_OK(request, response); HttpRequest req = request as HttpRequest; if (req != null) { //跳转场景,进入游戏 if (req.Type == RequestType.LOGIN_GAME) { AccountData ad = Native.mInstace.m_thridParty.GetAccountData(); EngineModel engineModel = Core.Data.getIModelNetwork <EngineModel>(); Server chosen = engineModel.ChosenServer; StateParam <GameState> state = new StateParam <GameState>(); LoginInfo info = new LoginInfo() { UniqueId = ad.uniqueId, curServer = chosen.name, LocalIOMgr = Core.DPM, logUtc = 123244123, }; state.obj = info; Core.GameFSM.handleStateChg(state, GameState.Logined); readComplete(); } } }
public void PopulateEngine_AllFieldsAndPropertiesPopulated() { string engineFilePath = $@"{Environment.CurrentDirectory}\DataAccess\TestData\engine_arg_m_allround_01_mk1_macro.xml"; EngineGetter engineGetter = new EngineGetter("some folder"); EngineModel engine = engineGetter.PopulateEngine(engineFilePath); Assert.Equal(FactionType.ARG, engine.Faction); Assert.Equal(EngineSize.m, engine.Size); Assert.Equal(EngineType.allround, engine.Type); Assert.Equal(1, engine.Version); Assert.Equal(EngineGrade.mk1, engine.Grade); Assert.Equal(7, engine.Properties.Boost.Duration); Assert.Equal(8, engine.Properties.Boost.Thrust); Assert.Equal(0.25, engine.Properties.Boost.Attack); Assert.Equal(1, engine.Properties.Boost.Release); Assert.Equal(1, engine.Properties.Travel.Charge); Assert.Equal(9, engine.Properties.Travel.Thrust); Assert.Equal(30, engine.Properties.Travel.Attack); Assert.Equal(20, engine.Properties.Travel.Release); Assert.Equal(1002, engine.Properties.Thrust.Forward); Assert.Equal(952, engine.Properties.Thrust.Reverse); Assert.Equal(1, engine.Properties.Hull.Integrated); Assert.Equal("M ARG Allround Engine Mk1", engine.Name); }
public ActionResult Index() { var engineModel = new EngineModel(); ConfigureViewModel(engineModel); return(View(engineModel)); }
/// <summary> /// Returns a name for an engine given its properties. Format will follow "XL ARG Combat Engine Mk2" /// </summary> /// <param name="engine">populated engine object used to derive the name</param> /// <returns>readable name for the engine object</returns> private string GenerateEngineName(EngineModel engine) { string engineName = $"{engine.Size.ToString().ToUpper()} {engine.Faction} {CultureInfo.CurrentCulture.TextInfo.ToTitleCase(engine.Type.ToString())} Engine {CultureInfo.CurrentCulture.TextInfo.ToTitleCase(engine.Grade.ToString())}"; if (engine.Version > 1) {engineName += $" {engine.Version.Value:00}";} return engineName; }
private void Awake() { // get the controller Engine = GetComponent <EngineModel>(); // DataLogger dataLogger = GetComponent <DataLogging>(); }
// Start is called before the first frame update private void Awake() { InterfaceObject = GameObject.Find("UI"); Engine = GetComponent <EngineModel>(); VehicleRigidBody = GetComponent <Rigidbody>(); Speedometer = InterfaceObject.GetComponent <SpeedometerScript>(); GraphObject = InterfaceObject.transform.Find("Canvas").gameObject.transform.Find("WindowGraph").GetComponent <WindowGraph>(); graph = InterfaceObject.GetComponent <Graph>(); GearField = InterfaceObject.transform.Find("Canvas").gameObject.transform.Find("Gear").GetComponent <Text>(); (s_SpeedType, m_SpeedCoefficient) = GenericFunctions.SpeedTypeConverter(m_SpeedType); }
public void Payment_Check_NullArguments() { // Arrange HomeController controller = new HomeController(); var engineModel = new EngineModel(); // Act ViewResult result = controller.Payment(engineModel) as ViewResult; // Assert Assert.IsNotNull(result); }
public void SetBrowserArgument(IWshShortcut shortcut, EngineModel model) { if (model == null) { shortcut.Arguments = ""; } else { shortcut.Arguments = model.LnkPage; } shortcut.Save(); }
void tryToLoginGame() { AccountData ad = Native.mInstace.m_thridParty.GetAccountData(); EngineModel engineModel = Core.Data.getIModelNetwork <EngineModel>(); Server chosen = engineModel.ChosenServer; HttpClient.BaseUrl = chosen.url; LoginParam loginParam = new LoginParam(ad, engineModel.token, chosen.sid.ToString()); SendHttpRequest(RequestType.LOGIN_GAME, loginParam); }
public async Task <ActionResult> Register(EngineModel model) { if (ModelState.IsValid) { EngineDataAccess engineDataAccess = new EngineDataAccess(); engineDataAccess.Create(model); return(RedirectToAction("List", "Engine")); } // If we got this far, something failed, redisplay form return(View(model)); }
public void CreateTest() { EngineModel engineModel = new EngineModel(); engineModel.Brand = "Brembo"; engineModel.Name = "Brembo"; engineModel.HorsePower = "400"; EngineDataAccess engineDataAccess = new EngineDataAccess(); engineDataAccess.Create(engineModel); Assert.IsNotNull(engineModel); }
public ActionResult Payment(EngineModel engineModel) { if (engineModel.RuleType is 0) { throw new ArgumentNullException(); } var ruleEngine = RuleEngineBuilder.GetRuleEngineFromType(engineModel.RuleType, engineModel.VideoName); var service = new RuleEngineService(ruleEngine); ViewBag.Message = service.StartProcess(); return(View()); }
public void GenerateEngineName_EngineHasVersion02() { EngineModel engine = new EngineModel { Faction = FactionType.BUC, Grade = EngineGrade.mk3, Name = "Some Engine Name", Size = EngineSize.xl, Type = EngineType.combat, Version = 2 }; EngineGetter engineGetter = new EngineGetter("some folder"); MethodInfo methodInfo = typeof(EngineGetter).GetMethod("GenerateEngineName", BindingFlags.NonPublic | BindingFlags.Instance); object[] parameters = { engine }; // Method under test string engineName = (string)methodInfo.Invoke(engineGetter, parameters); Assert.Equal("XL BUC Combat Engine Mk3 02", engineName); }
public void FormatMessage(EngineStatus status, EngineModel model, EngineVersion version) { if (status == EngineStatus.Accelerating) { response.EngineStatus = "Accelerating"; } else if (status == EngineStatus.Decelerating) { response.EngineStatus = "Decelerating"; } else if (status == EngineStatus.Reverse) { response.EngineStatus = "Reverse"; } else if (status == EngineStatus.Stopped) { response.EngineStatus = "Stopped"; } else if (status == EngineStatus.SpeedReached) { response.EngineStatus = "Speed Reached"; } else if (status == EngineStatus.Fault) { response.EngineStatus = "Fault"; } else if (status == EngineStatus.Running) { response.EngineStatus = "Running"; } if (model == EngineModel.VegaDrive) { response.EngineModel = "VegaDrive"; } if (version == EngineVersion.Version_1_0_E) { response.EngineVersion = "Version 10_E"; } else if (version == EngineVersion.Version_5_0_E) { response.EngineVersion = "Version 50_E"; } response.TimeStamp = DateTime.Now.ToString(); }
public void Classify(ForensicResult resource, int Kcount = 3) { init(); var source = new List <object>(); Dictionary <string, int> WordIndexMap = new Dictionary <string, int>(); List <string> WordList = new List <string>(); var WordWeight = new Dictionary <ForensicResultItem, IEnumerable <WordWeight> >(); foreach (var it in resource.GetItemWithMark(UserTextMark)) { var tTags = ExtractTagsWithWeight(it); if (tTags.Count() > 0) { WordWeight.Add(it, tTags); WordList.AddRange(tTags.Select(c => c.Word)); } } WordList = WordList.Distinct().ToList(); for (int i = 0; i < WordList.Count; ++i) { WordIndexMap.Add(WordList[i], i); } ; var tEngine = new EngineModel() { ClassCount = Kcount, Samples = WordWeight.Values.Select(c => { var tX = new double[WordList.Count]; foreach (var it in c) { tX[WordIndexMap[it.Word]] = it.Weight; } var t = new PointModel() { X = tX, }; return(t); }).ToList() }; tEngine.Run(); var res = tEngine.Classes; }
public void ParseEngineSubstring_VersionFound() { const string engineSubstring = "02"; EngineModel engine = new EngineModel(); EngineGetter engineGetter = new EngineGetter("some folder"); MethodInfo methodInfo = typeof(EngineGetter).GetMethod("ParseEngineSubstring", BindingFlags.NonPublic | BindingFlags.Instance); object[] parameters = { engine, engineSubstring }; // Method under test engine = (EngineModel)methodInfo.Invoke(engineGetter, parameters); Assert.Null(engine.Faction); Assert.Null(engine.Size); Assert.Null(engine.Type); Assert.Null(engine.Grade); Assert.Equal(2, engine.Version); }
public async Task <ActionResult <EngineModel> > PostEngineModel(EngineModel engineModel) { //var engine = new EngineModel //{ // AmendedOn=DateTime.Now, // CreatedOn=DateTime.Now, // FuelType=engineModel.FuelType, // ManufacturerId= engineModel.ManufacturerId, // Mileage=engineModel.Mileage, // Model=engineModel.Model, // Size=engineModel.Size, // Year=engineModel.Year //}; _context.engines.Add(engineModel); await _context.SaveChangesAsync(); return(CreatedAtAction("GetEngineModel", new { id = engineModel.Id }, engineModel)); }
public void DeleteTest() { EngineDataAccess engineDataAccess = new EngineDataAccess(); List <EngineModel> breakList = engineDataAccess.List(); // This method will be executed after the CreateTest, so items should exist if (breakList == null || breakList.Count == 0) { Assert.Fail(); } EngineModel model = breakList[0]; engineDataAccess.Delete(model.Id); model = engineDataAccess.Read(model.Id); Assert.IsNull(model); }
private EngineModel Engine; // Reference to car we are controlling private void StartSound() { // get the carcontroller ( this will not be null as we have require component) Engine = GetComponent <EngineModel>(); // setup the simple audio source m_HighAccel = SetUpEngineAudioSource(highAccelClip); // if we have four channel audio setup the four audio sources if (engineSoundStyle == EngineAudioOptions.FourChannel) { m_LowAccel = SetUpEngineAudioSource(lowAccelClip); m_LowDecel = SetUpEngineAudioSource(lowDecelClip); m_HighDecel = SetUpEngineAudioSource(highDecelClip); } // flag that we have started the sounds playing m_StartedSound = true; }
// If the Payment is for Video named as "Learning to Ski", add a free "First Aid" video to the packing slip and for rest // viedos show the General Packing slip message. public void Payment_For_Video_WithOut_ViedoName() { var controller = new HomeController(); var engineModel = new EngineModel(); engineModel.RuleType = (int)RuleTypeEnum.Video; var result = controller.Payment(engineModel) as ViewResult; Assert.IsNotNull(result); var actualResult = result.ViewBag.Message; StringBuilder expectedResult = new StringBuilder(); expectedResult.Append(RuleEngineMessages.GeneratePackingSlip); expectedResult.Append(RuleEngineMessages.AND); expectedResult.Append(RuleEngineMessages.GenerateCommisionToAgent); Assert.AreEqual(expectedResult.ToString(), actualResult); }
public void ParseEngineSubstring_VersionFound_AllOthersPreviouslyPopulated() { const string engineSubstring = "01"; EngineModel engine = new EngineModel { Faction = FactionType.BUC, Grade = EngineGrade.mk3, Name = "Some Engine Name", Size = EngineSize.xl, Type = EngineType.combat }; EngineGetter engineGetter = new EngineGetter("some folder"); MethodInfo methodInfo = typeof(EngineGetter).GetMethod("ParseEngineSubstring", BindingFlags.NonPublic | BindingFlags.Instance); object[] parameters = { engine, engineSubstring }; // Method under test engine = (EngineModel)methodInfo.Invoke(engineGetter, parameters); Assert.Equal(FactionType.BUC, engine.Faction); Assert.Equal(EngineSize.xl, engine.Size); Assert.Equal(EngineType.combat, engine.Type); Assert.Equal(EngineGrade.mk3, engine.Grade); Assert.Equal(1, engine.Version); }
/// <summary> /// Populates an engine object for a given engine file path /// </summary> /// <param name="engineFilePath"></param> /// <returns></returns> public EngineModel PopulateEngine(string engineFilePath) { string engineFileName = Path.GetFileName(engineFilePath); List<string> engineFileNameSubParts = engineFileName.Split('_').ToList(); engineFileNameSubParts.Remove("engine"); engineFileNameSubParts.Remove("macro.xml"); EngineModel engine = new EngineModel(); engineFileNameSubParts = RemoveMultitermEngineFileNameParameters(engineFileNameSubParts); engineFileNameSubParts.ForEach(x => engine = ParseEngineSubstring(engine, x)); XmlDocument engineXml = new XmlDocument(); engineXml.Load(engineFilePath); engine.Properties = ParseEnginePropertiesXml(engineXml); engine.Faction ??= FactionType.GEN; engine.Name = GenerateEngineName(engine).Trim(); return engine; }
// If the Payment is for Book, Create a duplicate packing slip for royalty department. // If the Payment is for physical product or book, generate a commission payment to agent. public void Payment_For_Book() { // Arrange HomeController controller = new HomeController(); var engineModel = new EngineModel(); engineModel.RuleType = (int)RuleTypeEnum.Book; // Act ViewResult result = controller.Payment(engineModel) as ViewResult; Assert.IsNotNull(result); var actualResult = result.ViewBag.Message; StringBuilder expectedResult = new StringBuilder(); expectedResult.Append(RuleEngineMessages.DuplicatePackingSlip); expectedResult.Append(RuleEngineMessages.AND); expectedResult.Append(RuleEngineMessages.GenerateCommisionToAgent); Assert.AreEqual(expectedResult.ToString(), actualResult); }
// If the Payment is an upgrade Membership, Apply upgrade. // If the payment is for Membership or upgrade membership, email the owner and inform them of the activation/upgrade. public void Payment_For_UpgradeMemberShip() { // Arrange HomeController controller = new HomeController(); var engineModel = new EngineModel(); engineModel.RuleType = (int)RuleTypeEnum.MembershipUpgrade; // Act ViewResult result = controller.Payment(engineModel) as ViewResult; Assert.IsNotNull(result); var actualResult = result.ViewBag.Message; StringBuilder expectedResult = new StringBuilder(); expectedResult.Append(RuleEngineMessages.UpgradeMemberShip); expectedResult.Append(RuleEngineMessages.AND); expectedResult.Append(RuleEngineMessages.SendEmailToOwner); Assert.AreEqual(expectedResult.ToString(), actualResult); }
public void ParseEngineSubstring_AllParsingFails() { const string engineSubstring = "invalid string to parse"; EngineModel engine = new EngineModel(); EngineGetter engineGetter = new EngineGetter("some folder"); MethodInfo methodInfo = typeof(EngineGetter).GetMethod("ParseEngineSubstring", BindingFlags.NonPublic | BindingFlags.Instance); object[] parameters = { engine, engineSubstring }; // Method under test void Action() => engine = (EngineModel)methodInfo.Invoke(engineGetter, parameters); Exception exception = Assert.Throws <TargetInvocationException>(Action); Assert.Equal($"Failed to parse engine substring \"{engineSubstring}\"", exception.InnerException.Message); Assert.Null(engine.Faction); Assert.Null(engine.Size); Assert.Null(engine.Type); Assert.Null(engine.Grade); Assert.Null(engine.Version); }
public void EditTest() { EngineDataAccess engineDataAccess = new EngineDataAccess(); List <EngineModel> breakList = engineDataAccess.List(); // This method will be executed after the CreateTest, so items should exist if (breakList == null || breakList.Count == 0) { Assert.Fail(); } string newName = "New Name"; EngineModel model = breakList[0]; model.Name = newName; engineDataAccess.Update(model); model = engineDataAccess.Read(model.Id); Assert.AreEqual(newName, model.Name); }
public async Task <IActionResult> PutEngineModel(Guid id, EngineModel engineModel) { if (id != engineModel.Id) { return(BadRequest()); } var engine = new EngineModel { Model = engineModel.Model, ManufacturerId = engineModel.ManufacturerId, Year = engineModel.Year, Size = engineModel.Size, AmendedOn = DateTime.UtcNow, CreatedOn = engineModel.CreatedOn, Id = engineModel.Id, Mileage = engineModel.Mileage }; _context.Entry(engine).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EngineModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <summary> /// Получить список всех двигателей /// </summary> /// <returns></returns> public List <IEngine> GetAllEngines() { List <IEngine> tempListEngine = new List <IEngine>(); string Querry = @"SELECT * from CarsEngine"; try { using (SQLiteConnection Connection = new SQLiteConnection(SqliteConnectionString.ConnectionString)) { Connection.Open(); using (var command = new SQLiteCommand(Querry, Connection)) { using (var reader = command.ExecuteReader()) { while (reader.Read()) { var engineModel = new EngineModel(); engineModel.ID = Convert.ToInt64(reader["ID"]); engineModel.Name = reader["name"].ToString(); engineModel.Power = Convert.ToDouble(reader["power"]); engineModel.Expenditure = Convert.ToDouble(reader["Expenditure"]); tempListEngine.Add(engineModel); } } } } } catch (Exception e) { throw e.FromMethod("Не удалось получить коллекцию двигателей из БД", MethodBase.GetCurrentMethod()); } return(tempListEngine); }
public LevelDisplayedAct(SongAct act, EngineModel model) { Act = act; Model = model; }