public static void TestReadFile(string db, string torrentPath, string baseDir, string filePath, string origianlFile) { //System.Diagnostics.Debugger.Launch(); var kernel = new StandardKernel(); kernel.Load(new ServiceNinjectModule()); kernel.Bind<FileInfoTable<TorrentManager>>().ToSelf().InSingletonScope(); var dbs = new ChunkDbService(db, false); var ds = new DeduplicationService(dbs); kernel.Bind<DeduplicationService>().ToConstant(ds).InSingletonScope(); var writer = new DedupDiskWriter(ds); var engineSettings = new EngineSettings(); engineSettings.PreferEncryption = false; engineSettings.AllowedEncryption = EncryptionTypes.All; int port = 33123; var ip = NetUtil.GetLocalIPByInterface("Local Area Connection"); engineSettings.ReportedAddress = new IPEndPoint(ip, port); var engine = new ClientEngine(engineSettings, new DedupDiskWriter(ds)); kernel.Bind<DiskManager>().ToConstant(engine.DiskManager).InSingletonScope(); kernel.Bind<ClientEngine>().ToConstant(engine).InSingletonScope(); kernel.Bind<DistributedDiskManager>().ToSelf(); kernel.Bind<FileService>().ToSelf().WithConstructorArgument("baseDir", baseDir); kernel.Bind<VirtualDiskDownloadService>().ToSelf(); var vd = kernel.Get<VirtualDiskDownloadService>(); var torrent = Torrent.Load(torrentPath); logger.DebugFormat("Loaded torrent file: {0}, piece length: {1}.", torrent.Name, torrent.PieceLength); vd.StartDownloadingFile(torrent, baseDir, -1); KernelContainer.Kernel = kernel; var m = new HurricaneServiceManager(); m.Start(); var url = string.Format("http://{0}:18081/FileService/", ip.ToString()); logger.DebugFormat("Contacting service at {0}", url); var client = new ManualFileServiceClient(url); string tstmsg = "tstmsg"; var resp = client.Echo(tstmsg); Assert.AreEqual(resp, tstmsg); byte[] resultData = null; try { var pathStatus = client.GetPathStatus(filePath); logger.DebugFormat("File size: {0}", pathStatus.FileSize); } catch (Exception ex) { logger.Error(ex); } try { // can only read 49352. resultData = client.Read(filePath, 0, 49253); } catch (Exception ex) { logger.Error(ex); } var actualData = IOUtil.Read(origianlFile, 0, 49252); try { Assert.IsTrue(actualData.SequenceEqual(resultData), "File part should match."); logger.Debug("Read succeeded."); } catch (Exception ex) { logger.Error(ex); } Console.Read(); }