Skip to content

Commit

Permalink
Merge pull request #116 from codecadwallader/property-padding
Browse files Browse the repository at this point in the history
Card 37: Add separate blank line padding options for single-line prop…
  • Loading branch information
codecadwallader committed Jul 12, 2015
2 parents 029e3dd + 6b5e091 commit 4693f47
Show file tree
Hide file tree
Showing 31 changed files with 952 additions and 685 deletions.
Original file line number Diff line number Diff line change
@@ -1,98 +1,97 @@
#region CodeMaid is Copyright 2007-2015 Steve Cadwallader.

// CodeMaid is free software: you can redistribute it and/or modify it under the terms of the GNU
// Lesser General Public License version 3 as published by the Free Software Foundation.
//
// CodeMaid is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
// even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details <http://www.gnu.org/licenses/>.

#endregion CodeMaid is Copyright 2007-2015 Steve Cadwallader.

using EnvDTE;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SteveCadwallader.CodeMaid.IntegrationTests.Helpers;
using SteveCadwallader.CodeMaid.Logic.Cleaning;
using SteveCadwallader.CodeMaid.Model.CodeItems;
using SteveCadwallader.CodeMaid.Properties;
using System.Linq;

namespace SteveCadwallader.CodeMaid.IntegrationTests.Cleaning.Insert
{
[TestClass]
[DeploymentItem(@"Cleaning\Insert\Data\BlankLinePaddingAfterFieldsWithComments.cs", "Data")]
[DeploymentItem(@"Cleaning\Insert\Data\BlankLinePaddingAfterFieldsWithComments_Cleaned.cs", "Data")]
public class BlankLinePaddingAfterFieldsWithCommentsTests
{
#region Setup

private static InsertBlankLinePaddingLogic _insertBlankLinePaddingLogic;
private ProjectItem _projectItem;

[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
_insertBlankLinePaddingLogic = InsertBlankLinePaddingLogic.GetInstance(TestEnvironment.Package);
Assert.IsNotNull(_insertBlankLinePaddingLogic);
}

[TestInitialize]
public void TestInitialize()
{
TestEnvironment.CommonTestInitialize();
_projectItem = TestEnvironment.LoadFileIntoProject(@"Data\BlankLinePaddingAfterFieldsWithComments.cs");
}

[TestCleanup]
public void TestCleanup()
{
TestEnvironment.RemoveFromProject(_projectItem);
}

#endregion Setup

#region Tests

[TestMethod]
[HostType("VS IDE")]
public void CleaningInsertBlankLinePaddingAfterFieldsWithComments_CleansAsExpected()
{
Settings.Default.Cleaning_InsertBlankLinePaddingAfterFieldsMultiLine = true;

TestOperations.ExecuteCommandAndVerifyResults(RunInsertBlankLinePaddingAfterFieldsWithComments, _projectItem, @"Data\BlankLinePaddingAfterFieldsWithComments_Cleaned.cs");
}

[TestMethod]
[HostType("VS IDE")]
public void CleaningInsertBlankLinePaddingAfterFieldsWithComments_DoesNothingOnSecondPass()
{
Settings.Default.Cleaning_InsertBlankLinePaddingAfterFieldsMultiLine = true;

TestOperations.ExecuteCommandTwiceAndVerifyNoChangesOnSecondPass(RunInsertBlankLinePaddingAfterFieldsWithComments, _projectItem);
}

[TestMethod]
[HostType("VS IDE")]
public void CleaningInsertBlankLinePaddingAfterFieldsWithComments_DoesNothingWhenSettingIsDisabled()
{
Settings.Default.Cleaning_InsertBlankLinePaddingAfterFieldsMultiLine = false;

TestOperations.ExecuteCommandAndVerifyNoChanges(RunInsertBlankLinePaddingAfterFieldsWithComments, _projectItem);
}

#endregion Tests

#region Helpers

private static void RunInsertBlankLinePaddingAfterFieldsWithComments(Document document)
{
var codeItems = TestOperations.CodeModelManager.RetrieveAllCodeItems(document);
var fields = codeItems.OfType<CodeItemField>().ToList();
var fieldsWithComments = fields.Where(x => x.StartPoint.Line < x.EndPoint.Line).ToList();

_insertBlankLinePaddingLogic.InsertPaddingAfterCodeElements(fieldsWithComments);
}

#endregion Helpers
}
#region CodeMaid is Copyright 2007-2015 Steve Cadwallader.

// CodeMaid is free software: you can redistribute it and/or modify it under the terms of the GNU
// Lesser General Public License version 3 as published by the Free Software Foundation.
//
// CodeMaid is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
// even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details <http://www.gnu.org/licenses/>.

#endregion CodeMaid is Copyright 2007-2015 Steve Cadwallader.

using EnvDTE;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SteveCadwallader.CodeMaid.IntegrationTests.Helpers;
using SteveCadwallader.CodeMaid.Logic.Cleaning;
using SteveCadwallader.CodeMaid.Model.CodeItems;
using SteveCadwallader.CodeMaid.Properties;
using System.Linq;

namespace SteveCadwallader.CodeMaid.IntegrationTests.Cleaning.Insert
{
[TestClass]
[DeploymentItem(@"Cleaning\Insert\Data\BlankLinePaddingAfterFieldsMultiLine.cs", "Data")]
[DeploymentItem(@"Cleaning\Insert\Data\BlankLinePaddingAfterFieldsMultiLine_Cleaned.cs", "Data")]
public class BlankLinePaddingAfterFieldsMultiLineTests
{
#region Setup

private static InsertBlankLinePaddingLogic _insertBlankLinePaddingLogic;
private ProjectItem _projectItem;

[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
_insertBlankLinePaddingLogic = InsertBlankLinePaddingLogic.GetInstance(TestEnvironment.Package);
Assert.IsNotNull(_insertBlankLinePaddingLogic);
}

[TestInitialize]
public void TestInitialize()
{
TestEnvironment.CommonTestInitialize();
_projectItem = TestEnvironment.LoadFileIntoProject(@"Data\BlankLinePaddingAfterFieldsMultiLine.cs");
}

[TestCleanup]
public void TestCleanup()
{
TestEnvironment.RemoveFromProject(_projectItem);
}

#endregion Setup

#region Tests

[TestMethod]
[HostType("VS IDE")]
public void CleaningInsertBlankLinePaddingAfterFieldsMultiLine_CleansAsExpected()
{
Settings.Default.Cleaning_InsertBlankLinePaddingAfterFieldsMultiLine = true;

TestOperations.ExecuteCommandAndVerifyResults(RunInsertBlankLinePaddingAfterFieldsMultiLine, _projectItem, @"Data\BlankLinePaddingAfterFieldsMultiLine_Cleaned.cs");
}

[TestMethod]
[HostType("VS IDE")]
public void CleaningInsertBlankLinePaddingAfterFieldsMultiLine_DoesNothingOnSecondPass()
{
Settings.Default.Cleaning_InsertBlankLinePaddingAfterFieldsMultiLine = true;

TestOperations.ExecuteCommandTwiceAndVerifyNoChangesOnSecondPass(RunInsertBlankLinePaddingAfterFieldsMultiLine, _projectItem);
}

[TestMethod]
[HostType("VS IDE")]
public void CleaningInsertBlankLinePaddingAfterFieldsMultiLine_DoesNothingWhenSettingIsDisabled()
{
Settings.Default.Cleaning_InsertBlankLinePaddingAfterFieldsMultiLine = false;

TestOperations.ExecuteCommandAndVerifyNoChanges(RunInsertBlankLinePaddingAfterFieldsMultiLine, _projectItem);
}

#endregion Tests

#region Helpers

private static void RunInsertBlankLinePaddingAfterFieldsMultiLine(Document document)
{
var codeItems = TestOperations.CodeModelManager.RetrieveAllCodeItems(document);
var fields = codeItems.OfType<CodeItemField>().ToList();

_insertBlankLinePaddingLogic.InsertPaddingAfterCodeElements(fields);
}

#endregion Helpers
}
}
Original file line number Diff line number Diff line change
@@ -1,97 +1,97 @@
#region CodeMaid is Copyright 2007-2015 Steve Cadwallader.

// CodeMaid is free software: you can redistribute it and/or modify it under the terms of the GNU
// Lesser General Public License version 3 as published by the Free Software Foundation.
//
// CodeMaid is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
// even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details <http://www.gnu.org/licenses/>.

#endregion CodeMaid is Copyright 2007-2015 Steve Cadwallader.

using EnvDTE;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SteveCadwallader.CodeMaid.IntegrationTests.Helpers;
using SteveCadwallader.CodeMaid.Logic.Cleaning;
using SteveCadwallader.CodeMaid.Model.CodeItems;
using SteveCadwallader.CodeMaid.Properties;
using System.Linq;

namespace SteveCadwallader.CodeMaid.IntegrationTests.Cleaning.Insert
{
[TestClass]
[DeploymentItem(@"Cleaning\Insert\Data\BlankLinePaddingAfterProperties.cs", "Data")]
[DeploymentItem(@"Cleaning\Insert\Data\BlankLinePaddingAfterProperties_Cleaned.cs", "Data")]
public class BlankLinePaddingAfterPropertiesTests
{
#region Setup

private static InsertBlankLinePaddingLogic _insertBlankLinePaddingLogic;
private ProjectItem _projectItem;

[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
_insertBlankLinePaddingLogic = InsertBlankLinePaddingLogic.GetInstance(TestEnvironment.Package);
Assert.IsNotNull(_insertBlankLinePaddingLogic);
}

[TestInitialize]
public void TestInitialize()
{
TestEnvironment.CommonTestInitialize();
_projectItem = TestEnvironment.LoadFileIntoProject(@"Data\BlankLinePaddingAfterProperties.cs");
}

[TestCleanup]
public void TestCleanup()
{
TestEnvironment.RemoveFromProject(_projectItem);
}

#endregion Setup

#region Tests

[TestMethod]
[HostType("VS IDE")]
public void CleaningInsertBlankLinePaddingAfterProperties_CleansAsExpected()
{
Settings.Default.Cleaning_InsertBlankLinePaddingAfterProperties = true;

TestOperations.ExecuteCommandAndVerifyResults(RunInsertBlankLinePaddingAfterProperties, _projectItem, @"Data\BlankLinePaddingAfterProperties_Cleaned.cs");
}

[TestMethod]
[HostType("VS IDE")]
public void CleaningInsertBlankLinePaddingAfterProperties_DoesNothingOnSecondPass()
{
Settings.Default.Cleaning_InsertBlankLinePaddingAfterProperties = true;

TestOperations.ExecuteCommandTwiceAndVerifyNoChangesOnSecondPass(RunInsertBlankLinePaddingAfterProperties, _projectItem);
}

[TestMethod]
[HostType("VS IDE")]
public void CleaningInsertBlankLinePaddingAfterProperties_DoesNothingWhenSettingIsDisabled()
{
Settings.Default.Cleaning_InsertBlankLinePaddingAfterProperties = false;

TestOperations.ExecuteCommandAndVerifyNoChanges(RunInsertBlankLinePaddingAfterProperties, _projectItem);
}

#endregion Tests

#region Helpers

private static void RunInsertBlankLinePaddingAfterProperties(Document document)
{
var codeItems = TestOperations.CodeModelManager.RetrieveAllCodeItems(document);
var properties = codeItems.OfType<CodeItemProperty>().ToList();

_insertBlankLinePaddingLogic.InsertPaddingAfterCodeElements(properties);
}

#endregion Helpers
}
#region CodeMaid is Copyright 2007-2015 Steve Cadwallader.

// CodeMaid is free software: you can redistribute it and/or modify it under the terms of the GNU
// Lesser General Public License version 3 as published by the Free Software Foundation.
//
// CodeMaid is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
// even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details <http://www.gnu.org/licenses/>.

#endregion CodeMaid is Copyright 2007-2015 Steve Cadwallader.

using EnvDTE;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SteveCadwallader.CodeMaid.IntegrationTests.Helpers;
using SteveCadwallader.CodeMaid.Logic.Cleaning;
using SteveCadwallader.CodeMaid.Model.CodeItems;
using SteveCadwallader.CodeMaid.Properties;
using System.Linq;

namespace SteveCadwallader.CodeMaid.IntegrationTests.Cleaning.Insert
{
[TestClass]
[DeploymentItem(@"Cleaning\Insert\Data\BlankLinePaddingAfterPropertiesMultiLine.cs", "Data")]
[DeploymentItem(@"Cleaning\Insert\Data\BlankLinePaddingAfterPropertiesMultiLine_Cleaned.cs", "Data")]
public class BlankLinePaddingAfterPropertiesMultiLineTests
{
#region Setup

private static InsertBlankLinePaddingLogic _insertBlankLinePaddingLogic;
private ProjectItem _projectItem;

[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
_insertBlankLinePaddingLogic = InsertBlankLinePaddingLogic.GetInstance(TestEnvironment.Package);
Assert.IsNotNull(_insertBlankLinePaddingLogic);
}

[TestInitialize]
public void TestInitialize()
{
TestEnvironment.CommonTestInitialize();
_projectItem = TestEnvironment.LoadFileIntoProject(@"Data\BlankLinePaddingAfterPropertiesMultiLine.cs");
}

[TestCleanup]
public void TestCleanup()
{
TestEnvironment.RemoveFromProject(_projectItem);
}

#endregion Setup

#region Tests

[TestMethod]
[HostType("VS IDE")]
public void CleaningInsertBlankLinePaddingAfterPropertiesMultiLine_CleansAsExpected()
{
Settings.Default.Cleaning_InsertBlankLinePaddingAfterPropertiesMultiLine = true;

TestOperations.ExecuteCommandAndVerifyResults(RunInsertBlankLinePaddingAfterPropertiesMultiLine, _projectItem, @"Data\BlankLinePaddingAfterPropertiesMultiLine_Cleaned.cs");
}

[TestMethod]
[HostType("VS IDE")]
public void CleaningInsertBlankLinePaddingAfterPropertiesMultiLine_DoesNothingOnSecondPass()
{
Settings.Default.Cleaning_InsertBlankLinePaddingAfterPropertiesMultiLine = true;

TestOperations.ExecuteCommandTwiceAndVerifyNoChangesOnSecondPass(RunInsertBlankLinePaddingAfterPropertiesMultiLine, _projectItem);
}

[TestMethod]
[HostType("VS IDE")]
public void CleaningInsertBlankLinePaddingAfterPropertiesMultiLine_DoesNothingWhenSettingIsDisabled()
{
Settings.Default.Cleaning_InsertBlankLinePaddingAfterPropertiesMultiLine = false;

TestOperations.ExecuteCommandAndVerifyNoChanges(RunInsertBlankLinePaddingAfterPropertiesMultiLine, _projectItem);
}

#endregion Tests

#region Helpers

private static void RunInsertBlankLinePaddingAfterPropertiesMultiLine(Document document)
{
var codeItems = TestOperations.CodeModelManager.RetrieveAllCodeItems(document);
var properties = codeItems.OfType<CodeItemProperty>().ToList();

_insertBlankLinePaddingLogic.InsertPaddingAfterCodeElements(properties);
}

#endregion Helpers
}
}
Loading

0 comments on commit 4693f47

Please sign in to comment.