public void CreatePluginProfiles(string accountName, string[] pluginProfileNames) { _profiles = pluginProfileNames.Select(x => new Profile { Name = x }).OfType <IProfile>().ToList(); var enumerator = _profiles.GetEnumerator(); _account.Profiles.Stub(x => x.GetEnumerator()).Return(enumerator); _profiles.ForEach(x => _account.Profiles.Stub(y => y[x.Name]).Return(x)); AccountCollection.Stub(x => x.GetOrCreate(accountName)).Return(_account); foreach (var profile in _profiles) { ProfileGatewayFactory.Stub(y => y.Create(_account.Name, profile)).Return( MockRepository.GenerateStub <IProfileGateway>()); } }