6 changed files with 125 additions and 241 deletions
@ -1,140 +1,107 @@
@@ -1,140 +1,107 @@
|
||||
//// 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.EnvDTE;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using NUnit.Framework;
|
||||
//using PackageManagement.Tests.Helpers;
|
||||
//using Rhino.Mocks;
|
||||
//
|
||||
//namespace PackageManagement.Tests.EnvDTE
|
||||
//{
|
||||
// [TestFixture]
|
||||
// public class CodeVariableTests
|
||||
// {
|
||||
// CodeVariable codeVariable;
|
||||
// FieldHelper helper;
|
||||
//
|
||||
// [SetUp]
|
||||
// public void Init()
|
||||
// {
|
||||
// helper = new FieldHelper();
|
||||
// }
|
||||
//
|
||||
// void CreatePublicVariable(string name)
|
||||
// {
|
||||
// helper.CreatePublicField(name);
|
||||
// CreateVariable();
|
||||
// }
|
||||
//
|
||||
// void CreatePrivateVariable(string name)
|
||||
// {
|
||||
// helper.CreatePrivateField(name);
|
||||
// CreateVariable();
|
||||
// }
|
||||
//
|
||||
// void CreateVariable()
|
||||
// {
|
||||
// codeVariable = new CodeVariable(helper.Field);
|
||||
// }
|
||||
//
|
||||
// void VariableStartsAtColumn(int column)
|
||||
// {
|
||||
// helper.VariableStartsAtColumn(column);
|
||||
// }
|
||||
//
|
||||
// void VariableStartsAtLine(int line)
|
||||
// {
|
||||
// helper.VariableStartsAtLine(line);
|
||||
// }
|
||||
//
|
||||
// void VariableEndsAtColumn(int column)
|
||||
// {
|
||||
// helper.VariableEndsAtColumn(column);
|
||||
// }
|
||||
//
|
||||
// void VariableEndsAtLine(int line)
|
||||
// {
|
||||
// helper.VariableEndsAtLine(line);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Access_PublicVariable_ReturnsPublic()
|
||||
// {
|
||||
// CreatePublicVariable("MyVariable");
|
||||
//
|
||||
// global::EnvDTE.vsCMAccess access = codeVariable.Access;
|
||||
//
|
||||
// Assert.AreEqual(global::EnvDTE.vsCMAccess.vsCMAccessPublic, access);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void Access_PrivateVariable_ReturnsPrivate()
|
||||
// {
|
||||
// CreatePrivateVariable("MyVariable");
|
||||
//
|
||||
// global::EnvDTE.vsCMAccess access = codeVariable.Access;
|
||||
//
|
||||
// Assert.AreEqual(global::EnvDTE.vsCMAccess.vsCMAccessPrivate, access);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetStartPoint_VariableStartsAtColumn5_ReturnsTextPointWithLineCharOffset5()
|
||||
// {
|
||||
// CreatePublicVariable("MyVariable");
|
||||
// VariableStartsAtColumn(5);
|
||||
//
|
||||
// global::EnvDTE.TextPoint point = codeVariable.GetStartPoint();
|
||||
// int offset = point.LineCharOffset;
|
||||
//
|
||||
// Assert.AreEqual(5, offset);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetStartPoint_VariableStartsAtLine1_ReturnsTextPointWithLine1()
|
||||
// {
|
||||
// CreatePublicVariable("MyVariable");
|
||||
// VariableStartsAtLine(1);
|
||||
//
|
||||
// global::EnvDTE.TextPoint point = codeVariable.GetStartPoint();
|
||||
// int line = point.Line;
|
||||
//
|
||||
// Assert.AreEqual(1, line);
|
||||
// }
|
||||
//
|
||||
// [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);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// 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 System.Linq; |
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
using ICSharpCode.PackageManagement.EnvDTE; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using PackageManagement.Tests.Helpers; |
||||
using Rhino.Mocks; |
||||
|
||||
namespace PackageManagement.Tests.EnvDTE |
||||
{ |
||||
[TestFixture] |
||||
public class CodeVariableTests : CodeModelTestBase |
||||
{ |
||||
CodeVariable codeVariable; |
||||
|
||||
void CreateCodeVariable(string code) |
||||
{ |
||||
AddCodeFile("class.cs", code); |
||||
ITypeDefinition typeDefinition = assemblyModel.TopLevelTypeDefinitions.Single().Resolve(); |
||||
codeVariable = new CodeVariable(codeModelContext, typeDefinition.Fields.First()); |
||||
} |
||||
|
||||
[Test] |
||||
public void Access_PublicVariable_ReturnsPublic() |
||||
{ |
||||
CreateCodeVariable( |
||||
"public class MyClass {\r\n" + |
||||
" public int MyVariable;\r\n" + |
||||
"}"); |
||||
|
||||
global::EnvDTE.vsCMAccess access = codeVariable.Access; |
||||
|
||||
Assert.AreEqual(global::EnvDTE.vsCMAccess.vsCMAccessPublic, access); |
||||
} |
||||
|
||||
[Test] |
||||
public void Access_PrivateVariable_ReturnsPrivate() |
||||
{ |
||||
CreateCodeVariable( |
||||
"public class MyClass {\r\n" + |
||||
" private int MyVariable;\r\n" + |
||||
"}"); |
||||
|
||||
global::EnvDTE.vsCMAccess access = codeVariable.Access; |
||||
|
||||
Assert.AreEqual(global::EnvDTE.vsCMAccess.vsCMAccessPrivate, access); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetStartPoint_VariableStartsAtColumnOneOnLineTwo_ReturnsTextPointWithLineCharOffsetOneAndLineTwo() |
||||
{ |
||||
CreateCodeVariable( |
||||
"public class Foo {\r\n" + |
||||
"int V;\r\n" + |
||||
"}"); |
||||
|
||||
global::EnvDTE.TextPoint point = codeVariable.GetStartPoint(); |
||||
|
||||
Assert.AreEqual(1, point.LineCharOffset); |
||||
Assert.AreEqual(2, point.Line); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetEndPoint_VariableEndsAtColumnSevenOnLineTwo_ReturnsTextPointWithLineCharOffsetSevenOnLineTwo() |
||||
{ |
||||
CreateCodeVariable( |
||||
"public class Foo {\r\n" + |
||||
"int V;\r\n" + |
||||
"}"); |
||||
|
||||
global::EnvDTE.TextPoint point = codeVariable.GetEndPoint(); |
||||
|
||||
Assert.AreEqual(7, point.LineCharOffset); |
||||
Assert.AreEqual(2, point.Line); |
||||
} |
||||
|
||||
[Test] |
||||
public void Kind_PublicVariable_ReturnsVariable() |
||||
{ |
||||
CreateCodeVariable( |
||||
"public class MyClass {\r\n" + |
||||
" private int MyVariable;\r\n" + |
||||
"}"); |
||||
|
||||
global::EnvDTE.vsCMElement kind = codeVariable.Kind; |
||||
|
||||
Assert.AreEqual(global::EnvDTE.vsCMElement.vsCMElementVariable, kind); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetEndPoint_VariableHasSpaceBeforeSemiColon_ReturnsTextPointThatIncludesSemiColon() |
||||
{ |
||||
CreateCodeVariable( |
||||
"public class Foo {\r\n" + |
||||
"int V ;\r\n" + |
||||
"}"); |
||||
|
||||
global::EnvDTE.TextPoint point = codeVariable.GetEndPoint(); |
||||
|
||||
Assert.AreEqual(8, point.LineCharOffset); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@ -1,75 +0,0 @@
@@ -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