Exemplo n.º 1
0
        public void ArpScanner_GetRespondingMachines_Starts_ArpScan_Process()
        {
            // Arrange
            IProcessWrapper mockProcessWrapper = GetMockProcessWrapper(new string[] { null });

            _processWrapperFactory.Stub(x => x.GetNewProcessWrapper()).Return(mockProcessWrapper);
            var sut = new ArpScanner(_processWrapperFactory);

            // Act
            sut.GetRespondingMachines();

            // Assert
            mockProcessWrapper.AssertWasCalled(x => x.Start(), options => options.Repeat.Once());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Test runner - Test that GetRespondingMachines continues if ReadLine content is invalid.
        /// </summary>
        /// <param name="content">ReadLine content.</param>
        private void GetRespondingMachinesShouldContinueIfReadLineContentInvalid_TestRunner(string content)
        {
            // Arrange
            IProcessWrapper mockProcessWrapper = GetMockProcessWrapper(new string[] { content, null });

            _processWrapperFactory.Stub(x => x.GetNewProcessWrapper()).Return(mockProcessWrapper);
            var sut = new ArpScanner(_processWrapperFactory);

            // Act
            IEnumerable <IPAddress> scanResults = sut.GetRespondingMachines();

            // Assert
            Assert.IsFalse(scanResults.Any());
        }
Exemplo n.º 3
0
        public void ArpScanner_GetResponding_Machines_Only_Returns_Valid_IP_Addresses()
        {
            // Arrange
            const int    IP_ADDRESS_COUNT   = 1;
            const string INVALID_IP_ADDRESS = "300.0.0.1";
            const string VALID_IP_ADDRESS   = "127.0.0.1";

            IProcessWrapper mockProcessWrapper = GetMockProcessWrapper(new string[] { INVALID_IP_ADDRESS + " OK", VALID_IP_ADDRESS + " OK", null });

            _processWrapperFactory.Stub(x => x.GetNewProcessWrapper()).Return(mockProcessWrapper);
            var sut = new ArpScanner(_processWrapperFactory);

            // Act
            IEnumerable <IPAddress> scanResults = sut.GetRespondingMachines();

            // Assert
            Assert.AreEqual(IP_ADDRESS_COUNT, scanResults.Count());
            Assert.AreEqual(VALID_IP_ADDRESS, scanResults.First().ToString());
        }
Exemplo n.º 4
0
        public void ArpScanner_GetRespondingMachines_Should_Return_Responding_IP_Address_List()
        {
            // Arrange
            const int       IP_ADDRESS_COUNT   = 2;
            const string    IP_ADDRESS1        = "127.0.0.1";
            const string    IP_ADDRESS2        = "192.168.1.1";
            IProcessWrapper mockProcessWrapper = GetMockProcessWrapper(new string[] { IP_ADDRESS1 + " OK", IP_ADDRESS2 + " OK", null });

            _processWrapperFactory.Stub(x => x.GetNewProcessWrapper()).Return(mockProcessWrapper);
            var sut = new ArpScanner(_processWrapperFactory);

            // Act
            IEnumerable <IPAddress> scanResults = sut.GetRespondingMachines();

            // Assert
            Assert.AreEqual(IP_ADDRESS_COUNT, scanResults.Count());
            Assert.AreEqual(IP_ADDRESS1, scanResults.ElementAt(0).ToString());
            Assert.AreEqual(IP_ADDRESS2, scanResults.ElementAt(1).ToString());
        }