private static void IntegrationTest()
{
	TunerFactoryConnectionManager tunerConnectionManager = TunerFactoryConnectionManager.GetInstance();
    ITunerFactory tunerFactory = tunerConnectionManager.GetTunerFactoryById(2);
    RemoteStreamReaderTunerFactory remoteTunerFactory = (RemoteStreamReaderTunerFactory)tunerFactory;
    remoteTunerFactory.Hostname = "tetsuro";
    remoteTunerFactory.Port = 6970;
    IStreamReader streamReader = remoteTunerFactory.CreateStreamReader();
    streamReader.CheckForDVBExEx((x, y, z) => Console.WriteLine("{0}, {1}, {2}", x, y, z.ToString()));
    if (!streamReader.StartDvbEx(2))
    {
        streamReader.Dispose();
        return;
    }
    DiSEqC_Opcode baseDiseqc = DiSEqC_Opcode.DISEQC_HIGH_NIBBLE | DiSEqC_Opcode.DISEQC_OPTION_A | DiSEqC_Opcode.DISEQC_POSITION_A;
    DiSEqC_Opcode lh = baseDiseqc | DiSEqC_Opcode.DISEQC_LOW_BAND | DiSEqC_Opcode.DISEQC_HORIZONTAL;
    DiSEqC_Opcode hh = baseDiseqc | DiSEqC_Opcode.DISEQC_HIGH_BAND | DiSEqC_Opcode.DISEQC_HORIZONTAL;
    DiSEqC_Opcode lv = baseDiseqc | DiSEqC_Opcode.DISEQC_LOW_BAND | DiSEqC_Opcode.DISEQC_VERTICAL;
    DiSEqC_Opcode hv = baseDiseqc | DiSEqC_Opcode.DISEQC_HIGH_BAND | DiSEqC_Opcode.DISEQC_VERTICAL;
	int lof1 = 9750 * 1000;
	int lof2 = 10600 * 1000;
	int lofSw = 11700 * 1000;
	int startFreq = 10700 * 1000;
	int endFreq = 12750 * 1000;
	int step = 1000;

	RfSpectrumData spectrumData = RfSpectrumData.Create();

	void RunRfScan(RfSpectrumData spectrum, int startFreq, int endFreq, SatelliteDeliverySystemDescriptor.PolarizationEnum polarization, DiSEqC_Opcode diseqcCmd, int lof1, int lof2, int lofSw)
	{
		const int STEP = 1000;
		streamReader.SendDiSEqC(2, diseqcCmd);
		RfSpectrumDataBlock block = spectrumData.CreateBlock(startFreq, endFreq, STEP, polarization);
		for (int i = startFreq; i <= endFreq; i += STEP)
		{
            double rf = Double.NaN;
            streamReader.RFScan(i, diseqcCmd.HasFlag(DiSEqC_Opcode.DISEQC_HORIZONTAL) ? 0 : 1, lof1, lof2, lofSw, out rf);
            Console.WriteLine("{0} {1}, {2}", i, polarization.ToString().Substring(0, 1), rf);
            block.Push(i, rf);
		}
	}

	RunRfScan(spectrumData, startFreq, lofSw, SatelliteDeliverySystemDescriptor.PolarizationEnum.HorizontalLinear, lh,lof1,lof2,lofSw);
	RunRfScan(spectrumData, lofSw, endFreq, SatelliteDeliverySystemDescriptor.PolarizationEnum.HorizontalLinear, hh, lof1, lof2, lofSw);
	RunRfScan(spectrumData, startFreq, lofSw, SatelliteDeliverySystemDescriptor.PolarizationEnum.VerticalLinear, lv, lof1, lof2, lofSw);
	RunRfScan(spectrumData, lofSw, endFreq, SatelliteDeliverySystemDescriptor.PolarizationEnum.VerticalLinear, hv, lof1, lof2, lofSw);

	FileStream fileStream = File.OpenWrite("spectrum.bin");
	spectrumData.SaveTo(fileStream);
	fileStream.Flush(true);
    fileStream.Close();

    streamReader.StopDVB();
	streamReader.Dispose();
}