public static void GenericTypeIsTest(Action <bool, string> assertTrue) { if (dotMemoryApi.IsEnabled) { dotMemoryApi.CollectAllocations = true; } var checkpoint1 = dotMemory.Check(); var garbage = Create <AllocatableTraffic>(AllocatableTraffic.Count); if (garbage.Length < AllocatableTraffic.Count) { throw new InvalidOperationException(); // preventing optimizations } TypePropertyTestProgram.Execute(() => { dotMemory.Check(_ => { var allocatedObjects = _.GetTrafficFrom(checkpoint1) .Where(w => w.Assembly.Is(TypePropertyTestProgram.Generic.Type.Assembly) & w.Type.Is(TypePropertyTestProgram.Generic.Type)) .AllocatedMemory; assertTrue(allocatedObjects.ObjectsCount == TypePropertyTestProgram.Generic.Count, string.Format(AssertTemplates.AssertObjectsCountTemplate, TypePropertyTestProgram.Generic.Count, allocatedObjects.ObjectsCount)); assertTrue(allocatedObjects.SizeInBytes > 0, string.Format(AssertTemplates.AssertSizeInBytesTemplate, allocatedObjects.SizeInBytes)); }); }, () => { } ); }
public static void IsTest(Action <ObjectSet> assertAction) { TypePropertyTestProgram.Execute(() => { dotMemory.Check(memory => { var objectSet = memory.GetObjects(where => where.Type.Is <TypePropertyTestProgram.One>()); Console.WriteLine(objectSet); assertAction(objectSet); }); }); }
public static void GenericTypeIstest(Action <bool, string> assertTrue) { TypePropertyTestProgram.Execute(() => { dotMemory.Check(memory => { var objectSet = memory.GetObjects(_ => _.Assembly.Is(TypePropertyTestProgram.Generic.Type.Assembly) & _.Type.Is(TypePropertyTestProgram.Generic.Type)); assertTrue(objectSet.ObjectsCount == TypePropertyTestProgram.Generic.Count, string.Format(AssertTemplates.AssertObjectsCountTemplate, TypePropertyTestProgram.Generic.Count, objectSet.ObjectsCount)); assertTrue(objectSet.SizeInBytes > 0, string.Format(AssertTemplates.AssertSizeInBytesTemplate, objectSet.SizeInBytes)); }); }, () => { } ); }
public static void TypeIsTest(Action <bool, string> assertTrue) { TypePropertyTestProgram.Execute(() => { dotMemory.Check(memory => { var objectSet = memory.GetObjects(where => where.Type.Is <TypePropertyTestProgram.One>()); Console.WriteLine(objectSet); assertTrue(objectSet.ObjectsCount == TypePropertyTestProgram.One.Count, string.Format(AssertTemplates.AssertObjectsCountTemplate, TypePropertyTestProgram.One.Count, objectSet.ObjectsCount)); assertTrue(objectSet.SizeInBytes > 0, string.Format(AssertTemplates.AssertSizeInBytesTemplate, objectSet.SizeInBytes)); }); }, () => { } ); }
public static void TypeIsNotListTest(Action <bool, string> assertTrue) { TypePropertyTestProgram.Execute(() => { dotMemory.Check(memory => { var objectSet = memory.GetObjects(where => where.Type.IsNot(typeof(TypePropertyTestProgram.One), typeof(TypePropertyTestProgram.Two))); var expectedCount = memory.ObjectsCount - TypePropertyTestProgram.One.Count - TypePropertyTestProgram.Two.Count; Console.WriteLine(objectSet); assertTrue(objectSet.ObjectsCount == expectedCount, string.Format(AssertTemplates.AssertObjectsCountTemplate, expectedCount, objectSet.ObjectsCount)); assertTrue(objectSet.SizeInBytes > 0, string.Format(AssertTemplates.AssertSizeInBytesTemplate, objectSet.SizeInBytes)); }); }, () => { } ); }