public CleanAppConfigCommandHandlerTest() { fs = new FakeFileSystem(); actionsHappened = new StringBuilder(); cleanAppConfigCommand = new CleanAppConfigCommand(Dir); var fileSearcher = A.Fake <IFileSearch>(); var sourceControl = A.Fake <IReadOnlySourceControl>(); A.CallTo(() => fileSearcher.FindFilesIncludingSubdirectories(Dir, "*.csproj")) .Invokes(call => actionsHappened.AppendLine(call.ToString())) .ReturnsLazily(call => fs.GetFiles().Where(x => x.EndsWith(".csproj", true, CultureInfo.InvariantCulture)).ToArray()); A.CallTo(() => fileSearcher.FindFilesIncludingSubdirectories(Dir, "app.config")) .Invokes(call => actionsHappened.AppendLine(call.ToString())) .ReturnsLazily(call => fs.GetFiles().Where(x => x.EndsWith("app.config", false, CultureInfo.InvariantCulture)).ToArray()); A.CallTo(() => fileSearcher.FindFilesIncludingSubdirectories(Dir, "App.config")) .Invokes(call => actionsHappened.AppendLine(call.ToString())) .ReturnsLazily(call => fs.GetFiles().Where(x => x.EndsWith("App.config", false, CultureInfo.InvariantCulture)).ToArray()); A.CallTo(() => sourceControl.GetFileStatus(A <string> ._)) .Invokes(call => actionsHappened.AppendLine(call.ToString())) .ReturnsLazily(call => fs.GetFileState(call.Arguments[0].ToString())); cleanSingleAppConfig = A.Fake <ICleanSingleAppConfig>(); A.CallTo(() => cleanSingleAppConfig.ExecuteAsync(A <string> ._, A <string> ._)) .Invokes(call => actionsHappened.AppendLine(call.ToString())); sut = new CleanAppConfigCommandHandler( fileSearcher, sourceControl, cleanSingleAppConfig); }
public CleanAppConfigCommandHandler( [NotNull] IFileSearch fileSearcher, [NotNull] IReadOnlySourceControl sourceControl, [NotNull] ICleanSingleAppConfig cleanSingleAppConfig) { Guard.NotNull(fileSearcher, nameof(fileSearcher)); Guard.NotNull(sourceControl, nameof(sourceControl)); Guard.NotNull(cleanSingleAppConfig, nameof(cleanSingleAppConfig)); this.fileSearcher = fileSearcher; this.sourceControl = sourceControl; this.cleanSingleAppConfig = cleanSingleAppConfig; }