public void GetLastHostAddress_ClassC_NetworkPortion28() { // arrange var mockKeyboardInteraction = new Mock <MockKeyboardInteraction>(); mockKeyboardInteraction.SetupSequence(m => m.ReadString()).Returns("200.1.129.129").Returns("28"); var actions = new CheckIpv4AddressActions(mockKeyboardInteraction.Object); var expected = "Last host address = 200.1.129.142"; // act var result = actions.GetLastHostAddress(); // assert Assert.NotNull(result); Assert.AreEqual(expected, result); }
public void GetLastHostAddress_Special() { // arrange var mockKeyboardInteraction = new Mock <MockKeyboardInteraction>(); mockKeyboardInteraction.SetupSequence(m => m.ReadString()).Returns("127.1.1.1").Returns("24"); var actions = new CheckIpv4AddressActions(mockKeyboardInteraction.Object); var expected = "Last host address = 127.1.1.1"; // act var result = actions.GetLastHostAddress(); // assert Assert.NotNull(result); Assert.AreEqual(expected, result); }
public int Run() { int state = Int32.MinValue; while (state != 0 && state != -1) { ShowMenu(); state = _keyboardInteraction.ReadNumber(); switch (state) { case 1: Console.WriteLine(_actions.ServeIsHostValid()); break; case 2: Console.WriteLine(_actions.ServeGetAddressType()); break; case 3: Console.WriteLine(_actions.GetNetworkAddress()); break; case 4: Console.WriteLine(_actions.GetBroadcastAddress()); break; case 5: Console.WriteLine(_actions.GetFirstHostAddress()); break; case 6: Console.WriteLine(_actions.GetLastHostAddress()); break; case 7: new SubnetMaskOfNetworkActionManager(_keyboardInteraction).Run(); break; case 8: Console.WriteLine(_actions.GetClassAddress()); break; case 9: Console.WriteLine(_actions.SubnetNetworkBitCount()); break; case 10: Console.WriteLine(_actions.GetHostBitCount()); break; case 11: Console.WriteLine(_actions.GetPossibleSubnetsCount()); break; case 12: Console.WriteLine(_actions.GetPossibleHostCount()); break; case 13: Console.WriteLine(_actions.GetFullNetworkData()); break; case 14: Console.WriteLine(_actions.BinaryFromDecimal()); break; case 15: Console.WriteLine(_actions.DecimalFromBinary()); break; case -1: case 0: break; default: Console.WriteLine(state + " is not in options."); break; } } return(state); }