public void QueryDiscoverersByDiscoveryMode() { CreateDiscovererFixtures(out var site, out var discoverers, out var modules); using (var mock = AutoMock.GetLoose(builder => { var hub = IoTHubServices.Create(modules); builder.RegisterType <NewtonSoftJsonConverters>().As <IJsonSerializerConverterProvider>(); builder.RegisterType <NewtonSoftJsonSerializer>().As <IJsonSerializer>(); builder.RegisterInstance(hub).As <IIoTHubTwinServices>(); })) { IDiscovererRegistry service = mock.Create <DiscovererRegistry>(); // Run var records = service.QueryDiscoverersAsync(new DiscovererQueryModel { Discovery = DiscoveryMode.Network }, null).Result; // Assert Assert.True(records.Items.Count == discoverers.Count(x => x.RequestedMode == DiscoveryMode.Network)); } }
public void QueryDiscoverersByNoneExistantSiteId() { CreateDiscovererFixtures(out _, out _, out var modules, true); using (var mock = AutoMock.GetLoose(builder => { var hub = IoTHubServices.Create(modules); builder.RegisterType <NewtonSoftJsonConverters>().As <IJsonSerializerConverterProvider>(); builder.RegisterType <NewtonSoftJsonSerializer>().As <IJsonSerializer>(); builder.RegisterInstance(hub).As <IIoTHubTwinServices>(); })) { IDiscovererRegistry service = mock.Create <DiscovererRegistry>(); // Run var records = service.QueryDiscoverersAsync(new DiscovererQueryModel { SiteId = "test" }, null).Result; // Assert Assert.True(records.Items.Count == 0); } }