Exemple #1
0
        public async void ScanAllMultiple_ShouldThrowPortsNullException()
        {
            string host = "localhost";

            Port[] ports = null;

            IScanner scanner = new MultipleScanner
            {
                Host  = host,
                Ports = ports
            };

            scanner.OnScanEnding += Scanner_OnScanEnding;

            await Assert.ThrowsAsync <ArgumentNullException>("Ports", async() => await scanner.ScanAllAsync());
        }
Exemple #2
0
        public async void ScanAllMultiple_ShouldDoNothingBecauseHostAreEmpty()
        {
            string host = "";

            Port[] ports = new Port[] { };

            IScanner scanner = new MultipleScanner
            {
                Host  = host,
                Ports = ports
            };

            scanner.OnScanEnding += Scanner_OnScanEnding;

            await scanner.ScanAllAsync();

            Assert.False(_results.HostIsValid);
        }
Exemple #3
0
        public async void ScanAllMultiple_ShouldDoNothingBecausePortsAreEmpty()
        {
            string host = "localhost";

            Port[] ports = new Port[] { };

            IScanner scanner = new MultipleScanner
            {
                Host  = host,
                Ports = ports
            };

            scanner.OnScanEnding += Scanner_OnScanEnding;

            await scanner.ScanAllAsync();

            Assert.True(_results.HostIsValid);
            Assert.True(_results.PortsAfterScan.Length == 0);
        }
Exemple #4
0
        public async void ScanAllMultiple_ShouldMultipleScanPorts()
        {
            string host = "localhost";

            Port[] ports = _multiplePorts;

            IScanner scanner = new MultipleScanner
            {
                Host  = host,
                Ports = ports
            };

            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);
            }
        }