public void ShouldSendMetadataRequested() { PeerHash other = PeerHash.Random(); PeerHash[] peers = { other }; using (MetagetFixture fixture = new MetagetFixture()) using (MetagetSession session = fixture.Start()) { MetadataMeasured measured = new MetadataMeasured { Hash = session.Hash, Size = session.Size, Peer = PeerHash.Random() }; A.CallTo(() => session.Glue.Peers).Returns(peers); session.Service.Start(); session.Service.Handle(measured); session.Pipeline.Process(); session.Pipeline.Tick(); session.Pipeline.Process(); A.CallTo(() => session.Glue.SendMetadataRequest(other, 0)).MustHaveHappened(); } }
public void ShouldTriggerMetafileMeasured() { using (MetagetFixture fixture = new MetagetFixture()) using (MetagetSession session = fixture.Start()) { MetadataMeasured measured = new MetadataMeasured { Hash = session.Hash, Size = session.Size, Peer = PeerHash.Random() }; Trigger handler = Trigger.Bind(ref session.Hooks.OnMetafileMeasured, data => { data.Hash.Should().Be(session.Hash); data.Size.Should().Be(session.Size); }); session.Service.Start(); session.Service.Handle(measured); session.Pipeline.Process(); handler.Wait().Should().BeTrue(); } }
public void ShouldVerifyMetafileWhenStarted() { using (MetagetFixture fixture = new MetagetFixture()) using (MetagetSession session = fixture.Start(true)) { A.CallTo(() => session.Metafile.IsCompleted()).Returns(false); session.Service.Start(); session.Pipeline.Process(); A.CallTo(() => session.Metafile.Verify()).MustHaveHappened(); } }