|
1 | 1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
| 2 | +using Moq; |
2 | 3 | using Rubberduck.Settings;
|
3 | 4 | using Rubberduck.SmartIndenter;
|
| 5 | +using Rubberduck.UI; |
4 | 6 | using Rubberduck.UI.Settings;
|
5 | 7 |
|
6 | 8 | namespace RubberduckTests.Settings
|
7 | 9 | {
|
8 | 10 | [TestClass]
|
9 | 11 | public class IndenterSettingsTests
|
10 | 12 | {
|
| 13 | + #region Defaults |
| 14 | + private const bool DefaultIndentEntireProcedureBody = true; |
| 15 | + private const bool DefaultIndentFirstCommentBlock = true; |
| 16 | + private const bool DefaultIndentFirstDeclarationBlock = true; |
| 17 | + private const bool DefaultAlignCommentsWithCode = true; |
| 18 | + private const bool DefaultAlignContinuations = true; |
| 19 | + private const bool DefaultIgnoreOperatorsInContinuations = true; |
| 20 | + private const bool DefaultIndentCase = false; |
| 21 | + private const bool DefaultForceDebugStatementsInColumn1 = false; |
| 22 | + private const bool DefaultForceCompilerDirectivesInColumn1 = false; |
| 23 | + private const bool DefaultIndentCompilerDirectives = true; |
| 24 | + private const bool DefaultAlignDims = false; |
| 25 | + private const int DefaultAlignDimColumn = 15; |
| 26 | + private const bool DefaultEnableUndo = true; |
| 27 | + private const EndOfLineCommentStyle DefaultEndOfLineCommentStyle = EndOfLineCommentStyle.AlignInColumn; |
| 28 | + private const int DefaultEndOfLineCommentColumnSpaceAlignment = 50; |
| 29 | + private const int DefaultIndentSpaces = 4; |
| 30 | + #endregion |
| 31 | + |
| 32 | + #region Nondefaults |
| 33 | + private const bool NondefaultIndentEntireProcedureBody = false; |
| 34 | + private const bool NondefaultIndentFirstCommentBlock = false; |
| 35 | + private const bool NondefaultIndentFirstDeclarationBlock = false; |
| 36 | + private const bool NondefaultAlignCommentsWithCode = false; |
| 37 | + private const bool NondefaultAlignContinuations = false; |
| 38 | + private const bool NondefaultIgnoreOperatorsInContinuations = false; |
| 39 | + private const bool NondefaultIndentCase = true; |
| 40 | + private const bool NondefaultForceDebugStatementsInColumn1 = true; |
| 41 | + private const bool NondefaultForceCompilerDirectivesInColumn1 = true; |
| 42 | + private const bool NondefaultIndentCompilerDirectives = false; |
| 43 | + private const bool NondefaultAlignDims = true; |
| 44 | + private const int NondefaultAlignDimColumn = 16; |
| 45 | + private const bool NondefaultEnableUndo = false; |
| 46 | + private const EndOfLineCommentStyle NondefaultEndOfLineCommentStyle = EndOfLineCommentStyle.Absolute; |
| 47 | + private const int NondefaultEndOfLineCommentColumnSpaceAlignment = 60; |
| 48 | + private const int NondefaultIndentSpaces = 2; |
| 49 | + #endregion |
| 50 | + |
| 51 | + public static Rubberduck.SmartIndenter.IndenterSettings GetMockIndenterSettings(bool nondefault = false) |
| 52 | + { |
| 53 | + var output = new Mock<Rubberduck.SmartIndenter.IndenterSettings>(); |
| 54 | + |
| 55 | + output.SetupProperty(s => s.IndentEntireProcedureBody); |
| 56 | + output.SetupProperty(s => s.IndentFirstCommentBlock); |
| 57 | + output.SetupProperty(s => s.IndentFirstDeclarationBlock); |
| 58 | + output.SetupProperty(s => s.AlignCommentsWithCode); |
| 59 | + output.SetupProperty(s => s.AlignContinuations); |
| 60 | + output.SetupProperty(s => s.IgnoreOperatorsInContinuations); |
| 61 | + output.SetupProperty(s => s.IndentCase); |
| 62 | + output.SetupProperty(s => s.ForceDebugStatementsInColumn1); |
| 63 | + output.SetupProperty(s => s.ForceCompilerDirectivesInColumn1); |
| 64 | + output.SetupProperty(s => s.IndentCompilerDirectives); |
| 65 | + output.SetupProperty(s => s.AlignDims); |
| 66 | + output.SetupProperty(s => s.AlignDimColumn); |
| 67 | + output.SetupProperty(s => s.EnableUndo); |
| 68 | + output.SetupProperty(s => s.EndOfLineCommentStyle); |
| 69 | + output.SetupProperty(s => s.EndOfLineCommentColumnSpaceAlignment); |
| 70 | + output.SetupProperty(s => s.IndentSpaces); |
| 71 | + |
| 72 | + output.Object.IndentEntireProcedureBody = nondefault ? NondefaultIndentEntireProcedureBody : DefaultIndentEntireProcedureBody; |
| 73 | + output.Object.IndentFirstCommentBlock = nondefault ? NondefaultIndentFirstCommentBlock : DefaultIndentFirstCommentBlock; |
| 74 | + output.Object.IndentFirstDeclarationBlock = nondefault ? NondefaultIndentFirstDeclarationBlock : DefaultIndentFirstDeclarationBlock; |
| 75 | + output.Object.AlignCommentsWithCode = nondefault ? NondefaultAlignCommentsWithCode : DefaultAlignCommentsWithCode; |
| 76 | + output.Object.AlignContinuations = nondefault ? NondefaultAlignContinuations : DefaultAlignContinuations; |
| 77 | + output.Object.IgnoreOperatorsInContinuations = nondefault ? NondefaultIgnoreOperatorsInContinuations : DefaultIgnoreOperatorsInContinuations; |
| 78 | + output.Object.IndentCase = nondefault ? NondefaultIndentCase : DefaultIndentCase; |
| 79 | + output.Object.ForceDebugStatementsInColumn1 = nondefault ? NondefaultForceDebugStatementsInColumn1 : DefaultForceDebugStatementsInColumn1; |
| 80 | + output.Object.ForceCompilerDirectivesInColumn1 = nondefault ? NondefaultForceCompilerDirectivesInColumn1 : DefaultForceCompilerDirectivesInColumn1; |
| 81 | + output.Object.IndentCompilerDirectives = nondefault ? NondefaultIndentCompilerDirectives : DefaultIndentCompilerDirectives; |
| 82 | + output.Object.AlignDims = nondefault ? NondefaultAlignDims : DefaultAlignDims; |
| 83 | + output.Object.AlignDimColumn = nondefault ? NondefaultAlignDimColumn : DefaultAlignDimColumn; |
| 84 | + output.Object.EnableUndo = nondefault ? NondefaultEnableUndo : DefaultEnableUndo; |
| 85 | + output.Object.EndOfLineCommentStyle = nondefault ? NondefaultEndOfLineCommentStyle : DefaultEndOfLineCommentStyle; |
| 86 | + output.Object.EndOfLineCommentColumnSpaceAlignment = nondefault ? NondefaultEndOfLineCommentColumnSpaceAlignment : DefaultEndOfLineCommentColumnSpaceAlignment; |
| 87 | + output.Object.IndentSpaces = nondefault ? NondefaultIndentSpaces : DefaultIndentSpaces; |
| 88 | + |
| 89 | + return output.Object; |
| 90 | + } |
| 91 | + |
11 | 92 | private Configuration GetDefaultConfig()
|
12 | 93 | {
|
13 |
| - var indenterSettings = new Rubberduck.SmartIndenter.IndenterSettings |
14 |
| - { |
15 |
| - IndentEntireProcedureBody = true, |
16 |
| - IndentFirstCommentBlock = true, |
17 |
| - IndentFirstDeclarationBlock = true, |
18 |
| - AlignCommentsWithCode = true, |
19 |
| - AlignContinuations = true, |
20 |
| - IgnoreOperatorsInContinuations = true, |
21 |
| - IndentCase = false, |
22 |
| - ForceDebugStatementsInColumn1 = false, |
23 |
| - ForceCompilerDirectivesInColumn1 = false, |
24 |
| - IndentCompilerDirectives = true, |
25 |
| - AlignDims = false, |
26 |
| - AlignDimColumn = 15, |
27 |
| - EnableUndo = true, |
28 |
| - EndOfLineCommentStyle = EndOfLineCommentStyle.AlignInColumn, |
29 |
| - EndOfLineCommentColumnSpaceAlignment = 50, |
30 |
| - IndentSpaces = 4 |
31 |
| - }; |
32 |
| - |
33 |
| - var userSettings = new UserSettings(null, null, null, null, null, indenterSettings); |
| 94 | + //var indenterSettings = GetTestIndenterSettings(); |
| 95 | + //{ |
| 96 | + // indenterSettings.IndentEntireProcedureBody = true, |
| 97 | + // indenterSettings.IndentFirstCommentBlock = true, |
| 98 | + // indenterSettings.IndentFirstDeclarationBlock = true, |
| 99 | + // indenterSettings.AlignCommentsWithCode = true, |
| 100 | + // indenterSettings.AlignContinuations = true, |
| 101 | + // IgnoreOperatorsInContinuations = true, |
| 102 | + // IndentCase = false, |
| 103 | + // ForceDebugStatementsInColumn1 = false, |
| 104 | + // ForceCompilerDirectivesInColumn1 = false, |
| 105 | + // IndentCompilerDirectives = true, |
| 106 | + // AlignDims = false, |
| 107 | + // AlignDimColumn = 15, |
| 108 | + // EnableUndo = true, |
| 109 | + // EndOfLineCommentStyle = EndOfLineCommentStyle.AlignInColumn, |
| 110 | + // EndOfLineCommentColumnSpaceAlignment = 50, |
| 111 | + // IndentSpaces = 4 |
| 112 | + //}; |
| 113 | + |
| 114 | + var userSettings = new UserSettings(null, null, null, null, null, GetMockIndenterSettings()); |
34 | 115 | return new Configuration(userSettings);
|
35 | 116 | }
|
36 | 117 |
|
37 | 118 | private Configuration GetNondefaultConfig()
|
38 | 119 | {
|
39 |
| - var indenterSettings = new Rubberduck.SmartIndenter.IndenterSettings |
40 |
| - { |
41 |
| - IndentEntireProcedureBody = false, |
42 |
| - IndentFirstCommentBlock = false, |
43 |
| - IndentFirstDeclarationBlock = false, |
44 |
| - AlignCommentsWithCode = false, |
45 |
| - AlignContinuations = false, |
46 |
| - IgnoreOperatorsInContinuations = false, |
47 |
| - IndentCase = true, |
48 |
| - ForceDebugStatementsInColumn1 = true, |
49 |
| - ForceCompilerDirectivesInColumn1 = true, |
50 |
| - IndentCompilerDirectives = false, |
51 |
| - AlignDims = true, |
52 |
| - AlignDimColumn = 16, |
53 |
| - EnableUndo = false, |
54 |
| - EndOfLineCommentStyle = EndOfLineCommentStyle.Absolute, |
55 |
| - EndOfLineCommentColumnSpaceAlignment = 60, |
56 |
| - IndentSpaces = 2 |
57 |
| - }; |
58 |
| - |
59 |
| - var userSettings = new UserSettings(null, null, null, null, null, indenterSettings); |
| 120 | + //var indenterSettings = new Rubberduck.SmartIndenter.IndenterSettings |
| 121 | + //{ |
| 122 | + // IndentEntireProcedureBody = false, |
| 123 | + // IndentFirstCommentBlock = false, |
| 124 | + // IndentFirstDeclarationBlock = false, |
| 125 | + // AlignCommentsWithCode = false, |
| 126 | + // AlignContinuations = false, |
| 127 | + // IgnoreOperatorsInContinuations = false, |
| 128 | + // IndentCase = true, |
| 129 | + // ForceDebugStatementsInColumn1 = true, |
| 130 | + // ForceCompilerDirectivesInColumn1 = true, |
| 131 | + // IndentCompilerDirectives = false, |
| 132 | + // AlignDims = true, |
| 133 | + // AlignDimColumn = 16, |
| 134 | + // EnableUndo = false, |
| 135 | + // EndOfLineCommentStyle = EndOfLineCommentStyle.Absolute, |
| 136 | + // EndOfLineCommentColumnSpaceAlignment = 60, |
| 137 | + // IndentSpaces = 2 |
| 138 | + //}; |
| 139 | + |
| 140 | + var userSettings = new UserSettings(null, null, null, null, null, GetMockIndenterSettings(true)); |
60 | 141 | return new Configuration(userSettings);
|
61 | 142 | }
|
62 | 143 |
|
|
0 commit comments