-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5e69a2
commit 4e3acb3
Showing
5 changed files
with
145 additions
and
21 deletions.
There are no files selected for viewing
43 changes: 41 additions & 2 deletions
43
src/ByReplace.Test/Commands/Rule/ListRules/ListRulesParameterTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,51 @@ | ||
using Xunit; | ||
using ByReplace.Commands.Apply.Rule; | ||
using ByReplace.Commands.Rule.ListRules; | ||
using ByReplace.Test.Common.Helpers; | ||
using Cocona; | ||
using Xunit; | ||
|
||
namespace ByReplace.Test.Commands.Rule.ListRules; | ||
|
||
public class ListRulesParameterTest | ||
{ | ||
[Fact] | ||
public void Test1() | ||
public void ListRulesParameter_ShouldValidateTheListRulesParameterHasInheritancesFromICommandParameterSet() | ||
{ | ||
// Arrange & Act | ||
var metadata = FileInspect<ListRulesParameter>.GetInterfaces(); | ||
|
||
// Assert | ||
Assert.NotNull(metadata); | ||
Assert.Equal(typeof(ICommandParameterSet), metadata.First()); | ||
} | ||
|
||
[Fact] | ||
public void ListRulesParameter_ShouldValidateThePropertiesConfiguration() | ||
{ | ||
// Arrange & Act | ||
var metadata = FileInspect<ListRulesParameter>.GetProperties(); | ||
|
||
// Assert | ||
Assert.Single(metadata); | ||
Assert.Collection(metadata, | ||
entry => | ||
{ | ||
var attributes = entry.GetCustomAttributes(false); | ||
|
||
Assert.Equal(typeof(string), entry.Name.GetType()); | ||
Assert.Equal("ConfigFile", entry.Name); | ||
Assert.Single(attributes); | ||
Assert.Collection(attributes, | ||
attribute => | ||
{ | ||
var option = (OptionAttribute)attribute; | ||
|
||
Assert.Equal(typeof(OptionAttribute), attribute.GetType()); | ||
Assert.Null(option.Name); | ||
Assert.Equal("Path of the brconfig file.", option.Description); | ||
Assert.Collection(option.ShortNames, | ||
entry => Assert.Equal('f', entry)); | ||
}); | ||
}); | ||
} | ||
} |
17 changes: 0 additions & 17 deletions
17
src/ByReplace.Test/Commands/Rule/ListRules/RulesBoxBuilderTest.cs
This file was deleted.
Oops, something went wrong.
102 changes: 102 additions & 0 deletions
102
src/ByReplace.Test/Commands/Rule/ListRules/RulesBoxTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using Xunit; | ||
using ByReplace.Commands.Rule.ListRules; | ||
using ByReplace.Builders; | ||
using ByReplace.Models; | ||
using ByReplace.Printers; | ||
using ByReplace.Test.Analyzers; | ||
using ByReplace.Test.Common.ConfigMock; | ||
using ByReplace.Test.Common.FolderMock; | ||
using Moq; | ||
using System.Collections.Immutable; | ||
|
||
namespace ByReplace.Test.Commands.Rule.ListRules; | ||
|
||
public class RulesBoxTest | ||
{ | ||
private readonly PathCompilationSyntax _pathCompilationSyntax; | ||
private readonly BrConfiguration _brConfiguration; | ||
private readonly Mock<IPrint> _printMock; | ||
|
||
public RulesBoxTest() | ||
{ | ||
_printMock = new Mock<IPrint>(); | ||
|
||
var configContent = BrContentFactory | ||
.CreateDefault() | ||
.AddConfig(BrContentFactory.ConfigNoPathDeclaration("obj", ".bin")) | ||
.AddRules(BrContentFactory | ||
.Rule("RuleTest") | ||
.WithExtensions(".cs", ".txt") | ||
.WithSkips("**\\Controllers\\*", "bin\\bin1.txt", "obj\\obj2.txt") | ||
.WithReplacement(BrContentFactory.Replacement("Test", "Test2"))) | ||
.Compile(); | ||
|
||
var rootFolder = FolderSyntax | ||
.FolderDeclaration("RootFolder") | ||
.AddMembers( | ||
FileSyntax.FileDeclaration("RootFile1.cs", "ITest = new Test()"), | ||
FileSyntax.FileDeclaration("RootFile2.cs", "ITest = new Test()")); | ||
|
||
_pathCompilationSyntax = PathFactory | ||
.Compile(nameof(AnalyzerAndFixerTest)) | ||
.AddMembers(rootFolder) | ||
.AddBrConfiguration(configContent) | ||
.Create(); | ||
|
||
_brConfiguration = BrConfigurationBuilder | ||
.Create() | ||
.SetPath($"./{_pathCompilationSyntax.InternalIdentifier}") | ||
.SetConfigPath($"./{_pathCompilationSyntax.InternalIdentifier}") | ||
.Build(); | ||
} | ||
|
||
[Fact] | ||
public void RulesBox_WhenInstantiate_ShouldValidateTheBoxConfiguration() | ||
{ | ||
// Arrange & Act | ||
var rulesBox = new RulesBox(_brConfiguration.Rules); | ||
|
||
// Assert | ||
Assert.Equal(100, rulesBox.Width); | ||
Assert.Equal(_brConfiguration.Rules.Count * 2, rulesBox.Height); | ||
Assert.Equal("Rules", rulesBox.BoxName); | ||
} | ||
|
||
[Fact] | ||
public void RulesBox_WhenInstantiate_ShouldValidateIfTwoObjectWithTheSameParametersAreEquals() | ||
{ | ||
// Arrange | ||
var rulesBoxFirst = new RulesBox(_brConfiguration.Rules); | ||
var rulesBoxSecond = new RulesBox(_brConfiguration.Rules); | ||
|
||
// Act | ||
var isEquals = rulesBoxFirst.Equals(rulesBoxSecond); | ||
var isEqualsLikeObject = rulesBoxFirst.Equals((object)rulesBoxSecond); | ||
var hasTheSameHashcode = rulesBoxFirst.GetHashCode() == rulesBoxSecond.GetHashCode(); | ||
|
||
// Assert | ||
Assert.Equal(rulesBoxSecond, rulesBoxFirst); | ||
Assert.True(isEquals); | ||
Assert.True(isEqualsLikeObject); | ||
Assert.True(hasTheSameHashcode); | ||
} | ||
|
||
[Fact] | ||
public void RulesBox_WhenInstantiate_ShouldValidateIfTwoObjectWithTheSameParametersAreNotEquals() | ||
{ | ||
// Arrange | ||
var rulesBoxFirst = new RulesBox(_brConfiguration.Rules); | ||
var rulesBoxSecond = new RulesBox(ImmutableList<Models.Rule>.Empty); | ||
|
||
// Act | ||
var isEquals = rulesBoxFirst.Equals(rulesBoxSecond); | ||
var isEqualsLikeObject = rulesBoxFirst.Equals((object)rulesBoxSecond); | ||
var hasTheSameHashcode = rulesBoxFirst.GetHashCode() == rulesBoxSecond.GetHashCode(); | ||
|
||
// Assert | ||
Assert.NotEqual(rulesBoxSecond, rulesBoxFirst); | ||
Assert.False(isEquals); | ||
Assert.False(isEqualsLikeObject); | ||
Assert.False(hasTheSameHashcode); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.