public void Ctor_CapNames_ReturnsDefaultValues()
        {
            var r = new DerivedRegex(@"(?<Name>\w*)");

            Assert.Null(r.Caps);

            IDictionary capNames = r.CapNames;

            Assert.NotNull(capNames);
            Assert.Same(capNames, r.CapNames);
            Assert.True(capNames.Contains("Name"));

            AssertExtensions.Throws <ArgumentNullException>("value", () => r.Caps     = null);
            AssertExtensions.Throws <ArgumentNullException>("value", () => r.CapNames = null);

            r.Caps = new Dictionary <string, string>();
            Assert.IsType <Hashtable>(r.Caps);

            r.CapNames = new Dictionary <string, string>();
            Assert.IsType <Hashtable>(r.CapNames);

            var newHashtable = new Hashtable();

            r.CapNames = newHashtable;
            Assert.Same(newHashtable, r.CapNames);

            r.Caps = newHashtable;
            Assert.Same(newHashtable, r.Caps);
        }
Exemple #2
0
        public void InitializeReferences_OnlyInvokedOnce()
        {
            var r = new DerivedRegex();

            r.InitializeReferences();
            Assert.Throws <NotSupportedException>(() => r.InitializeReferences());
        }
Exemple #3
0
        public void InitializeReferences_OnlyInvokedOnce()
        {
            var r = new DerivedRegex();

            r.InitializeReferences();
            if (PlatformDetection.IsNetFramework)
            {
                Assert.Throws <NotSupportedException>(() => r.InitializeReferences());
            }
            else
            {
                // As of .NET 7, this method is a nop.
                r.InitializeReferences();
            }
        }