コード例 #1
0
        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"));
        }
コード例 #2
0
        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"));
        }
コード例 #3
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"));
        }