Ejemplo n.º 1
0
        public void ContainsPort_Mac_returns_true_if_port_is_listening(int port, bool isListening, string fileName)
        {
            FileInfo responseFile = new FileInfo(Path.Combine(Directory.GetCurrentDirectory(), "SystemResponses", "Mac", fileName));

            if (!responseFile.Exists)
                throw new FileNotFoundException($"Could not find test file: {responseFile.FullName}");

            _runtimeInfoMock.Setup(m => m.NewLine).Returns("\n").Verifiable();
            _runtimeInfoMock.Setup(m => m.IsMac).Returns(true).Verifiable();

            string netstatResponse = File.ReadAllText(responseFile.FullName);

            NetworkingService service = (NetworkingService)CreateService();

            Assert.Equal(isListening, service.ContainsNetstatPort(netstatResponse, port));

            _runtimeInfoMock.Verify();
        }