예제 #1
0
        public BuildUpToDateCheckTests(ITestOutputHelper output)
        {
            _output = output;

            // NOTE most of these mocks are only present to prevent NREs in Initialize

            // Enable "Info" log level, as we assert logged messages in tests
            var projectSystemOptions = new Mock <IProjectSystemOptions>();

            projectSystemOptions.Setup(o => o.GetFastUpToDateLoggingLevelAsync(It.IsAny <CancellationToken>()))
            .ReturnsAsync(LogLevel.Info);
            projectSystemOptions.Setup(o => o.GetIsFastUpToDateCheckEnabledAsync(It.IsAny <CancellationToken>()))
            .ReturnsAsync(() => _isFastUpToDateCheckEnabled);

            var projectCommonServices = IProjectCommonServicesFactory.CreateWithDefaultThreadingPolicy();
            var jointRuleSource       = new ProjectValueDataSource <IProjectSubscriptionUpdate>(projectCommonServices);
            var sourceItemsRuleSource = new ProjectValueDataSource <IProjectSubscriptionUpdate>(projectCommonServices);

            var projectSubscriptionService = new Mock <IProjectSubscriptionService>();

            projectSubscriptionService.SetupGet(o => o.JointRuleSource).Returns(jointRuleSource);
            projectSubscriptionService.SetupGet(o => o.SourceItemsRuleSource).Returns(sourceItemsRuleSource);

            var configuredProjectServices = ConfiguredProjectServicesFactory.Create(projectSubscriptionService: projectSubscriptionService.Object);

            var configuredProject = new Mock <ConfiguredProject>();

            configuredProject.SetupGet(c => c.ProjectVersion).Returns(() => _projectVersion);
            configuredProject.SetupGet(c => c.Services).Returns(configuredProjectServices);
            configuredProject.SetupGet(c => c.UnconfiguredProject).Returns(UnconfiguredProjectFactory.Create(filePath: _projectFullPath));

            var projectAsynchronousTasksService = new Mock <IProjectAsynchronousTasksService>();

            projectAsynchronousTasksService.SetupGet(s => s.UnloadCancellationToken).Returns(CancellationToken.None);
            projectAsynchronousTasksService.Setup(s => s.IsTaskQueueEmpty(ProjectCriticalOperation.Build)).Returns(() => _isTaskQueueEmpty);

            var lastWriteTimeUtc = new DateTime(1999, 1, 1, 0, 0, 0, DateTimeKind.Utc);

            _fileSystem = new IFileSystemMock();
            _fileSystem.AddFile(_msBuildProjectFullPath, lastWriteTimeUtc);
            _fileSystem.AddFile("Project1", lastWriteTimeUtc);
            _fileSystem.AddFile("Project2", lastWriteTimeUtc);
            _fileSystem.AddFolder(_msBuildProjectDirectory);
            _fileSystem.AddFolder(_outputPath);

            var threadingService = IProjectThreadingServiceFactory.Create();

            _buildUpToDateCheck = new BuildUpToDateCheck(
                projectSystemOptions.Object,
                configuredProject.Object,
                projectAsynchronousTasksService.Object,
                IProjectItemSchemaServiceFactory.Create(),
                ITelemetryServiceFactory.Create(telemetryParameters => _telemetryEvents.Add(telemetryParameters)),
                threadingService,
                _fileSystem);
        }
예제 #2
0
 public TestAccessor(BuildUpToDateCheck check)
 {
     _check = check;
 }