public void CannotSwitchSpaceContextWhenTheRepositoryScopeIsSpecified(RepositoryScope scope) { var repository = Substitute.For <IOctopusAsyncRepository>(); repository.Scope.Returns(scope); ITeamsRepository teamRepo = new TeamsRepository(repository); Action switchContext = () => teamRepo.UsingContext(SpaceContext.AllSpaces()); switchContext.ShouldThrow <SpaceContextSwitchException>(); }
public async Task NonSingleSpaceContextShouldNotChangeExistingSpaceId(string spaceIdsToUse, bool includeSystem) { var spaceIds = spaceIdsToUse.Split(','); var client = SetupAsyncClient(); await client.Create(Arg.Any <string>(), Arg.Do <TeamResource>(t => t.SpaceId.Should().Be("Spaces-4"))).ConfigureAwait(false); var teamRepo = new TeamsRepository(new OctopusAsyncRepository(client, RepositoryScope.Unspecified())); var multiScoped = teamRepo.UsingContext(SpaceContext.SpecificSpacesAndSystem(spaceIds.Select(CreateSpaceResource))); var _ = await multiScoped.Create(new TeamResource() { Name = "Test", SpaceId = "Spaces-4" }).ConfigureAwait(false); }
public async Task NonSingleSpaceContextShouldNotEnrichSpaceId(string includingSpaceId, bool includeSystem) { var client = SetupAsyncClient(); await client.Create(Arg.Any <string>(), Arg.Do <TeamResource>(t => { t.SpaceId.Should().BeNullOrEmpty(); })).ConfigureAwait(false); var includingSpaceContext = includeSystem ? SpaceContext.SpecificSpaceAndSystem(CreateSpaceResource(includingSpaceId)) : SpaceContext.SpecificSpace(CreateSpaceResource(includingSpaceId)); var teamRepo = new TeamsRepository(new OctopusAsyncRepository(client, RepositoryScope.Unspecified())); var multiScoped = teamRepo.UsingContext(includingSpaceContext); var _ = await multiScoped.Create(new TeamResource() { Name = "Test" }).ConfigureAwait(false); }