public void UseNameThrowsWhenNameUsed()
        {
            var _naming = new SyntaxerNamingContext(null);

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

            Assert.Throws<SyntaxerNameAlreadyReservedException>(() =>
                {
                    SyntaxerNamingContextExtensions.UseName(
                        _naming,
                        "name");
                });
        }
Exemplo n.º 2
0
        public void CanUseNameOnEmptyContextAndCanMethodsReturnAsExpected()
        {
            var _naming = new SyntaxerNamingContext(null);

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

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

            Assert.False(_naming.CanForbidName("name"));
            Assert.False(_naming.CanUseName("name"));
        }
Exemplo n.º 3
0
        public void CanUseNameForbiddenInUpperScopeAndCanMethodsReturnAsExpected()
        {
            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.TryUseName("name"));

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

            Assert.False(_naming.CanForbidName("name"));
            Assert.False(_naming.CanUseName("name"));
        }
Exemplo n.º 4
0
        public void CanUseNameOnEmptyContext()
        {
            var _naming = new SyntaxerNamingContext(null);

            Assert.True(_naming.TryUseName("name"));
        }
Exemplo n.º 5
0
        public void CanUseDifferentNames()
        {
            var _naming = new SyntaxerNamingContext(null);

            Assert.True(_naming.TryUseName("name"));
            Assert.True(_naming.TryUseName("Name"));
            Assert.True(_naming.TryUseName("NAME"));
            Assert.True(_naming.TryUseName("_name"));
            Assert.True(_naming.TryUseName(" name"));
            Assert.True(_naming.TryUseName("name "));
            Assert.True(_naming.TryUseName("_"));
            Assert.True(_naming.TryUseName(""));
            Assert.True(_naming.TryUseName(" "));
            Assert.True(_naming.TryUseName("@"));
            Assert.True(_naming.TryUseName("!"));
            Assert.True(_naming.TryUseName("o"));
            Assert.True(_naming.TryUseName("ö"));
            Assert.True(_naming.TryUseName("ø"));
            Assert.True(_naming.TryUseName("\r"));
            Assert.True(_naming.TryUseName("\n"));
            Assert.True(_naming.TryUseName("\r\n"));
            Assert.True(_naming.TryUseName("\n\r"));
        }
Exemplo n.º 6
0
        public void CanUseNameForbiddenInUpperScope()
        {
            var _upperScopeNaming = new SyntaxerNamingContext(null);
            Assert.True(_upperScopeNaming.TryForbidName("name"));

            var _naming = new SyntaxerNamingContext(_upperScopeNaming);
            Assert.True(_naming.TryUseName("name"));
        }
Exemplo n.º 7
0
        public void CannotUseSameNameTwice()
        {
            var _naming = new SyntaxerNamingContext(null);

            Assert.True(_naming.TryUseName("name"));
            Assert.False(_naming.TryUseName("name"));
        }
Exemplo n.º 8
0
        public void CannotUseNameUsedInUpperScope()
        {
            var _upperScopeNaming = new SyntaxerNamingContext(null);
            Assert.True(_upperScopeNaming.TryUseName("name"));

            var _naming = new SyntaxerNamingContext(_upperScopeNaming);
            Assert.False(_naming.TryUseName("name"));
        }
Exemplo n.º 9
0
        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"));
        }
Exemplo n.º 10
0
        public void CannotUseNameForbiddenInLowerScope()
        {
            var _naming = new SyntaxerNamingContext(null);
            var _lowerScopeNaming = new SyntaxerNamingContext(_naming);

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

            Assert.False(_naming.TryUseName("name"));
        }
Exemplo n.º 11
0
        public void CannotUseForbiddenName()
        {
            var _naming = new SyntaxerNamingContext(null);

            Assert.True(_naming.TryForbidName("name"));
            Assert.False(_naming.TryUseName("name"));
        }