/// <summary>
        /// Helper to create fixtures
        /// </summary>
        /// <param name="site"></param>
        /// <param name="super"></param>
        /// <param name="existing"></param>
        /// <param name="found"></param>
        /// <param name="registry"></param>
        /// <param name="countDevices"></param>
        /// <param name="fixup"></param>
        /// <param name="disable"></param>
        private static void CreateFixtures(out string site, out string super,
                                           out List <ApplicationRegistrationModel> existing, out List <DiscoveryEventModel> found,
                                           out IoTHubServices registry, int countDevices = -1,
                                           Func <ApplicationRegistrationModel, ApplicationRegistrationModel> fixup = null,
                                           bool disable = false)
        {
            var fix = new Fixture();

            // Create template applications and endpoints
            fix.Customizations.Add(new TypeRelay(typeof(JToken), typeof(JObject)));
            var sitex = site = fix.Create <string>();

            var module = fix.Create <string>();
            var device = fix.Create <string>();
            var superx = super = SupervisorModelEx.CreateSupervisorId(device, module);

            var supervisor = (
                SupervisorRegistration.Patch(null,
                                             SupervisorRegistration.FromServiceModel(new SupervisorModel {
                SiteId = site,
                Id = superx
            })), new DeviceModel {
                Id = device, ModuleId = module
            });

            var template = fix
                           .Build <ApplicationRegistrationModel>()
                           .Without(x => x.Application)
                           .Do(c => c.Application = fix
                                                    .Build <ApplicationInfoModel>()
                                                    .Without(x => x.NotSeenSince)
                                                    .With(x => x.SiteId, sitex)
                                                    .With(x => x.SupervisorId, superx)
                                                    .Create())
                           .Without(x => x.Endpoints)
                           .Do(c => c.Endpoints = fix
                                                  .Build <EndpointRegistrationModel>()
                                                  .With(x => x.SiteId, sitex)
                                                  .With(x => x.SupervisorId, superx)
                                                  .CreateMany(5)
                                                  .ToList())
                           .CreateMany(5)
                           .ToList();

            template.ForEach(a =>
                             a.Application.ApplicationId =
                                 ApplicationInfoModelEx.CreateApplicationId(a.Application)
                             );

            // Create discovery results from template
            var i = 0; var now = DateTime.UtcNow;

            found = template
                    .SelectMany(a => a.Endpoints.Select(
                                    e => new DiscoveryEventModel {
                Application  = a.Application,
                Registration = e,
                Index        = i++,
                TimeStamp    = now
            }))
                    .ToList();

            // Clone and fixup existing applications as per test case
            existing = template
                       .Select(e => e.Clone())
                       .Select(fixup ?? (a => a))
                       .ToList();
            // and fill registry with them...
            var appdevices = existing
                             .Select(a => ApplicationRegistration.FromServiceModel(a.Application, disable))
                             .Select(a => ApplicationRegistration.Patch(null, a))
                             .Select(d => (d, new DeviceModel {
                Id = d.Id
            }));
            var epdevices = existing
                            .SelectMany(a => a.Endpoints
                                        .Select(e => EndpointRegistration.FromServiceModel(
                                                    new EndpointInfoModel {
                ApplicationId = a.Application.ApplicationId,
                Registration  = e
            }, disable)))
                            .Select(e => EndpointRegistration.Patch(null, e))
                            .Select(d => (d, new DeviceModel {
                Id = d.Id
            }));

            appdevices = appdevices.Concat(epdevices);
            if (countDevices != -1)
            {
                appdevices = appdevices.Take(countDevices);
            }
            registry = new IoTHubServices(appdevices.Concat(supervisor.YieldReturn()));
        }