I am conducting a Proof of Concept (POC) to purchase of a license for my organization.
I have created a small POC I am able to traverse backward in rdi overlay not able to traverse forward
using System;
using System.Collections.Generic;
namespace ConsoleApp6
{
// Simple calculator class to add two integers
public class Adder
{
public int Add(int a, int b)
{
return a + b;
}
}
// Production classes: ClassOne ... ClassTen
public class ClassOne
{
public List<string> One(List<string> trace = null)
{
trace = trace ?? new List<string>();
trace.Add("ClassOne.One");
Two(trace);
return trace;
}
public void Two(List<string> trace)
{
trace.Add("ClassOne.Two");
Three(trace);
}
public void Three(List<string> trace)
{
trace.Add("ClassOne.Three");
new ClassTwo().One(trace);
}
}
public class ClassTwo
{
public List<string> One(List<string> trace = null)
{
trace = trace ?? new List<string>();
trace.Add("ClassTwo.One");
Two(trace);
return trace;
}
public void Two(List<string> trace)
{
trace.Add("ClassTwo.Two");
Three(trace);
}
public void Three(List<string> trace)
{
trace.Add("ClassTwo.Three");
new ClassThree().One(trace);
}
}
public class ClassThree
{
public List<string> One(List<string> trace = null)
{
trace = trace ?? new List<string>();
trace.Add("ClassThree.One");
Two(trace);
return trace;
}
public void Two(List<string> trace)
{
trace.Add("ClassThree.Two");
Three(trace);
}
public void Three(List<string> trace)
{
trace.Add("ClassThree.Three");
new ClassFour().One(trace);
}
}
public class ClassFour
{
public List<string> One(List<string> trace = null)
{
trace = trace ?? new List<string>();
trace.Add("ClassFour.One");
Two(trace);
return trace;
}
public void Two(List<string> trace)
{
trace.Add("ClassFour.Two");
Three(trace);
}
public void Three(List<string> trace)
{
trace.Add("ClassFour.Three");
new ClassFive().One(trace);
}
}
public class ClassFive
{
public List<string> One(List<string> trace = null)
{
trace = trace ?? new List<string>();
trace.Add("ClassFive.One");
Two(trace);
return trace;
}
public void Two(List<string> trace)
{
trace.Add("ClassFive.Two");
Three(trace);
}
public void Three(List<string> trace)
{
trace.Add("ClassFive.Three");
new ClassSix().One(trace);
}
}
public class ClassSix
{
public List<string> One(List<string> trace = null)
{
trace = trace ?? new List<string>();
trace.Add("ClassSix.One");
Two(trace);
return trace;
}
public void Two(List<string> trace)
{
trace.Add("ClassSix.Two");
Three(trace);
}
public void Three(List<string> trace)
{
trace.Add("ClassSix.Three");
new ClassSeven().One(trace);
}
}
public class ClassSeven
{
public List<string> One(List<string> trace = null)
{
trace = trace ?? new List<string>();
trace.Add("ClassSeven.One");
Two(trace);
return trace;
}
public void Two(List<string> trace)
{
trace.Add("ClassSeven.Two");
Three(trace);
}
public void Three(List<string> trace)
{
trace.Add("ClassSeven.Three");
new ClassEight().One(trace);
}
}
public class ClassEight
{
public List<string> One(List<string> trace = null)
{
trace = trace ?? new List<string>();
trace.Add("ClassEight.One");
Two(trace);
return trace;
}
public void Two(List<string> trace)
{
trace.Add("ClassEight.Two");
Three(trace);
}
public void Three(List<string> trace)
{
trace.Add("ClassEight.Three");
new ClassNine().One(trace);
}
}
public class ClassNine
{
public List<string> One(List<string> trace = null)
{
trace = trace ?? new List<string>();
trace.Add("ClassNine.One");
Two(trace);
return trace;
}
public void Two(List<string> trace)
{
trace.Add("ClassNine.Two");
Three(trace);
}
public void Three(List<string> trace)
{
trace.Add("ClassNine.Three");
new ClassTen().One(trace);
}
}
public class ClassTen
{
public List<string> One(List<string> trace = null)
{
trace = trace ?? new List<string>();
trace.Add("ClassTen.One");
Two(trace);
return trace;
}
public void Two(List<string> trace)
{
trace.Add("ClassTen.Two");
Three(trace);
}
public void Three(List<string> trace)
{
trace.Add("ClassTen.Three");
// End of chain.
}
}
internal class Program
{
static void Main(string[] args)
{
var adder = new Adder();
int result = adder.Add(2, 3);
Console.WriteLine("Result: " + result);
}
}
}
using ConsoleApp6;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic; // add this
namespace UnitTestProject1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void ClassOne_Three_AddsExpectedTraceAndCallsClassTwo()
{
// arrange
var trace = new List<string>();
var classOne = new ClassOne();
// act
classOne.Three(trace);
// assert
CollectionAssert.Contains(trace, "ClassOne.Three");
CollectionAssert.Contains(trace, "ClassTwo.One");
CollectionAssert.Contains(trace, "ClassTwo.Two");
CollectionAssert.Contains(trace, "ClassTwo.Three");
}
}
}
Please help regards
Vikram