/// <summary> /// Initializes a new instance of <see cref="TestContext"/>. /// </summary> /// <param name="subscriptions">The set of subscription metadata describing the Git repos that are listening for changes to base images.</param> /// <param name="allSubscriptionImagePaths">Multiple sets of mappings between subscriptions and their associated image paths.</param> /// <param name="inProgressBuilds">The set of in-progress builds that should be configured.</param> /// <param name="allBuilds">The set of failed builds that should be configured.</param> public TestContext( Subscription[] subscriptions, IEnumerable <IEnumerable <SubscriptionImagePaths> > allSubscriptionImagePaths, PagedList <WebApi.Build> inProgressBuilds, PagedList <WebApi.Build> allBuilds) { this.allSubscriptionImagePaths = allSubscriptionImagePaths; this.inProgressBuilds = inProgressBuilds; this.allBuilds = allBuilds; this.subscriptionsPath = this.SerializeJsonObjectToTempFile(subscriptions); TeamProject project = new TeamProject { Id = Guid.NewGuid() }; Mock <IProjectHttpClient> projectHttpClientMock = CreateProjectHttpClientMock(project); this.buildHttpClientMock = CreateBuildHttpClientMock(project, this.inProgressBuilds, this.allBuilds); Mock <IVssConnectionFactory> connectionFactoryMock = CreateVssConnectionFactoryMock( projectHttpClientMock, this.buildHttpClientMock); _notificationServiceMock = new Mock <INotificationService>(); this.command = this.CreateCommand(connectionFactoryMock); }
private QueueBuildCommand CreateCommand(Mock <IVssConnectionFactory> connectionFactoryMock) { Mock <ILoggerService> loggerServiceMock = new Mock <ILoggerService>(); QueueBuildCommand command = new QueueBuildCommand(connectionFactoryMock.Object, loggerServiceMock.Object); command.Options.AzdoOptions.Organization = BuildOrganization; command.Options.AzdoOptions.AccessToken = "testToken"; command.Options.SubscriptionsPath = this.subscriptionsPath; command.Options.AllSubscriptionImagePaths = this.allSubscriptionImagePaths .Select(subscriptionImagePaths => JsonConvert.SerializeObject(subscriptionImagePaths.ToArray())); return(command); }
/// <summary> /// Initializes a new instance of <see cref="TestContext"/>. /// </summary> /// <param name="subscriptions">The set of subscription metadata describing the Git repos that are listening for changes to base images.</param> /// <param name="allSubscriptionImagePaths">Multiple sets of mappings between subscriptions and their associated image paths.</param> /// <param name="hasInProgressBuild">A value indicating whether to mark a build to be in progress for all pipelines.</param> public TestContext( Subscription[] subscriptions, IEnumerable <IEnumerable <SubscriptionImagePaths> > allSubscriptionImagePaths, bool hasInProgressBuild = false) { this.allSubscriptionImagePaths = allSubscriptionImagePaths; this.hasInProgressBuild = hasInProgressBuild; this.subscriptionsPath = this.SerializeJsonObjectToTempFile(subscriptions); TeamProject project = new TeamProject { Id = Guid.NewGuid() }; Mock <IProjectHttpClient> projectHttpClientMock = CreateProjectHttpClientMock(project); this.buildHttpClientMock = CreateBuildHttpClientMock(project, hasInProgressBuild); Mock <IVssConnectionFactory> connectionFactoryMock = CreateVssConnectionFactoryMock( projectHttpClientMock, this.buildHttpClientMock); this.command = this.CreateCommand(connectionFactoryMock); }