/// <summary>
        /// Find applications
        /// </summary>
        /// <param name="service"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        public static async Task <List <ApplicationInfoModel> > QueryAllApplicationsAsync(
            this IApplicationRegistry service, ApplicationRegistrationQueryModel query)
        {
            var registrations = new List <ApplicationInfoModel>();
            var result        = await service.QueryApplicationsAsync(query);

            registrations.AddRange(result.Items);
            while (result.ContinuationToken != null)
            {
                result = await service.ListApplicationsAsync(result.ContinuationToken);

                registrations.AddRange(result.Items);
            }
            return(registrations);
        }
Пример #2
0
        public void ListAllApplicationsUsingQuery()
        {
            CreateAppFixtures(out var site, out var super, out var apps, out var devices);

            using (var mock = AutoMock.GetLoose()) {
                mock.Provide <IIoTHubTwinServices>(IoTHubServices.Create(devices));
                mock.Provide <IApplicationRepository, ApplicationTwins>();
                IApplicationRegistry service = mock.Create <ApplicationRegistry>();

                // Run
                var records = service.QueryApplicationsAsync(null, null).Result;

                // Assert
                Assert.True(apps.IsSameAs(records.Items));
            }
        }
Пример #3
0
        public void QueryApplicationsByApplicationNameDifferentCase()
        {
            CreateAppFixtures(out var site, out var super, out var apps, out var devices);

            using (var mock = AutoMock.GetLoose()) {
                mock.Provide <IIoTHubTwinServices>(IoTHubServices.Create(devices));
                mock.Provide <IApplicationRepository, ApplicationTwins>();
                IApplicationRegistry service = mock.Create <ApplicationRegistry>();

                // Run
                var records = service.QueryApplicationsAsync(new ApplicationRegistrationQueryModel {
                    ApplicationName = apps.First().ApplicationName.ToUpperInvariant()
                }, null).Result;

                // Assert
                Assert.True(records.Items.Count == 0);
            }
        }
Пример #4
0
        public void QueryApplicationsBySupervisorId()
        {
            CreateAppFixtures(out var site, out var super, out var apps, out var devices, true);

            using (var mock = AutoMock.GetLoose()) {
                mock.Provide <IIoTHubTwinServices>(IoTHubServices.Create(devices));
                mock.Provide <IApplicationRepository, ApplicationTwins>();
                IApplicationRegistry service = mock.Create <ApplicationRegistry>();

                // Run
                var records = service.QueryApplicationsAsync(new ApplicationRegistrationQueryModel {
                    SiteOrSupervisorId = super
                }, null).Result;

                // Assert
                Assert.True(apps.IsSameAs(records.Items));
            }
        }
Пример #5
0
        public void QueryApplicationsByDiscoveryServerApplicationType()
        {
            CreateAppFixtures(out var site, out var super, out var apps, out var devices);

            using (var mock = AutoMock.GetLoose()) {
                mock.Provide <IIoTHubTwinServices>(IoTHubServices.Create(devices));
                mock.Provide <IApplicationRepository, ApplicationTwins>();
                IApplicationRegistry service = mock.Create <ApplicationRegistry>();

                // Run
                var records = service.QueryApplicationsAsync(new ApplicationRegistrationQueryModel {
                    ApplicationType = ApplicationType.DiscoveryServer
                }, null).Result;

                // Assert
                Assert.Equal(apps.Count(x => x.ApplicationType == ApplicationType.DiscoveryServer), records.Items.Count);
            }
        }
        public void ListAllApplicationsUsingQuery()
        {
            CreateAppFixtures(out var site, out var super, out var apps, out var devices);

            using (var mock = AutoMock.GetLoose(builder => {
                var hub = IoTHubServices.Create(devices);
                builder.RegisterType <NewtonSoftJsonConverters>().As <IJsonSerializerConverterProvider>();
                builder.RegisterType <NewtonSoftJsonSerializer>().As <IJsonSerializer>();
                builder.RegisterInstance(hub).As <IIoTHubTwinServices>();
                builder.RegisterType <ApplicationTwins>().As <IApplicationRepository>();
            })) {
                IApplicationRegistry service = mock.Create <ApplicationRegistry>();

                // Run
                var records = service.QueryApplicationsAsync(null, null).Result;

                // Assert
                Assert.True(apps.IsSameAs(records.Items));
            }
        }
        public void QueryApplicationsByApplicationNameDifferentCase()
        {
            CreateAppFixtures(out var site, out var super, out var apps, out var devices);

            using (var mock = AutoMock.GetLoose(builder => {
                var hub = IoTHubServices.Create(devices);
                builder.RegisterType <NewtonSoftJsonConverters>().As <IJsonSerializerConverterProvider>();
                builder.RegisterType <NewtonSoftJsonSerializer>().As <IJsonSerializer>();
                builder.RegisterInstance(hub).As <IIoTHubTwinServices>();
                builder.RegisterType <ApplicationTwins>().As <IApplicationRepository>();
            })) {
                IApplicationRegistry service = mock.Create <ApplicationRegistry>();

                // Run
                var records = service.QueryApplicationsAsync(new ApplicationRegistrationQueryModel {
                    ApplicationName = apps.First().ApplicationName.ToUpperInvariant()
                }, null).Result;

                // Assert
                Assert.True(records.Items.Count == 0);
            }
        }
        public void QueryApplicationsByDiscoveryServerApplicationType()
        {
            CreateAppFixtures(out var site, out var super, out var apps, out var devices);

            using (var mock = AutoMock.GetLoose(builder => {
                var hub = IoTHubServices.Create(devices);
                builder.RegisterType <NewtonSoftJsonConverters>().As <IJsonSerializerConverterProvider>();
                builder.RegisterType <NewtonSoftJsonSerializer>().As <IJsonSerializer>();
                builder.RegisterInstance(hub).As <IIoTHubTwinServices>();
                builder.RegisterType <ApplicationTwins>().As <IApplicationRepository>();
            })) {
                IApplicationRegistry service = mock.Create <ApplicationRegistry>();

                // Run
                var records = service.QueryApplicationsAsync(new ApplicationRegistrationQueryModel {
                    ApplicationType = ApplicationType.DiscoveryServer
                }, null).Result;

                // Assert
                Assert.Equal(apps.Count(x => x.ApplicationType == ApplicationType.DiscoveryServer), records.Items.Count);
            }
        }