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 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")); }
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")); }
public void CanUseNameOnEmptyContext() { var _naming = new SyntaxerNamingContext(null); Assert.True(_naming.TryUseName("name")); }
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")); }
public void CanUseNameForbiddenInUpperScope() { var _upperScopeNaming = new SyntaxerNamingContext(null); Assert.True(_upperScopeNaming.TryForbidName("name")); var _naming = new SyntaxerNamingContext(_upperScopeNaming); Assert.True(_naming.TryUseName("name")); }
public void CannotUseSameNameTwice() { var _naming = new SyntaxerNamingContext(null); Assert.True(_naming.TryUseName("name")); Assert.False(_naming.TryUseName("name")); }
public void CannotUseNameUsedInUpperScope() { var _upperScopeNaming = new SyntaxerNamingContext(null); Assert.True(_upperScopeNaming.TryUseName("name")); var _naming = new SyntaxerNamingContext(_upperScopeNaming); Assert.False(_naming.TryUseName("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")); }
public void CannotUseNameForbiddenInLowerScope() { var _naming = new SyntaxerNamingContext(null); var _lowerScopeNaming = new SyntaxerNamingContext(_naming); Assert.True(_lowerScopeNaming.TryForbidName("name")); Assert.False(_naming.TryUseName("name")); }
public void CannotUseForbiddenName() { var _naming = new SyntaxerNamingContext(null); Assert.True(_naming.TryForbidName("name")); Assert.False(_naming.TryUseName("name")); }