/// <summary> /// 绑定(重量、水分)检测项目 /// </summary> private void BindCboxTestItems() { List <TestItems> list = TestItemsDAL.GetListWhereTestItemName("", "启动"); TestItems ti = new TestItems(); ti.TestItems_ID = 0; ti.TestItems_NAME = "全部"; TestItems t = list[0]; list[0] = ti; list.Add(t); List <TestItems> list2 = list; cboxTestItems2.DataSource = list; cboxTestItems2.DisplayMember = "TestItems_NAME"; cboxTestItems2.ValueMember = "TestItems_ID"; if (cboxTestItems2.DataSource != null) { cboxTestItems2.SelectedValue = 0; } cboxTestItems.DataSource = list2;// TestItemsDAL.GetListWhereTestItemName("", "启动"); cboxTestItems.DisplayMember = "TestItems_NAME"; cboxTestItems.ValueMember = "TestItems_ID"; if (cboxTestItems.DataSource != null) { // cboxTestItems.SelectedIndex =-1; cboxTestItems.SelectedValue = 0; } }
public void Apply_useHeathPoitionOnWrongCharacter() { var healthPotion = new TestItems().HealthPotion; var wolf = new TestCharacters().Wolf; Assert.Throws <WrongRequirementException>(() => healthPotion.Apply(wolf)); }
public void Eqip_InvalidItem() { var human = new TestCharacters().InjuerdHuman; var amulet = new TestItems().ElvishAmulet; Assert.Throws <WrongRequirementException>(() => human.Eqip(amulet)); }
private void DeleteItemCommandProc(Object selectedItems) { ItemType selectedItem = (ItemType)((ObservableCollection <object>)selectedItems).FirstOrDefault(); if (selectedItem == null) { return; } bool result = true; WindowsUI.RunWindowDialog(() => { if (MessageBox.Show( String.Format(StringsFunctions.ResourceString("resDeleteConfirmation"), selectedItem.FirstName, selectedItem.Surname), StringsFunctions.ResourceString("resConfirmationRequired"), MessageBoxButton.YesNo) != MessageBoxResult.Yes) { result = false; } } ); if (!result) { return; } TestItems.Remove((ItemTypeExtended)selectedItem); }
public void Consume_AItemThatTheCharDoesnotHave() { var human = new TestCharacters().InjuerdHuman; var healthPotion = new TestItems().HealthPotion; var ex = Assert.Throws <InvalidOperationException>(() => human.Consume(healthPotion)); ex.Message.Should().Be($"The Character ({human.Name}) has not this Item: {healthPotion.Name}"); }
public void Apply_useHeathPoitionToGetMaxLife() { var healthPotion = new TestItems().HealthPotion; var injuerdHuman = new TestCharacters().InjuerdHuman; healthPotion.Apply(injuerdHuman); healthPotion.Apply(injuerdHuman); injuerdHuman.CurrentFluentAttributes.LifePoints.Should().Be(15); }
public void Apply_useHeathPoitionOnHealthyCharcater() { var healthPotion = new TestItems().HealthPotion; var elve = new TestCharacters().Elve; healthPotion.Apply(elve); elve.CurrentFluentAttributes.LifePoints.Should().Be(13); }
public void Eqip_ToMuch() { var human = new TestCharacters().InjuerdHuman; var sword = new TestItems().Sword; human.Eqip(sword); human.Eqip(sword); Assert.Throws <WrongRequirementException>(() => human.Eqip(sword)); }
public void Eqip_Amulet() { var elve = new TestCharacters().Elve; var amulet = new TestItems().ElvishAmulet; elve.Eqip(amulet); elve.Eqipped.Should().BeEquivalentTo(new List <StaticItem> { amulet }); }
public void Eqip_Sword() { var human = new TestCharacters().InjuerdHuman; var sword = new TestItems().Sword; human.Eqip(sword); human.Eqipped.Should().BeEquivalentTo(new List <StaticItem> { sword }); }
public void Apply_useHeathPoitionOnEqipedCharcater() { var healthPotion = new TestItems().HealthPotion; var elve = new TestCharacters().Elve; var amuelet = new TestItems().ElvishAmulet; elve.Eqip(amuelet); healthPotion.Apply(elve); elve.CurrentFluentAttributes.LifePoints.Should().Be(18); }
public void GetModifiedFluentAttributes_AmuelettEquipped() { var human = new TestCharacters().InjuerdHuman; var amulett = new TestItems().AmuletOfLife; human.Eqip(amulett); var testData = human.GetModifiedFluentAttributes(); testData.LifePoints.Should().Be(20); }
public void Attack_EqiuppedElve_Attacks_Human() { var human = new TestCharacters().InjuerdHuman; var elve = new TestCharacters().Elve; var sword = new TestItems().Sword; elve.Eqip(sword); elve.Attack(human); human.CurrentFluentAttributes.LifePoints.Should().BeLessOrEqualTo(0) .And.BeGreaterOrEqualTo(-5); }
public void GetModifiedAttributes_SwordEquipped() { var human = new TestCharacters().InjuerdHuman; var sword = new TestItems().Sword; human.Eqip(sword); var testData = human.GetModifiedAttributes(); testData.AttackPoints.Should().Be(8); testData.DefendPoints.Should().Be(5); }
public void Eqip_twice() { var elve = new TestCharacters().Elve; var sword = new TestItems().Sword; elve.Eqip(sword); elve.Eqip(sword); elve.Eqipped.Should().BeEquivalentTo(new List <StaticItem> { sword, sword }); }
public void GetModifiedFluentAttributes_SeveralEquipped() { var human = new TestCharacters().InjuerdHuman; var amuletOfLife = new TestItems().AmuletOfLife; var amulettOfDead = new TestItems().AmuletOfDead; human.Eqip(amuletOfLife); human.Eqip(amulettOfDead); var testData = human.GetModifiedFluentAttributes(); testData.LifePoints.Should().Be(13); }
/// <summary> /// 添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { try { if (this.txtTestItems_Count.Text == "") { mf.ShowToolTip(ToolTipIcon.Info, "提示", "检测项目次数不能为空!", txtTestItems_Count, this); return; } if (Convert.ToDouble(this.txtTestItems_Count.Text) == 0) { mf.ShowToolTip(ToolTipIcon.Info, "提示", "检测项目次数不能为零!", txtTestItems_Count, this); return; } //ValidateTextBox();//调用验证文本框方法 if (!btnCheck()) { return; //去重 } var TestItemsadd = new TestItems { TestItems_NAME = this.txtTestItems_Name.Text.Trim(), //Tes_TestItems_ID = Convert.ToInt32(this.txtTes_TestItems_ID.Text.Trim()), Tes_TestItems_ID = Convert.ToInt32(this.cbxTes_TestItems_ID.SelectedValue), TestItems_Dictionary_ID = Convert.ToInt32(this.cbxTestItemsState.SelectedValue), TestItems_COUNT = Convert.ToInt32(this.txtTestItems_Count.Text.Trim()), TestItems_REMARK = this.txtTestItems_Remark.Text.Trim() }; if (TestItemsDAL.InsertOneQCRecord(TestItemsadd)) { MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } string strContent = "检测项目名称为:" + this.txtTestItems_Name.Text.Trim();; LogInfoDAL.loginfoadd("新增", "新增 " + strContent + " 的信息", Common.USERNAME);//添加日志 } catch (Exception ex) { Common.WriteTextLog("项目检测管理 btnAdd_Click()" + ex.Message.ToString()); } finally { page = new PageControl(); page.PageMaxCount = tscbxPageSize2.SelectedItem.ToString(); LoadData(); } }
protected override void LoadDesignTimeData() { base.LoadDesignTimeData(); for (var i = 1; i < 10; i++) { var color = string.Join("", Enumerable.Repeat(i.ToString(), 6)); var testItem = new TestItem() { Id = i, Title = "Test Item " + i, Subtitle = "Subtitle " + i, HexColor = string.Concat("#", color) }; TestItems.Add(testItem); } }
/// <summary> /// 重新测试 /// </summary> /// <param name="itemID"></param> public void TestItemAgain(Guid itemID) { var testItem = TestItems.FirstOrDefault(q => q.ItemID == itemID); if (testItem == null || (testItem.TestTypeID == TestTypes[0] || testItem.TestTypeID != TestTypes[TestTypes.Length - 1])) { return; } testResultCallback(testItem.ItemID, "正在重新测试", testItem.LastValueString, 3); TestItem(testItem); SaveReference(); }
public void Eqip_Several() { var elve = new TestCharacters().Elve; var amulet = new TestItems().ElvishAmulet; var sword = new TestItems().Sword; var axe = new TestItems().Axe; elve.Eqip(sword); elve.Eqip(axe); elve.Eqip(amulet); elve.Eqipped.Should().BeEquivalentTo(new List <StaticItem> { amulet, sword, axe }); }
public void GetModifiedAttributes_SeveralEquipped() { var human = new TestCharacters().InjuerdHuman; var sword = new TestItems().Sword; var axe = new TestItems().Axe; human.Eqip(sword); human.Eqip(axe); var testData = human.GetModifiedAttributes(); testData.AttackPoints.Should().Be(11); testData.DefendPoints.Should().Be(4); }
/// <summary> /// IL归零 /// </summary> private void Test1Action() { if (IsStop) { return; } var items = TestItems.Where(q => q.TestTypeID == TestTypes[1]).ToList(); var lastPort = -1; var lastTestType = Guid.Empty; if (items.Count < 1) { return; } if (!MeasurementJob.SpecData.WorkInfoSpecItems.Any(q => MeasurementJob.SpecData.GetTestGroup(q.TestGroupID).TestGroupTestType == "Point") && MeasurementJob.SpecData.WorkInfoSpecItems.Any(q => MeasurementJob.SpecData.GetTestGroup(q.TestGroupID).TestGroupTestType == "PointPDL")) { pdlReferces = true; } foreach (var item in items) { if (IsStop) { return; } testResultCallback(item.ItemID, "正在测试", item.LastValueString, 3); var wl = item.Wavelenght; var ch = item.Channel; UpdateTestInfo(wl, ch); if (lastPort != item.Channel) { var result = ShowMessage( 0, $"请将光源连接到 功率计通道{item.Channel},开始获取归零值"); if (result != 1) { return; } } lastPort = item.Channel; lastTestType = item.TestTypeID; TestItem(item); } }
private void NewItemCommandProc(Object o) { NewItemWindow newItemWindow = WindowsUI.ShowWindowDialogEx <NewItemWindow>(); if (newItemWindow.DialogResult == true) { ItemTypeExtended newItem = ItemTypeExtended.GetItemTypeAsItemClassExtended( ((NewItemVM)(newItemWindow.DataContext)).Model.NewItem ); // Update item TestItems.Add( newItem ); } }
public void Apply_useHeathPoitionDependsOnModifiedFluidAttributes() { var healthPotion = new TestItems().HealthPotion; var elve = Substitute.For <Character>(); var baseElve = new TestCharacters().Elve; elve.BaseFluentAttributes = baseElve.BaseFluentAttributes; elve.CurrentFluentAttributes = baseElve.CurrentFluentAttributes; elve.Features = baseElve.Features; elve.GetModifiedFluentAttributes().Returns(new CharacterFluentAttributes { LifePoints = 20 }); healthPotion.Apply(elve); elve.CurrentFluentAttributes.LifePoints.Should().Be(19); }
public override void LoadState(object navParameter, Dictionary <string, object> state) { base.LoadState(navParameter, state); if (!TestItems.Any()) { for (var i = 1; i <= 5; i++) { var color = string.Join("", Enumerable.Repeat(i.ToString(), 6)); var testItem = new TestItem() { Id = i, Title = "Runtime Item " + i, Subtitle = "Subtitle " + i, HexColor = string.Concat("#", color) }; TestItems.Add(testItem); } } }
/// <summary> /// 新增一条质检记录 /// </summary> /// <param name="qcRecord">质检实体</param> /// <returns></returns> public static bool InsertOneQCRecord(TestItems qcRecord) { bool rbool = true; using (DCQUALITYDataContext db = new DCQUALITYDataContext()) { try { db.TestItems.InsertOnSubmit(qcRecord); db.SubmitChanges(); rbool = true; } catch { rbool = false; } finally { db.Connection.Close(); } } return(rbool); }
/// <summary> /// 保存归零 /// </summary> private void SaveAction() { if (IsStop) { return; } var saveitem = TestItems.LastOrDefault(); testResultCallback(saveitem.ItemID, "正在保存", "", 3); MeasurementJob.ReferenceData.ResetReferenceTimeOut(); if (!SaveReference()) { saveitem.ValueString = "Fail"; testResultCallback(saveitem.ItemID, "失败", "", 2); } else { saveitem.ValueString = "OK"; testResultCallback(saveitem.ItemID, "通过", "", 1); } }
public static void Init(string jsonFilename, string?rootPath = null) { if (rootPath != null) { TestDataRoot = rootPath; } TestItems.Clear(); var items = JsonConvert.DeserializeObject <List <Item> >(File.ReadAllText(Path.Combine(TestDataRoot, jsonFilename)), new JsonSerializerSettings() { Converters = { new Converter() } }); if (items == null) { return; } foreach (var item in items) { TestItems.Add(item.Name, item); } }
private void ModifyItemCommandProc(Object selectedItems) { ItemTypeExtended selectedItem = (ItemTypeExtended)((ObservableCollection <object>)selectedItems).FirstOrDefault(); if (selectedItem == null) { return; } // Show window EditItemWindow editItemWindow = WindowsUI.ShowWindowDialogEx <EditItemWindow>(selectedItem); if (editItemWindow.DialogResult == true) { ItemTypeExtended currentItem = ItemTypeExtended.GetItemTypeAsItemClassExtended( ((EditItemVM)(editItemWindow.DataContext)).Model.CurrentItem ); // Update item TestItems.Update(selectedItem, currentItem); } }
/// <summary> /// 回损归零 /// </summary> private void Test2Action() { if (IsStop) { return; } var items = TestItems.Where(q => q.TestTypeID == TestTypes[2]).ToList(); var lastTestType = Guid.Empty; foreach (var item in items) { if (IsStop) { return; } testResultCallback(item.ItemID, "正在测试", item.LastValueString, 3); var wl = item.Wavelenght; var ch = 1; UpdateTestInfo(wl, ch); if (lastTestType == Guid.Empty) { var result = ShowMessage( 0, $"请将回损探头连接到功率计通道{item.Channel},并打折光源线,开始获取系统回损"); if (result != 1) { return; } } lastTestType = item.TestTypeID; TestItem(item); } }