public HgResumeTransportProvider(HgResumeTransport transport) { Transport = transport; }
public void Push_2DifferentApiServers_HgRepoFileUpdatedWithBothEntries() { using (var e1 = new TestEnvironment("api1", ApiServerType.Dummy)) using (var provider = GetTransportProviderForTest(e1)) { var api2 = new DummyApiServerForTest("api3"); var transport2 = new HgResumeTransport(e1.Local.Repository, "api3", api2, e1.MultiProgress); // push to ApiServer 1 e1.LocalAddAndCommit(); var revisionResponse = ApiResponses.Revisions(e1.Local.Repository.GetTip().Number.Hash + ':' + e1.Local.Repository.GetTip().Branch); e1.ApiServer.AddResponse(revisionResponse); e1.LocalAddAndCommit(); e1.ApiServer.AddResponse(ApiResponses.PushComplete()); var tipHash1 = e1.Local.Repository.GetTip().Number.Hash; var transport = provider.Transport; transport.Push(); e1.ApiServer.AddResponse(ApiResponses.PushComplete()); // finishPushBundle // push to ApiServer 2 api2.AddResponse(revisionResponse); api2.AddResponse(ApiResponses.PushComplete()); transport2.Push(); // check contents of remoteRepoDb string dbStoragePath = transport.PathToLocalStorage; string dbFilePath = Path.Combine(dbStoragePath, HgResumeTransport.RevisionCacheFilename); var cacheContents = HgResumeTransport.ReadServerRevisionCache(dbFilePath); Assert.True(cacheContents.Count == 2, "should be two api server entries in the cache."); Assert.True(cacheContents.SingleOrDefault(x => x.RemoteId == e1.ApiServer.Host).Revision.Number.Hash == tipHash1, "Cache contents incorrect"); Assert.True(cacheContents.SingleOrDefault(x => x.RemoteId == api2.Host).Revision.Number.Hash == tipHash1, "Cache contents incorrect"); // second push e1.LocalAddAndCommit(); e1.LocalAddAndCommit(); string tipHash2 = e1.Local.Repository.GetTip().Number.Hash; e1.ApiServer.AddResponse(ApiResponses.PushAccepted(1)); e1.ApiServer.AddResponse(ApiResponses.PushComplete()); transport.Push(); cacheContents = HgResumeTransport.ReadServerRevisionCache(dbFilePath); Assert.True(cacheContents.Count == 2, "should be two api server entries in the cache."); Assert.True(cacheContents.SingleOrDefault(x => x.RemoteId == e1.ApiServer.Host).Revision.Number.Hash == tipHash2, "Cache contents incorrect"); Assert.True(cacheContents.SingleOrDefault(x => x.RemoteId == api2.Host).Revision.Number.Hash == tipHash1, "Cache contents incorrect"); Assert.That(e1.Progress.AllMessages, Contains.Item("Finished sending")); } }