public void When_Container_Is_Valuable_It_Only_Ends_Up_In_Even_Stacks() { //Arrange ShipRow sr = new ShipRow(7); //Act for (int i = 0; i < 30; i++) { Container container = ContainerConstructor.CreateContainer(true, false, 30000); sr.AddContainer(container); } //Assert for (int i = 0; i < sr.Stacks.Count; i++) { if (i % 2 == 0) { Assert.AreEqual(1, sr.Stacks[i].ContainerCount); } else { Assert.AreEqual(0, sr.Stacks[i].ContainerCount); } } }
public void ShipRow_Contains_Correct_Number_Of_Stacks() { //Arrange / Act ShipRow sr = new ShipRow(7); //Assert Assert.AreEqual(sr.Stacks.Count, 7); }
public void AddContainerToStacks_OneValuableOneNormalToStack_ShouldReturnTrue() { // Arrange bool expected = true; ShipRow shipRow = new ShipRow(1); shipRow.AddContainerToStacks(new ContainerValuable(4000)); // Act bool actual = shipRow.AddContainerToStacks(new ContainerNormal(4000)); // Assert Assert.AreEqual(expected, actual); }
public void AddContainerToStacks_OneCoolableValuableOneValuableToTwoStacks_ShouldReturnFalse() { // Arrange bool expected = true; ShipRow shipRow = new ShipRow(2); shipRow.AddContainerToStacks(new ContainerCoolableValuable(4000)); // Act bool actual = shipRow.AddContainerToStacks(new ContainerValuable(4000)); // Assert Assert.AreEqual(expected, actual); }
public void AddContainerToStacks_TwoValuableToOneStack_ShouldReturnFalse() { // Arrange bool expected = false; ShipRow shipRow = new ShipRow(1); shipRow.AddContainerToStacks(new ContainerValuable(4000)); // Act bool actual = shipRow.AddContainerToStacks(new ContainerValuable(4000)); // Assert Assert.AreEqual(expected, actual); }
public void When_Container_Is_Cooled_It_Only_Ends_Up_In_First_Stack() { //Arange ShipRow sr = new ShipRow(7); //Act for (int i = 0; i < 30; i++) { Container cooledContainer = ContainerConstructor.CreateContainer(false, true, 30000); sr.AddContainer(cooledContainer); } //Assert Assert.IsTrue(sr.Stacks[0].ContainerCount > 0); for (int i = 1; i < sr.Stacks.Count; i++) { Assert.AreEqual(0, sr.Stacks[i].ContainerCount); } }
public void Every_Fourth_Stack_Is_Lower_Than_The_Stack_Before_Or_After_That_If_One_Of_Those_Has_A_Valuable_Container() { //Arrange ShipRow sr = new ShipRow(7); List <Container> containers = ContainerConstructor.CreateRandomContainers(500); containers.SortForShip(); //Act foreach (Container container in containers) { sr.AddContainer(container); } //Assert if (sr.Stacks[2].HasValuable && sr.Stacks[3].ContainerCount >= sr.Stacks[2].ContainerCount) { Assert.Fail(); } if (sr.Stacks[4].HasValuable && sr.Stacks[3].ContainerCount >= sr.Stacks[4].ContainerCount) { Assert.Fail(); } }
private void CheckClipboardData() { if (bCheckClipboardDataRunning || m_esi == null || !StaticData.getInstance().m_loaded) { return; } bCheckClipboardDataRunning = true; if (Clipboard.ContainsText(TextDataFormat.Text)) { Debug.WriteLine("CheckClipboardData()"); string clipboardText = Clipboard.GetText(TextDataFormat.Text); if (m_oldClipboardText != clipboardText) { m_oldClipboardText = clipboardText; // check if d-scan bool bDScan = false; MatchCollection matches = Regex.Matches(clipboardText, @"^(\d+)\t([^\t]+).*$", RegexOptions.Multiline); if (matches.Count > 0) { m_ships.Clear(); } foreach (Match match in matches) { bDScan = true; ShipRow shiprow = new ShipRow(); shiprow.m_name = match.Groups[2].Value.Trim(); shiprow.m_typeid = match.Groups[1].Value.Trim(); try { StaticData sd = StaticData.getInstance(); string groupId = sd.m_typeIds[shiprow.m_typeid]["groupID"]; shiprow.m_typename = sd.m_typeIds[shiprow.m_typeid]["name"]["en"]; shiprow.m_faction = sd.m_typeIds[shiprow.m_typeid]["sofFactionName"]; shiprow.m_category = sd.m_groupIds[groupId]["name"]["en"]; m_ships.Add(shiprow); m_esi.downloadImage(0, shiprow.m_typeid); } catch (Exception) { // try next row } } if (bDScan) { //dataGridViewMain.Invoke((MethodInvoker)delegate { UpdateStatus(true, false, true, false); }); UpdateStatus(true, false, true, false); } // check local persons bool bLocalScan = false; if (!bDScan) { string ownname = m_esi.getLoggedUserName(); clipboardText += "\r\n"; // just to be sure matches = Regex.Matches(clipboardText, @"^(.*)$", RegexOptions.Multiline); foreach (Match match in matches) { if (match.Groups[1].Value.Trim() == ownname) { bLocalScan = true; break; } } if (bLocalScan) { m_local.Clear(); m_esi.killAllPersonThreads(); foreach (Match match in matches) { string name = match.Groups[1].Value.Trim(); if (name.Length > 0 && name != ownname) { PilotRow pilotrow = new PilotRow(); pilotrow.m_name = name; m_esi.fillChar(pilotrow); m_local.Add(pilotrow); } } //dataGridViewMain.Invoke((MethodInvoker)delegate { UpdateStatus(false, true, false, true); }); UpdateStatus(false, true, false, true); } } } } bCheckClipboardDataRunning = false; }