public void ExpectedInterfacesPoeStatus() { var fakeInterfacesPoeStatusResults = GetFakeInterfacesPoeStatusResults(); var eth4 = new Mock <EthernetPoe>(); eth4.Object.Name = "ether4"; eth4.Setup(r => r.MonitorOnce(It.IsAny <ITikConnection>())) .Returns <ITikConnection>(MonitorPoEOnceLocal); var eth6 = new Mock <EthernetPoe>(); eth6.Object.Name = "ether6"; eth6.Setup(r => r.MonitorOnce(It.IsAny <ITikConnection>())) .Returns <ITikConnection>(MonitorPoEOnceLocal); var list = new List <EthernetPoe> { eth4.Object, eth6.Object }; var poeReader = new Mock <IEntityReader <EthernetPoe> >(); poeReader.Setup(r => r.GetAll()).Returns(() => { var results = list.ToArray(); return(results); }); var poleTester = new PoleTester(_logger.Object, _connection.Object); var interfacesPoeStatus = poleTester.GetInterfacesPoeStatus(poeReader.Object); Assert.Equal(fakeInterfacesPoeStatusResults, interfacesPoeStatus); }
public void ExpectedInterfaceNegotiation() { var fakeInterfacesNegotiation = GetFakeInterfacesNegotiation(); var eth2 = new Mock <InterfaceEthernet>(); eth2.Object.Name = "ether2"; eth2.Object.Running = true; eth2.Setup(r => r.MonitorOnce(It.IsAny <ITikConnection>())) .Returns <ITikConnection>(MonitorOnceLocal); var eth3 = new Mock <InterfaceEthernet>(); eth3.Object.Name = "ether3"; eth3.Object.Running = true; eth3.Setup(r => r.MonitorOnce(It.IsAny <ITikConnection>())) .Returns <ITikConnection>(MonitorOnceLocal); var eth4 = new Mock <InterfaceEthernet>(); eth4.Object.Name = "ether4"; eth4.Object.Running = true; eth4.Setup(r => r.MonitorOnce(It.IsAny <ITikConnection>())) .Returns <ITikConnection>(MonitorOnceLocal); var eth5 = new Mock <InterfaceEthernet>(); eth5.Object.Name = "ether5"; eth5.Object.Running = false; eth5.Setup(r => r.MonitorOnce(It.IsAny <ITikConnection>())) .Returns <ITikConnection>(MonitorOnceLocal); var eth6 = new Mock <InterfaceEthernet>(); eth6.Object.Name = "ether6"; eth6.Object.Running = true; eth6.Setup(r => r.MonitorOnce(It.IsAny <ITikConnection>())) .Returns <ITikConnection>(MonitorOnceLocal); var list = new List <InterfaceEthernet> { eth2.Object, eth3.Object, eth4.Object, eth5.Object, eth6.Object }; _ethReader.Setup(r => r.GetAll()).Returns(() => { var results = list.ToArray(); return(results); }); var poleTester = new PoleTester(_logger.Object, _connection.Object); var interfacesNegotiation = poleTester.GetInterfacesNegotiation(_ethReader.Object); Assert.Equal(fakeInterfacesNegotiation, interfacesNegotiation); }
private static void Main(string[] args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } // Set up configuration sources. var mycfg = InitialSetup(); var connection = GetMikrotikConnection(mycfg.Host, mycfg.ApiUser, mycfg.ApiPass); var neighReader = connection.CreateEntityReader <IpNeighbor>(); var etherReader = connection.CreateEntityReader <InterfaceEthernet>(); var poeReader = connection.CreateEntityReader <EthernetPoe>(); var bTest = new BandwidthTest(connection); var poleTester = new PoleTester(Log.Logger, connection); var interfacesToTest = poleTester.GetNeighborsOnRunningInterfaces(etherReader, neighReader); var interfacesPoeStatus = poleTester.GetInterfacesPoeStatus(poeReader); var interfacesNegotiation = poleTester.GetInterfacesNegotiation(etherReader); var interfacesBandwidthTest = poleTester.RunBandwidthTests(interfacesToTest, interfacesNegotiation, bTest); foreach (var ethtotest in interfacesToTest) { Log.Logger.Information("Agregada para testear {InterfaceTesteable}", ethtotest.ToString()); } foreach (var ethPoeStatus in interfacesPoeStatus) { Log.Logger.Information("Estado Poe {InterfacePoeStatus}", ethPoeStatus.ToString()); } foreach (var ifaceNegotiation in interfacesNegotiation) { Log.Logger.Information("Negotiation {InterfaceNegotiation}", ifaceNegotiation.ToString()); } connection.Dispose(); Log.Logger.Information("Done!, press Enter to end"); Console.ReadLine(); }
public void ExpectedBandwidthTestInterfaces() { var fakeInterfaceListToTestResults = GetFakeEthToTestResults(); var fakeInterfacesNegotiation = GetFakeInterfacesNegotiation(); var fakeBandwidthTestInterfaces = GetFakeBandwidthTestInterfaces(); var btest = new Mock <IBandwidthTest>(); btest.Setup(b => b.Run(It.IsAny <BandwidthTestParameters>(), It.IsAny <int>())) .Returns(RunLocal); var poleTester = new PoleTester(_logger.Object, _connection.Object); var btResults = poleTester.RunBandwidthTests (fakeInterfaceListToTestResults, fakeInterfacesNegotiation, btest.Object); Assert.Equal(fakeBandwidthTestInterfaces, btResults); }
public void ExpectedNeighborsOnRunningInterfaces() { var ethlist = GetFakeEthList(); _ethReader.Setup(r => r.GetAll()).Returns(ethlist.ToArray); var fakeInterfaceListToTestResults = GetFakeEthToTestResults(); var neighList = GetFakeNeighList(); var neigReader = new Mock <IEntityReader <IpNeighbor> >(); neigReader.Setup(r => r.GetAll()).Returns(neighList.ToArray); var poleTester = new PoleTester(_logger.Object, _connection.Object); var interfaceToTest = poleTester.GetNeighborsOnRunningInterfaces (_ethReader.Object, neigReader.Object); Assert.Equal(fakeInterfaceListToTestResults, interfaceToTest); }