Пример #1
0
 /// <summary>
 /// Creates an instance of <see cref="SolutionRestoreRequest"/> with flags typical to
 /// on-demand restore as requested by an user via Visual Studio UI.
 /// </summary>
 /// <returns>New instance of <see cref="SolutionRestoreRequest"/></returns>
 public static SolutionRestoreRequest ByUserCommand(ExplicitRestoreReason explicitRestoreReason)
 {
     return(new SolutionRestoreRequest(
                forceRestore: false,
                restoreSource: RestoreOperationSource.Explicit,
                explicitRestoreReason));
 }
Пример #2
0
 public SolutionRestoreRequest(
     bool forceRestore,
     RestoreOperationSource restoreSource,
     ExplicitRestoreReason explicitRestoreReason)
 {
     ForceRestore          = forceRestore;
     RestoreSource         = restoreSource;
     ExplicitRestoreReason = explicitRestoreReason;
 }
        public void RestoreTelemetryService_EmitRestoreEvent_OperationSucceed(bool forceRestore, RestoreOperationSource source, NuGetOperationStatus status, ExplicitRestoreReason explicitRestoreReason)
        {
            // Arrange
            var            telemetrySession   = new Mock <ITelemetrySession>();
            TelemetryEvent lastTelemetryEvent = null;

            telemetrySession
            .Setup(x => x.PostEvent(It.IsAny <TelemetryEvent>()))
            .Callback <TelemetryEvent>(x => lastTelemetryEvent = x);

            var noopProjectsCount = 0;

            if (status == NuGetOperationStatus.NoOp)
            {
                noopProjectsCount = 1;
            }

            var operationId = Guid.NewGuid().ToString();

            var restoreTelemetryData = new RestoreTelemetryEvent(
                operationId,
                projectIds: new[] { Guid.NewGuid().ToString() },
                forceRestore: forceRestore,
                source: source,
                startTime: DateTimeOffset.Now.AddSeconds(-3),
                status: status,
                packageCount: 2,
                noOpProjectsCount: noopProjectsCount,
                upToDateProjectsCount: 5,
                unknownProjectsCount: 0,
                projectJsonProjectsCount: 0,
                packageReferenceProjectsCount: 0,
                legacyPackageReferenceProjectsCount: 0,
                cpsPackageReferenceProjectsCount: 0,
                dotnetCliToolProjectsCount: 0,
                packagesConfigProjectsCount: 1,
                endTime: DateTimeOffset.Now,
                duration: 2.10,
                additionalTrackingData: new Dictionary <string, object>()
            {
                { nameof(RestoreTelemetryEvent.IsSolutionLoadRestore), true },
                { nameof(ExplicitRestoreReason), explicitRestoreReason }
            },
                new IntervalTracker("Activity"),
                isPackageSourceMappingEnabled: false,
                httpFeedsCount: 1,
                localFeedsCount: 2,
                hasNuGetOrg: true,
                hasVSOfflineFeed: false);
            var service = new NuGetVSTelemetryService(telemetrySession.Object);

            // Act
            service.EmitTelemetryEvent(restoreTelemetryData);

            // Assert
            VerifyTelemetryEventData(operationId, restoreTelemetryData, lastTelemetryEvent);
        }