public void TraceResultShouldContainThreeThreads() { ITracer tracer = new MethodTracer(); MultiThreadingClass multiThreadingClass = new MultiThreadingClass(tracer); multiThreadingClass.RunThreeThreads(); TraceResult traceResult = tracer.GetTraceResult(); Assert.Equal(3, traceResult.Threads.Count()); }
public void FirstMethodResultShouldContainOneInnerMethod() { ITracer tracer = new MethodTracer(); ClassWithSeveralMethods classWithSeveralMethods = new ClassWithSeveralMethods(tracer); classWithSeveralMethods.MethodWithInnerMethods(); TraceResult traceResult = tracer.GetTraceResult(); Assert.Single(traceResult.Threads[0].Methods[0].Methods); }
public void MethodTimeShouldBeMoreOrEqualThanSleepTime() { ITracer tracer = new MethodTracer(); ClassWithSleepMethod classWithSleepMethod = new ClassWithSleepMethod(tracer); classWithSleepMethod.MethodWithSleep(); TraceResult traceResult = tracer.GetTraceResult(); Assert.True(traceResult.Threads[0].Methods[0].Time >= 100); }
public void ThreadTimeShouldEqualSumOfHighestLevelMethodsTimes() { ITracer tracer = new MethodTracer(); ClassWithSeveralMethods classWithSeveralMethods = new ClassWithSeveralMethods(tracer); classWithSeveralMethods.MethodWithInnerMethods(); TraceResult traceResult = tracer.GetTraceResult(); Assert.Equal(traceResult.Threads[0].Time, traceResult.Threads[0].Methods.Select(method => method.Time).Sum()); }
public void TracerShouldTraceTwoMethodsOnHighestLevel() { ITracer tracer = new MethodTracer(); ClassWithSeveralMethods classWithSeveralMethods = new ClassWithSeveralMethods(tracer); classWithSeveralMethods.MethodWithInnerMethods(); TraceResult traceResult = tracer.GetTraceResult(); Assert.Equal(2, traceResult.Threads[0].Methods.Count); }
public void ShouldReturnCorrectThreadId() { ITracer tracer = new MethodTracer(); ClassWithSleepMethod classWithSleepMethod = new ClassWithSleepMethod(tracer); int threadId = Thread.CurrentThread.ManagedThreadId; classWithSleepMethod.MethodWithSleep(); TraceResult traceResult = tracer.GetTraceResult(); Assert.Equal(threadId, traceResult.Threads[0].Id); }
public void TestMethodTraceResult() { SetUp(); _methodTracer.StartTrace(ClassName, MethodName); _methodTracer.StartTrace(InnerClassName, InnerMethodName); _methodTracer.StopTrace(); _methodTracer.StopTrace(); var methodTraceResult = _methodTracer.GetTraceResult(); Assert.Equal(ClassName, methodTraceResult.ClassName); Assert.Equal(MethodName, methodTraceResult.MethodName); var innerMethodTraceResult = methodTraceResult.InnerMethodTraceResults[0]; Assert.Equal(InnerClassName, innerMethodTraceResult.ClassName); Assert.Equal(InnerMethodName, innerMethodTraceResult.MethodName); }
static void Main(string[] args) { ITracer methodTracer = new MethodTracer(); BackgroundTestStarter testStarter = new BackgroundTestStarter(methodTracer); testStarter.StartTest(); TraceResult traceResult = methodTracer.GetTraceResult(); IWriter consoleWriter = new ConsoleWriter(); IWriter fileWriter = new FileWriter("out.txt"); ISerializer serializer = new JSONSerializer(); string serializedResult = serializer.Serizlize(traceResult); consoleWriter.Write(serializedResult); fileWriter.Write(serializedResult); }