6 changed files with 125 additions and 241 deletions
@ -1,140 +1,107 @@ |
|||||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
//
|
|
||||||
//using System;
|
using System; |
||||||
//using ICSharpCode.PackageManagement.EnvDTE;
|
using System.Linq; |
||||||
//using ICSharpCode.SharpDevelop.Dom;
|
using ICSharpCode.NRefactory.TypeSystem; |
||||||
//using NUnit.Framework;
|
using ICSharpCode.PackageManagement.EnvDTE; |
||||||
//using PackageManagement.Tests.Helpers;
|
using ICSharpCode.SharpDevelop.Dom; |
||||||
//using Rhino.Mocks;
|
using NUnit.Framework; |
||||||
//
|
using PackageManagement.Tests.Helpers; |
||||||
//namespace PackageManagement.Tests.EnvDTE
|
using Rhino.Mocks; |
||||||
//{
|
|
||||||
// [TestFixture]
|
namespace PackageManagement.Tests.EnvDTE |
||||||
// public class CodeVariableTests
|
{ |
||||||
// {
|
[TestFixture] |
||||||
// CodeVariable codeVariable;
|
public class CodeVariableTests : CodeModelTestBase |
||||||
// FieldHelper helper;
|
{ |
||||||
//
|
CodeVariable codeVariable; |
||||||
// [SetUp]
|
|
||||||
// public void Init()
|
void CreateCodeVariable(string code) |
||||||
// {
|
{ |
||||||
// helper = new FieldHelper();
|
AddCodeFile("class.cs", code); |
||||||
// }
|
ITypeDefinition typeDefinition = assemblyModel.TopLevelTypeDefinitions.Single().Resolve(); |
||||||
//
|
codeVariable = new CodeVariable(codeModelContext, typeDefinition.Fields.First()); |
||||||
// void CreatePublicVariable(string name)
|
} |
||||||
// {
|
|
||||||
// helper.CreatePublicField(name);
|
[Test] |
||||||
// CreateVariable();
|
public void Access_PublicVariable_ReturnsPublic() |
||||||
// }
|
{ |
||||||
//
|
CreateCodeVariable( |
||||||
// void CreatePrivateVariable(string name)
|
"public class MyClass {\r\n" + |
||||||
// {
|
" public int MyVariable;\r\n" + |
||||||
// helper.CreatePrivateField(name);
|
"}"); |
||||||
// CreateVariable();
|
|
||||||
// }
|
global::EnvDTE.vsCMAccess access = codeVariable.Access; |
||||||
//
|
|
||||||
// void CreateVariable()
|
Assert.AreEqual(global::EnvDTE.vsCMAccess.vsCMAccessPublic, access); |
||||||
// {
|
} |
||||||
// codeVariable = new CodeVariable(helper.Field);
|
|
||||||
// }
|
[Test] |
||||||
//
|
public void Access_PrivateVariable_ReturnsPrivate() |
||||||
// void VariableStartsAtColumn(int column)
|
{ |
||||||
// {
|
CreateCodeVariable( |
||||||
// helper.VariableStartsAtColumn(column);
|
"public class MyClass {\r\n" + |
||||||
// }
|
" private int MyVariable;\r\n" + |
||||||
//
|
"}"); |
||||||
// void VariableStartsAtLine(int line)
|
|
||||||
// {
|
global::EnvDTE.vsCMAccess access = codeVariable.Access; |
||||||
// helper.VariableStartsAtLine(line);
|
|
||||||
// }
|
Assert.AreEqual(global::EnvDTE.vsCMAccess.vsCMAccessPrivate, access); |
||||||
//
|
} |
||||||
// void VariableEndsAtColumn(int column)
|
|
||||||
// {
|
[Test] |
||||||
// helper.VariableEndsAtColumn(column);
|
public void GetStartPoint_VariableStartsAtColumnOneOnLineTwo_ReturnsTextPointWithLineCharOffsetOneAndLineTwo() |
||||||
// }
|
{ |
||||||
//
|
CreateCodeVariable( |
||||||
// void VariableEndsAtLine(int line)
|
"public class Foo {\r\n" + |
||||||
// {
|
"int V;\r\n" + |
||||||
// helper.VariableEndsAtLine(line);
|
"}"); |
||||||
// }
|
|
||||||
//
|
global::EnvDTE.TextPoint point = codeVariable.GetStartPoint(); |
||||||
// [Test]
|
|
||||||
// public void Access_PublicVariable_ReturnsPublic()
|
Assert.AreEqual(1, point.LineCharOffset); |
||||||
// {
|
Assert.AreEqual(2, point.Line); |
||||||
// CreatePublicVariable("MyVariable");
|
} |
||||||
//
|
|
||||||
// global::EnvDTE.vsCMAccess access = codeVariable.Access;
|
[Test] |
||||||
//
|
public void GetEndPoint_VariableEndsAtColumnSevenOnLineTwo_ReturnsTextPointWithLineCharOffsetSevenOnLineTwo() |
||||||
// Assert.AreEqual(global::EnvDTE.vsCMAccess.vsCMAccessPublic, access);
|
{ |
||||||
// }
|
CreateCodeVariable( |
||||||
//
|
"public class Foo {\r\n" + |
||||||
// [Test]
|
"int V;\r\n" + |
||||||
// public void Access_PrivateVariable_ReturnsPrivate()
|
"}"); |
||||||
// {
|
|
||||||
// CreatePrivateVariable("MyVariable");
|
global::EnvDTE.TextPoint point = codeVariable.GetEndPoint(); |
||||||
//
|
|
||||||
// global::EnvDTE.vsCMAccess access = codeVariable.Access;
|
Assert.AreEqual(7, point.LineCharOffset); |
||||||
//
|
Assert.AreEqual(2, point.Line); |
||||||
// Assert.AreEqual(global::EnvDTE.vsCMAccess.vsCMAccessPrivate, access);
|
} |
||||||
// }
|
|
||||||
//
|
[Test] |
||||||
// [Test]
|
public void Kind_PublicVariable_ReturnsVariable() |
||||||
// public void GetStartPoint_VariableStartsAtColumn5_ReturnsTextPointWithLineCharOffset5()
|
{ |
||||||
// {
|
CreateCodeVariable( |
||||||
// CreatePublicVariable("MyVariable");
|
"public class MyClass {\r\n" + |
||||||
// VariableStartsAtColumn(5);
|
" private int MyVariable;\r\n" + |
||||||
//
|
"}"); |
||||||
// global::EnvDTE.TextPoint point = codeVariable.GetStartPoint();
|
|
||||||
// int offset = point.LineCharOffset;
|
global::EnvDTE.vsCMElement kind = codeVariable.Kind; |
||||||
//
|
|
||||||
// Assert.AreEqual(5, offset);
|
Assert.AreEqual(global::EnvDTE.vsCMElement.vsCMElementVariable, kind); |
||||||
// }
|
} |
||||||
//
|
|
||||||
// [Test]
|
[Test] |
||||||
// public void GetStartPoint_VariableStartsAtLine1_ReturnsTextPointWithLine1()
|
public void GetEndPoint_VariableHasSpaceBeforeSemiColon_ReturnsTextPointThatIncludesSemiColon() |
||||||
// {
|
{ |
||||||
// CreatePublicVariable("MyVariable");
|
CreateCodeVariable( |
||||||
// VariableStartsAtLine(1);
|
"public class Foo {\r\n" + |
||||||
//
|
"int V ;\r\n" + |
||||||
// global::EnvDTE.TextPoint point = codeVariable.GetStartPoint();
|
"}"); |
||||||
// int line = point.Line;
|
|
||||||
//
|
global::EnvDTE.TextPoint point = codeVariable.GetEndPoint(); |
||||||
// Assert.AreEqual(1, line);
|
|
||||||
// }
|
Assert.AreEqual(8, point.LineCharOffset); |
||||||
//
|
} |
||||||
// [Test]
|
} |
||||||
// public void GetEndPoint_VariableEndsAtColumn10_ReturnsTextPointWithLineCharOffset10()
|
} |
||||||
// {
|
|
||||||
// CreatePublicVariable("MyVariable");
|
|
||||||
// VariableEndsAtColumn(10);
|
|
||||||
//
|
|
||||||
// global::EnvDTE.TextPoint point = codeVariable.GetEndPoint();
|
|
||||||
// int offset = point.LineCharOffset;
|
|
||||||
//
|
|
||||||
// Assert.AreEqual(10, offset);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// [Test]
|
|
||||||
// public void GetEndPoint_VariableEndsAtLine2_ReturnsTextPointWithLine2()
|
|
||||||
// {
|
|
||||||
// CreatePublicVariable("MyVariable");
|
|
||||||
// VariableEndsAtLine(2);
|
|
||||||
//
|
|
||||||
// global::EnvDTE.TextPoint point = codeVariable.GetEndPoint();
|
|
||||||
// int line = point.Line;
|
|
||||||
//
|
|
||||||
// Assert.AreEqual(2, line);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// [Test]
|
|
||||||
// public void Kind_PublicVariable_ReturnsVariable()
|
|
||||||
// {
|
|
||||||
// CreatePublicVariable("MyVariable");
|
|
||||||
//
|
|
||||||
// global::EnvDTE.vsCMElement kind = codeVariable.Kind;
|
|
||||||
//
|
|
||||||
// Assert.AreEqual(global::EnvDTE.vsCMElement.vsCMElementVariable, kind);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
@ -1,75 +0,0 @@ |
|||||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
//
|
|
||||||
//using System;
|
|
||||||
//using ICSharpCode.PackageManagement;
|
|
||||||
//using ICSharpCode.SharpDevelop.Dom;
|
|
||||||
//using Rhino.Mocks;
|
|
||||||
//
|
|
||||||
//namespace PackageManagement.Tests.Helpers
|
|
||||||
//{
|
|
||||||
// public class FieldHelper
|
|
||||||
// {
|
|
||||||
// public IField Field;
|
|
||||||
// public ProjectContentHelper ProjectContentHelper = new ProjectContentHelper();
|
|
||||||
//
|
|
||||||
// /// <summary>
|
|
||||||
// /// Field name should include the class prefix (e.g. "Class1.MyField")
|
|
||||||
// /// </summary>
|
|
||||||
// public void CreateField(string fullyQualifiedName)
|
|
||||||
// {
|
|
||||||
// Field = MockRepository.GenerateMock<IField, IEntity>();
|
|
||||||
// Field.Stub(f => f.ProjectContent).Return(ProjectContentHelper.ProjectContent);
|
|
||||||
// Field.Stub(f => f.FullyQualifiedName).Return(fullyQualifiedName);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void CreatePublicField(string fullyQualifiedName)
|
|
||||||
// {
|
|
||||||
// CreateField(fullyQualifiedName);
|
|
||||||
// Field.Stub(f => f.IsPublic).Return(true);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void CreatePrivateField(string fullyQualifiedName)
|
|
||||||
// {
|
|
||||||
// CreateField(fullyQualifiedName);
|
|
||||||
// Field.Stub(f => f.IsPublic).Return(false);
|
|
||||||
// Field.Stub(f => f.IsPrivate).Return(true);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void SetRegion(DomRegion region)
|
|
||||||
// {
|
|
||||||
// Field.Stub(f => f.Region).Return(region);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void VariableStartsAtColumn(int column)
|
|
||||||
// {
|
|
||||||
// var region = new DomRegion(1, column);
|
|
||||||
// SetRegion(region);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void VariableStartsAtLine(int line)
|
|
||||||
// {
|
|
||||||
// var region = new DomRegion(line, 1);
|
|
||||||
// SetRegion(region);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void VariableEndsAtColumn(int column)
|
|
||||||
// {
|
|
||||||
// var region = new DomRegion(1, 1, 1, column);
|
|
||||||
// SetRegion(region);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void VariableEndsAtLine(int line)
|
|
||||||
// {
|
|
||||||
// var region = new DomRegion(1, 1, line, 1);
|
|
||||||
// SetRegion(region);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void SetCompilationUnitFileName(string fileName)
|
|
||||||
// {
|
|
||||||
// var helper = new CompilationUnitHelper();
|
|
||||||
// helper.SetFileName(fileName);
|
|
||||||
// Field.Stub(f => f.CompilationUnit).Return(helper.CompilationUnit);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
Loading…
Reference in new issue