public void Pass_Correct_Values_To_Server_Client() { // arrange var args = new[] { "-n", "test" }; var initMethod = new InitMethod(); var clientBuilder = new ServerClientBuilder(); var dbg = new DebugEngineProxyBuilder(); var builder = new TimeTravelFacadeBuilder(dbg); builder.WithGetStartingPosition(new Position(0, 0)).WithGetEndingPosition(new Position(1, 0)); initMethod.TimeTravelFacade = builder.Build(); initMethod.ServerClient = clientBuilder.Build(); initMethod.Settings = new Settings { ServerUrl = "http://localhost:5000" }; // act initMethod.Process(args); // assert clientBuilder.Mock.Verify( client => client.InitializeProject("test", new Position(0, 0), new Position(1, 0)), Times.Once); }
public void Upsert_All_Frames_At_The_Current_Position() { var options = new IndexOptions() { MemoryRanges = new [] { new MemoryRange(0x100, 0x200), } }; var indexMethod = new IndexMethod(); var sc = new ServerClientBuilder(); sc.WithUpsertFrames(() => { }); sc.WithAddMemoryRange(); var ttf = new TimeTravelFacadeBuilder(); ttf.WithPositions(new PositionsResult(new[] { new PositionsRecord(1, new Position(1, 1), true), new PositionsRecord(2, new Position(1, 1), false), })); var dbg = new DebugEngineProxyBuilder(); dbg.WithReadVirtualMemory(new byte[] { 0x00, 0x11 }); indexMethod.ServerClient = sc.Build(); indexMethod.TimeTravelFacade = ttf.Build(); indexMethod.DebugEngineProxy = dbg.Build(); indexMethod.UpsertCurrentPosition(options); sc.Mock.Verify(client => client.UpsertFrames(It.Is <IEnumerable <Frame> >(frames => frames.Count() == 2)), Times.Once); sc.Mock.Verify(client => client.AddMemoryRange(It.IsAny <MemoryChunk>()), Times.Once); }
public void Upsert_Frames_From_Breaks() { var dbg = new DebugEngineProxyBuilder(); var tt = new TimeTravelFacadeBuilder(dbg); var sc = new ServerClientBuilder(); var bp = new BreakpointFacadeBuilder(); dbg.WithRunUntilBreak(); var count = 0; dbg.SetRunUntilBreakCallback(() => { if (count++ > 0) { tt.AdvanceToNextPosition(); } }); var dbgEngProxy = dbg.Build(); var timeTravelFacade = tt.Build(); var serverClient = sc.Build(); var bpFacade = bp.Build(); dbg.CurrentThreadId = MockFrames.SingleThreaded0.First().ThreadId; tt.WithFrames(MockFrames.SingleThreaded0); sc.WithUpsertFrames(() => { }); var indexMethod = new IndexMethod { DebugEngineProxy = dbgEngProxy, TimeTravelFacade = timeTravelFacade, ServerClient = serverClient, BreakpointFacade = bpFacade }; indexMethod.ProcessInternal(new Position(0, 0), MockFrames.SingleThreaded0.Max(x => x.Position), new IndexOptions()); sc.Mock.Verify(client => client.UpsertFrames( It.Is <IEnumerable <Frame> >(frames => frames.SequenceEqual(MockFrames.SingleThreaded0)))); }
public void Identify_Correct_Starting_Position() { // Arrange var options = new IndexOptions { Start = new Position(0x35, 0x1) }; var dbg = new DebugEngineProxyBuilder(); var indexMethod = new IndexMethod(); indexMethod.DebugEngineProxy = dbg.Build(); var builder = new TimeTravelFacadeBuilder(dbg); builder.WithGetStartingPosition(new Position(0x35, 0)); indexMethod.TimeTravelFacade = builder.Build(); // Act var startingPosition = indexMethod.GetStartingPosition(options); // Assert startingPosition.Should().Be(new Position(0x35, 1), "35:1 means that the high portion is 35 and the low portion is 1"); }