Пример #1
0
        public void Return_The_Correct_AppDomains()
        {
            // arrange
            var module = new DumpModule();
            var domain = new DumpAppDomain();

            // act
            module.AppDomainsInternal.Add(domain);

            // assert
            module.AppDomains.Should().HaveCount(1);
        }
Пример #2
0
        public void Add_A_AppDomain_Only_Once()
        {
            // arrange
            var sut       = new DumpModule(new DumpModuleKey(0, ""));
            var appDomain = new DumpAppDomain();

            // act
            sut.AddAppDomain(appDomain);
            sut.AddAppDomain(appDomain);

            // assert
            sut.AppDomains.Should().HaveCount(1);
        }
Пример #3
0
        public void Add_A_Handle_Only_Once()
        {
            // arrange
            var sut    = new DumpAppDomain();
            var handle = new DumpHandle();

            // act
            sut.AddHandle(handle);
            sut.AddHandle(handle);

            // assert
            sut.Handles.Should().HaveCount(1);
        }
Пример #4
0
        public void Exhibit_Entity_Equality()
        {
            // arrange
            var a = new DumpAppDomain()
            {
                Address = 0,
                Name    = "Something"
            };
            var b = new DumpAppDomain
            {
                Address = 0,
                Name    = "Something Else"
            };
            var c = new DumpAppDomain
            {
                Address = 1,
                Name    = "Something"
            };

            // act
            // assert
            a.GetHashCode().Should().Be(b.GetHashCode());
            a.GetHashCode().Should().NotBe(c.GetHashCode());

            a.Equals(a).Should().BeTrue();
            a.Equals(b).Should().BeTrue();
            a.Equals(c).Should().BeFalse();
            a.Equals(null).Should().BeFalse();
            a.Equals("").Should().BeFalse();
            a.CompareTo(a).Should().Be(0);
            a.CompareTo(b).Should().Be(0);
            a.CompareTo(c).Should().Be(-1);
            a.CompareTo(null).Should().Be(1);
            a.Equals((object)a).Should().BeTrue();
            a.Equals((object)b).Should().BeTrue();
            a.Equals((object)c).Should().BeFalse();
            a.Equals((object)null).Should().BeFalse();
            a.CompareTo((object)a).Should().Be(0);
            a.CompareTo((object)b).Should().Be(0);
            a.CompareTo((object)c).Should().Be(-1);
            a.CompareTo((object)null).Should().Be(1);
            (a < b).Should().BeFalse();
            (a <= b).Should().BeTrue();
            (c > a).Should().BeTrue();
            (c >= a).Should().BeTrue();
            Action throws = () => a.CompareTo("");

            throws.Should().Throw <ArgumentException>();
        }
Пример #5
0
        public void Correctly_Add_Modules()
        {
            // arrange
            var appDomain = new DumpAppDomain();
            var module    = new DumpModule()
            {
                Key = new DumpModuleKey(0x10, "")
            };

            // act
            appDomain.AddModule(module);

            // assert
            appDomain.LoadedModules.Should().HaveCount(1);
        }
Пример #6
0
        /// <summary>
        ///     Creates the application domains.
        /// </summary>
        public void CreateAppDomains()
        {
            AppDomains = new Dictionary <ulong, DumpAppDomain>();
            AppDomainToModuleMapping = new Dictionary <ulong, IList <DumpModuleKey> >();
            var runtimeAppDomains = Runtime.AppDomains.Concat(new[] { Runtime.SharedDomain, Runtime.SystemDomain });

            foreach (var domain in runtimeAppDomains)
            {
                var dumpAppDomain = new DumpAppDomain
                {
                    Address         = domain.Address,
                    Name            = domain.Name,
                    ApplicationBase = domain.ApplicationBase,
                    ConfigFile      = domain.ConfigurationFile
                };
                AppDomains.Add(dumpAppDomain.Address, dumpAppDomain);
                AppDomainToModuleMapping.Add(domain.Address, domain.Modules.Select(x => x.ToKeyType()).ToList());
            }
        }
Пример #7
0
        public void Return_The_Correct_Value()
        {
            // arrange
            var a = new DumpAppDomain()
            {
                Address = 0
            };
            var b = new DumpAppDomain()
            {
                Address = 1
            };
            var appDomains = new Dictionary <ulong, DumpAppDomain>
            {
                [a.Address] = a,
                [b.Address] = b
            };
            var sut = new DumpAppDomainRepository(appDomains);

            // act
            // assert
            sut.Get(0).Should().Be(a);
            sut.AppDomains.Should().HaveCount(2);
        }