public async void ScanAllRange_ShouldDoNothingBecauseHostAreEmpty() { string host = ""; RangeOfPorts rangeOfPorts = _validRange; IScanner scanner = new RangeOfPortsScanner { Host = host, Ports = rangeOfPorts.GetPortsArray(), }; scanner.OnScanEnding += Scanner_OnScanEnding; await scanner.ScanAllAsync(); Assert.False(_results.HostIsValid); }
public async void ScanAllRange_ShouldThrowRangeExceptionBecausePortsNotInitialized() { string host = "localhost"; RangeOfPorts rangeOfPorts = new RangeOfPorts(); await Assert.ThrowsAsync <RangeOfPortsException>(async() => { IScanner scanner = new RangeOfPortsScanner { Host = host, Ports = rangeOfPorts.GetPortsArray(), }; scanner.OnScanEnding += Scanner_OnScanEnding; await scanner.ScanAllAsync(); }); }
public async void ScanAllRange_ShouldThrowRangeExceptionBecausePortsIncorrect() { string host = "localhost"; RangeOfPorts rangeOfPorts = new RangeOfPorts { FromTcp = 20, ToTcp = 15, }; await Assert.ThrowsAsync <RangeOfPortsException>(async() => { IScanner scanner = new RangeOfPortsScanner { Host = host, Ports = rangeOfPorts.GetPortsArray(), }; scanner.OnScanEnding += Scanner_OnScanEnding; await scanner.ScanAllAsync(); }); }
public async void ScanAllRange_ShouldScanRangeOfPorts() { string host = "localhost"; RangeOfPorts rangeOfPorts = _validRange; IScanner scanner = new RangeOfPortsScanner { Host = host, Ports = rangeOfPorts.GetPortsArray(), }; scanner.OnScanEnding += Scanner_OnScanEnding; await scanner.ScanAllAsync(); Assert.True(_results.HostIsValid); foreach (var result in _results.PortsAfterScan) { Assert.True(result.State == PortState.Opened || result.State == PortState.Closed); } }
public async void ScanAllRange_ShouldThrowHostNullException() { string host = null; RangeOfPorts rangeOfPorts = _validRange; IScanner scanner = new RangeOfPortsScanner { Host = host, Ports = rangeOfPorts.GetPortsArray(), }; scanner.OnScanEnding += Scanner_OnScanEnding; await Assert.ThrowsAsync <ArgumentNullException>("Host", async() => await scanner.ScanAllAsync()); }
public async void ScanAllRange_ShouldThrowPortsNullException() { string host = "localhost"; IScanner scanner = new RangeOfPortsScanner { Host = host, Ports = null, }; scanner.OnScanEnding += Scanner_OnScanEnding; await Assert.ThrowsAsync <ArgumentNullException>("Ports", async() => await scanner.ScanAllAsync()); }