//
//
//
//
// $Revision$
//
using System;
using ICSharpCode.AvalonEdit.CodeCompletion;
using ICSharpCode.RubyBinding;
using ICSharpCode.SharpDevelop;
using NUnit.Framework;
namespace RubyBinding.Tests.Console
{
[TestFixture]
public class EmptyStringCodeCompletionTestFixture
{
MockMemberProvider memberProvider;
RubyConsoleCompletionDataProvider completionProvider;
[SetUp]
public void Init()
{
memberProvider = new MockMemberProvider();
completionProvider = new RubyConsoleCompletionDataProvider(memberProvider);
}
///
/// If the user presses the dot character without having any text in the command line then
/// a SyntaxException occurs if the code calls IronRuby's CommandLine.GetMemberNames. So this
/// tests ensures that if the string is empty then this method is not called.
///
[Test]
public void NoCompletionItemsGeneratedForEmptyString()
{
memberProvider.SetMemberNames(new string[] {"a"});
memberProvider.SetGlobals(new string[] {"a"});
Assert.AreEqual(0, completionProvider.GenerateCompletionData(">>> ").Length);
}
///
/// Checks that the GenerateCompletionData method catches any exceptions thrown by the
/// IMemberProvider implementation. This can occur when an invalid name is passed to
/// IronRuby's CommandLine.GetMemberNames or GetGlobals. For example, an UnboundNameException is
/// thrown if an unknown name is used.
///
[Test]
public void NoCompletionItemsGeneratedWhenExceptionThrown()
{
memberProvider.ExceptionToThrow = new ApplicationException("Should not be thrown");
Assert.AreEqual(0, completionProvider.GenerateCompletionData(">>> a").Length);
}
[Test]
public void UnderscoresPassedToGetMemberNames()
{
completionProvider.GenerateCompletionData(">>> __builtins__");
Assert.AreEqual("__builtins__", memberProvider.GetMemberNamesParameter);
}
}
}