public void CanForbidNameForbiddenInUpperScopeAndCanMethodsReturnAsExpected()
        {
            var _upperScopeNaming = new SyntaxerNamingContext(null);

            Assert.True(_upperScopeNaming.CanForbidName("name"));
            Assert.True(_upperScopeNaming.CanUseName("name"));

            Assert.True(_upperScopeNaming.TryForbidName("name"));

            Assert.True(_upperScopeNaming.CanForbidName("name"));
            Assert.False(_upperScopeNaming.CanUseName("name"));

            var _naming = new SyntaxerNamingContext(_upperScopeNaming);

            Assert.True(_upperScopeNaming.CanForbidName("name"));
            Assert.False(_upperScopeNaming.CanUseName("name"));

            Assert.True(_naming.CanForbidName("name"));
            Assert.True(_naming.CanUseName("name"));

            Assert.True(_naming.TryForbidName("name"));

            Assert.True(_upperScopeNaming.CanForbidName("name"));
            Assert.False(_upperScopeNaming.CanUseName("name"));

            Assert.True(_naming.CanForbidName("name"));
            Assert.False(_naming.CanUseName("name"));
        }
        public void UseNameUsesName()
        {
            var _naming = new SyntaxerNamingContext(null);

            Assert.True(_naming.CanUseName("name"));

            SyntaxerNamingContextExtensions.UseName(
                _naming,
                "name");

            Assert.False(_naming.CanUseName("name"));
        }
        public void UseNameThrowsWhenNameUsed()
        {
            var _naming = new SyntaxerNamingContext(null);

            _naming.TryUseName("name");
            Assert.False(_naming.CanUseName("name"));

            Assert.Throws<SyntaxerNameAlreadyReservedException>(() =>
                {
                    SyntaxerNamingContextExtensions.UseName(
                        _naming,
                        "name");
                });
        }
        public void CanForbidNameOnEmptyContextAndCanMethodsReturnAsExpected()
        {
            var _naming = new SyntaxerNamingContext(null);

            Assert.True(_naming.CanUseName("name"));
            Assert.True(_naming.CanForbidName("name"));

            Assert.True(_naming.TryForbidName("name"));

            Assert.True(_naming.CanForbidName("name"));
            Assert.False(_naming.CanUseName("name"));
        }
        public void CannotUseNameUsedInLowerScopeAndCanMethodsReturnAsExpected()
        {
            var _naming = new SyntaxerNamingContext(null);
            var _lowerScopeNaming = new SyntaxerNamingContext(_naming);

            Assert.True(_naming.CanUseName("name"));
            Assert.True(_naming.CanForbidName("name"));

            Assert.True(_lowerScopeNaming.CanUseName("name"));
            Assert.True(_lowerScopeNaming.CanForbidName("name"));

            Assert.True(_lowerScopeNaming.TryUseName("name"));

            Assert.False(_naming.CanUseName("name"));
            Assert.True(_naming.CanForbidName("name"));

            Assert.False(_lowerScopeNaming.CanUseName("name"));
            Assert.False(_lowerScopeNaming.CanForbidName("name"));

            Assert.False(_naming.TryUseName("name"));

            Assert.False(_naming.CanUseName("name"));
            Assert.True(_naming.CanForbidName("name"));

            Assert.False(_lowerScopeNaming.CanUseName("name"));
            Assert.False(_lowerScopeNaming.CanForbidName("name"));
        }