public void Basic() { string result = CreateVisualBasicManifestResourceName.CreateManifestNameImpl ( @"f:\myproject\SubFolder\MyForm.resx", null, // Link file name true, null, // Root namespace null, null, StreamHelpers.StringToStream( @" Namespace Nested.TestNamespace Class TestClass End Class End Namespace "), null ); Assert.Equal("Nested.TestNamespace.TestClass", result); }
public void DependentWithEmbeddedCulture() { string result = CreateVisualBasicManifestResourceName.CreateManifestNameImpl ( @"f:\myproject\SubFolder\MyForm.fr-fr.resx", null, // Link file name true, "RootNamespace", // Root namespace null, null, StreamHelpers.StringToStream( @" Namespace Nested.TestNamespace Class TestClass End Class End Namespace "), null ); Assert.Equal("RootNamespace.Nested.TestNamespace.TestClass.fr-fr", result); }
/* * Method: AssertTokenize * * Tokenize a string ('source') and compare it to the expected set of tokens. * Also compare the source that is regenerated by concatenating all of the tokens * to 'expectedSource'. */ static private void AssertTokenize ( string source, string expectedSource, string expectedTokenKey, int expectedLastLineNumber ) { VisualBasicTokenizer tokens = new VisualBasicTokenizer ( StreamHelpers.StringToStream(source), false ); string results = ""; string tokenKey = ""; int lastLine = 0; bool syntaxError = false; foreach (Token t in tokens) { results += t.InnerText; lastLine = t.Line; if (!syntaxError) { // Its not really a file name, but GetExtension serves the purpose of getting the class name without // the namespace prepended. string tokenClass = t.ToString(); int pos = tokenClass.LastIndexOfAny(new char[] { '+', '.' }); if (t is VisualBasicTokenizer.LineTerminatorToken) { tokenKey += "eol"; } else if (t is WhitespaceToken) { tokenKey += "."; } else { tokenKey += tokenClass.Substring(pos + 1); tokenKey += "("; tokenKey += t.InnerText; tokenKey += ")"; } } if (t is SyntaxErrorToken) { // Stop processing after the first syntax error because // the order of tokens after this is an implementation detail and // shouldn't be encoded into the unit tests. syntaxError = true; } } tokenKey = tokenKey.Replace("Token", ""); if (expectedSource != results || expectedTokenKey != tokenKey) { Console.WriteLine(tokenKey); } Assert.Equal(expectedSource, results); Assert.Equal(expectedTokenKey, tokenKey); Assert.Equal(expectedLastLineNumber, lastLine); }