コード例 #1
0
        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);
            }
        }
コード例 #2
0
 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;
 }
コード例 #3
0
        public CalculationCodeReferenceUpdate(ITokenChecker tokenChecker)
        {
            Guard.ArgumentNotNull(tokenChecker, nameof(tokenChecker));

            _tokenChecker = tokenChecker;
        }
コード例 #4
0
 public Token(ITokenChecker checker, string tokenString)
 {
     _checker     = checker;
     _tokenString = tokenString;
 }