public void Extract_The_Correct_String_Value()
        {
            // arrange
            var extractor = new StringExtractor();
            var builder   = new ClrObjectBuilder();

            builder
            .WithType("System.String")
            .WithAddress(0x1234)
            .WithSize(100)
            .WithSimpleValue("Duke the corgi");
            var runtimeBuilder = new ClrRuntimeBuilder();
            var heapBuilder    = new ClrHeapBuilder();

            heapBuilder.WithGetGeneration(2);
            runtimeBuilder.WithHeap(heapBuilder.Build());
            var runtime = runtimeBuilder.Build();
            var built   = builder.Build();

            // act
            var result = (StringDumpObject)extractor.Extract(built, runtime);

            // assert
            result.Address.Should().Be(0x1234);
            result.Size.Should().Be(100);
            result.Gen.Should().Be(2);
            result.FullTypeName.Should().Be("System.String");
            result.Value.Should().Be("Duke the corgi");
        }
Esempio n. 2
0
        public void Correctly_Extract_Objects()
        {
            var type = new ClrTypeBuilder()
                       .WithName("Duke")
                       .WithGetSize(42)
                       .Build();

            var obj = new ClrObjectBuilder()
                      .WithAddress(0x100)
                      .WithSize(42)
                      .WithType(type)
                      .Build();

            var heap = new ClrHeapBuilder()
                       .WithGetGeneration(1)
                       .WithGetObjectType(obj.Type)
                       .Build();

            var rt = new ClrRuntimeBuilder()
                     .WithHeap(heap)
                     .Build();



            // arrange
            var extractor = new DefaultObjectExtractor();

            // act
            var res  = extractor.Extract(obj, rt);
            var res2 = extractor.Extract(0x100, rt);

            // assert
            res.Address.Should().Be(0x100);
            res.Gen.Should().Be(1);
            res.Size.Should().Be(42);
            res.FullTypeName.Should().Be("Duke");

            res2.Address.Should().Be(0x100);
            res2.Gen.Should().Be(1);
            res2.Size.Should().Be(42);
            res2.FullTypeName.Should().Be("Duke");
        }
Esempio n. 3
0
        public void Return_The_Correct_Values()
        {
            // arrange
            var startTime   = DateTime.Now;
            var moduleInfo  = new Mock <IModuleInfo>();
            var moduleInfos = new[] { moduleInfo.Object };
            var locator     = new SymbolLocatorBuilder()
                              .WithSymbolCache(@"c:\cache")
                              .WithSymbolPath(@"c:\symbols")
                              .Build();

            var heap = new ClrHeapBuilder()
                       .WithTotalSize(0x100)
                       .Build();

            var pool = new ClrThreadPoolBuilder()
                       .WithCpuUtilization(85)
                       .WithFreeCompletionPortCount(90)
                       .WithIdleThreads(11)
                       .WithMaxCompletionPorts(20)
                       .WithMaxFreeCompletionPorts(50)
                       .WithMaxThreads(100)
                       .WithMinCompletionPorts(8)
                       .WithMinThreads(12)
                       .WithRunningThreads(22)
                       .WithTotalThreads(123)
                       .Build();

            var clrVersion = new Mock <IClrInfo>();
            var runtime    = new ClrRuntimeBuilder()
                             .WithHeap(heap)
                             .WithHeapCount(3)
                             .WithServerGc(true)
                             .WithThreadPool(pool)
                             .Build();

            var dataReader = new Mock <IDataReader>();
            var dataTarget = new DataTargetBuilder()
                             .WithArchitecture(Architecture.Amd64)
                             .WithClrVersions(new List <IClrInfo>
            {
                clrVersion.Object
            })
                             .WithDataReader(dataReader.Object)
                             .WithIsMinidump(true)
                             .WithPointerSize(4)
                             .WithSymbolLocator(locator)
                             .WithEnumerateModules(moduleInfos)
                             .Build();
            var fileInfo = new FileInfo(@"C:\dumps\crash.dmp");
            var sut      = new DumpInformationRepository(dataTarget, runtime, fileInfo);

            // act
            // assert
            sut.CpuUtilization.Should().Be(85);
            sut.DumpFile.Should().Be(fileInfo);
            sut.HeapCount.Should().Be(3);
            sut.IsMiniDump.Should().Be(true);
            sut.IsServerGc.Should().Be(true);
            sut.MaxNumberFreeIoCompletionPorts.Should().Be(50);
            sut.MaxNumberIoCompletionPorts.Should().Be(20);
            sut.MaxThreads.Should().Be(100);
            sut.MinNumberIoCompletionPorts.Should().Be(8);
            sut.MinThreads.Should().Be(12);
            sut.NumberFreeIoCompletionPorts.Should().Be(90);
            sut.NumberIdleThreads.Should().Be(11);
            sut.NumRunningThreads.Should().Be(22);
            sut.ModuleInfos.SequenceEqual(moduleInfos).Should().BeTrue();
            sut.SymbolCache.Should().Be(@"c:\cache");
            sut.SymbolPath.Should().Be(@"c:\symbols");
            sut.TotalHeapSize.Should().Be(0x100);
            sut.TotalThreads.Should().Be(123);
            sut.StartTimeUtc.Should().BeCloseTo(startTime.ToUniversalTime(), 1000);
        }