public void ReplaceSourceCodeReferences_RunsAsExpected(string input, string oldName, string newName, string expectedOutput, IEnumerable <TokenCheckerCall> tokenCheckerCalls) { //Arrange ITokenChecker tokenChecker = Substitute.For <ITokenChecker>(); tokenChecker .CheckIsToken(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <int>()) .Returns(x => x.ArgAt <int>(2) % 2 == 0); CalculationCodeReferenceUpdate calculationCodeReferenceUpdate = new CalculationCodeReferenceUpdate(tokenChecker); //Act string result = calculationCodeReferenceUpdate.ReplaceSourceCodeReferences(input, oldName, newName); //Assert Assert.AreEqual(expectedOutput, result); tokenChecker .Received(tokenCheckerCalls.Count()) .CheckIsToken(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <int>()); foreach (TokenCheckerCall call in tokenCheckerCalls) { tokenChecker .Received(1) .CheckIsToken(call.SourceCode, oldName, call.Position); } }
public PreviewService( ILogger logger, IBuildProjectsService buildProjectsService, IValidator <PreviewRequest> previewRequestValidator, ICalculationsRepository calculationsRepository, IDatasetRepository datasetRepository, IFeatureToggle featureToggle, ICacheProvider cacheProvider, ISourceCodeService sourceCodeService, ITokenChecker tokenChecker) { _logger = logger; _buildProjectsService = buildProjectsService; _previewRequestValidator = previewRequestValidator; _calculationsRepository = calculationsRepository; _datasetRepository = datasetRepository; _featureToggle = featureToggle; _cacheProvider = cacheProvider; _sourceCodeService = sourceCodeService; _tokenChecker = tokenChecker; }
public CalculationCodeReferenceUpdate(ITokenChecker tokenChecker) { Guard.ArgumentNotNull(tokenChecker, nameof(tokenChecker)); _tokenChecker = tokenChecker; }
public Token(ITokenChecker checker, string tokenString) { _checker = checker; _tokenString = tokenString; }