public void Add_Tag_To_Specified_Frames() { var tagAccess = new TagAccess(); var builder = new ContextFactoryBuilder(); builder.WithFrame(new FrameEntity { PosHi = 0, PosLo = 0, ThreadId = 1 }).WithFrame(new FrameEntity { PosHi = 0, PosLo = 0, ThreadId = 2 }); tagAccess.ContextFactory = builder.Build(); tagAccess.AddTag("", new Position(0, 0), new[] { 1, 2 }, new Tag() { Title = "test tag" }); tagAccess.GetTags("", new Position(0, 0), 1).Single().Title.Should().Be("test tag"); tagAccess.GetTags("", new Position(0, 0), 2).Single().Title.Should().Be("test tag"); }
public void Find_Matching_Frames_Complex() { var frameAccess = new FrameAccess(); var builder = new ContextFactoryBuilder(); builder.WithFrame(new FrameEntity { PosHi = 0, PosLo = 0, ThreadId = 1, Rax = ((ulong)1).ToHexString() }).WithFrame(new FrameEntity { PosHi = 0, PosLo = 0, ThreadId = 2, Rax = ((ulong)2).ToHexString() }).WithFrame(new FrameEntity { PosHi = 1, PosLo = 0, ThreadId = 2, Rax = ((ulong)2).ToHexString() }).WithFrame(new FrameEntity { PosHi = 1, PosLo = 1, ThreadId = 2, Rax = ((ulong)1).ToHexString(), Rbx = ((ulong)2).ToHexString() }); frameAccess.ContextFactory = builder.Build(); var rax = new RegisterEqualsCriterion(Register.Rax, ((ulong)1).ToHexString()); var rbx = new RegisterEqualsCriterion(Register.Rbx, ((ulong)2).ToHexString()); var and = new AndCriterion(new[] { rax, rbx }); var or = new OrCriterion(new[] { rax, rbx }); var not = new NotCriterion(rax); var all = new OrCriterion(new ICriterion[] { not, rax }); var none = new AndCriterion(new ICriterion[] { not, rax }); var andAll = new AndCriterion(new ICriterion[] { and, all }); var andResults = frameAccess.Search("", and); var orResults = frameAccess.Search("", or); var notResults = frameAccess.Search("", not); var allResults = frameAccess.Search("", all); var noneResults = frameAccess.Search("", none); var andAllResults = frameAccess.Search("", andAll); andResults.Single().RegisterSet.Rax.Should().Be(1); andResults.Single().RegisterSet.Rbx.Should().Be(2); orResults.Should().HaveCount(2); notResults.Should().HaveCount(2); allResults.Should().HaveCount(4); noneResults.Should().HaveCount(0); andAllResults.Should().HaveCount(1); }
public void Find_Matching_Frames_By_Register_values() { var frameAccess = new FrameAccess(); var builder = new ContextFactoryBuilder(); builder.WithFrame(new FrameEntity { PosHi = 0, PosLo = 0, ThreadId = 1, Rax = ((ulong)0).ToHexString(), Rbx = ((ulong)1).ToHexString(), Rcx = ((ulong)2).ToHexString(), Rdx = ((ulong)3).ToHexString() }).WithFrame(new FrameEntity { PosHi = 0, PosLo = 0, ThreadId = 2, Rax = ((ulong)0).ToHexString(), Rbx = ((ulong)2).ToHexString(), Rcx = ((ulong)4).ToHexString(), Rdx = ((ulong)6).ToHexString() }).WithFrame(new FrameEntity { PosHi = 1, PosLo = 0, ThreadId = 2 }).WithFrame(new FrameEntity { PosHi = 1, PosLo = 1, ThreadId = 2, Rax = ((ulong)0).ToHexString(), Rbx = ((ulong)1).ToHexString(), Rcx = ((ulong)2).ToHexString(), Rdx = ((ulong)3).ToHexString() }); frameAccess.ContextFactory = builder.Build(); var between = new RegisterBetweenCriterion(Register.Rax, ((ulong)0).ToHexString(), ((ulong)2).ToHexString()); var notBetween = new NotCriterion(between); var betweenResults = frameAccess.Search("", between); var notBetweenResults = frameAccess.Search("", notBetween); betweenResults.Should().HaveCount(3); notBetweenResults.Should().HaveCount(1); }
public void Throw_If_Frame_Cant_Be_Found() { var access = new FrameAccess(); var builder = new ContextFactoryBuilder(); var frame = new FrameEntity { PosHi = 0, PosLo = 0, ThreadId = 1 }; builder.WithFrame(frame); access.ContextFactory = builder.Build(); Action throws = () => access.GetFrame("test", new Position(1, 0), 1); throws.Should().Throw <IndexOutOfRangeException>(); }
public void Get_The_Correct_Frame_If_One_Exists() { var access = new FrameAccess(); var builder = new ContextFactoryBuilder(); var frame = new FrameEntity { PosHi = 0, PosLo = 0, ThreadId = 1 }; builder.WithFrame(frame); access.ContextFactory = builder.Build(); var converter = new FrameDomainEntityConverter(); var domain = converter.ToDomain(frame, access.ContextFactory.GetContext("")); access.GetFrame("anyproject", new Position(0, 0), 1).Should().Be(domain); }
public void Find_Matching_Frames_When_Searched_For_Basic() { var frameAccess = new FrameAccess(); var builder = new ContextFactoryBuilder(); builder.WithFrame(new FrameEntity { PosHi = 0, PosLo = 0, ThreadId = 1, Rax = ((ulong)1).ToHexString() }).WithFrame(new FrameEntity { PosHi = 0, PosLo = 0, ThreadId = 2, Rax = ((ulong)2).ToHexString() }); frameAccess.ContextFactory = builder.Build(); var results = frameAccess.Search("", new RegisterEqualsCriterion(Register.Rax, ((ulong)1).ToHexString())); results.Single().RegisterSet.Rax.Should().Be(1); }
public void Create_The_Correct_Expression_Tree_For_Or() { var visitor = new FrameCriterionVisitor(); var criteria1 = new RegisterEqualsCriterion(Register.Rax, ((ulong)0).ToHexString()); var criteria2 = new RegisterEqualsCriterion(Register.Rbx, ((ulong)1).ToHexString()); var and = new OrCriterion(new[] { criteria1, criteria2 }); var f = visitor.Visit(and); var builder = new ContextFactoryBuilder(); var frame = new FrameEntity { Rax = ((ulong)0).ToHexString(), Rbx = ((ulong)1).ToHexString() }; var frame2 = new FrameEntity { Rax = ((ulong)1).ToHexString(), Rbx = ((ulong)1).ToHexString() }; builder.WithFrame(frame).WithFrame(frame2); var method = ((FramePredicateExpression)f).Compile(); new[] { frame, frame2 }.Where(x => method(x)).SequenceEqual(new[] { frame, frame2 }).Should().BeTrue(); }