Beispiel #1
0
        public static async Task PopulateTestData()
        {
            var dataService       = IoCActivator.ServiceProvider.GetRequiredService <IDataService>();
            var userManager       = IoCActivator.ServiceProvider.GetRequiredService <UserManager <RemotelyUser> >();
            var emailSender       = IoCActivator.ServiceProvider.GetRequiredService <IEmailSenderEx>();
            var organizationModel = new OrganizationModel(dataService, userManager, emailSender, Mock.Of <IHttpClientFactory>());


            await userManager.CreateAsync(Admin1);

            organizationModel.Input.UserEmail = Admin2.UserName;
            organizationModel.Input.IsAdmin   = true;
            await organizationModel.AddUser(Admin1);

            Admin2 = await userManager.FindByNameAsync(Admin2.UserName);

            organizationModel.Input.UserEmail = User1.UserName;
            organizationModel.Input.IsAdmin   = false;
            await organizationModel.AddUser(Admin1);

            User1 = await userManager.FindByNameAsync(User1.UserName);

            organizationModel.Input.UserEmail = User2.UserName;
            organizationModel.Input.IsAdmin   = false;
            await organizationModel.AddUser(Admin1);

            User2 = await userManager.FindByNameAsync(User2.UserName);

            Device1.OrganizationID = Admin1.OrganizationID;
            dataService.AddOrUpdateDevice(Device1, out _);
            Device2.OrganizationID = Admin1.OrganizationID;
            dataService.AddOrUpdateDevice(Device2, out _);

            dataService.AddDeviceGroup(Admin1.OrganizationID, Group1, out _, out _);
            dataService.AddDeviceGroup(Admin1.OrganizationID, Group2, out _, out _);
            var deviceGroups = dataService.GetDeviceGroups(Admin1.UserName);

            Group1 = deviceGroups.First(x => x.Name == Group1.Name);
            Group2 = deviceGroups.First(x => x.Name == Group2.Name);

            OrganizationID = Admin1.OrganizationID;
        }