public void DisableEnableApplication() { CreateAppFixtures(out var site, out var super, out var apps, out var devices); using (var mock = AutoMock.GetLoose()) { var hub = IoTHubServices.Create(devices); mock.Provide <IIoTHubTwinServices>(hub); mock.Provide <IApplicationRepository, ApplicationTwins>(); IApplicationRegistry service = mock.Create <ApplicationRegistry>(); var app = apps.First(); service.DisableApplicationAsync(app.ApplicationId, null).Wait(); var registration = service.GetApplicationAsync(app.ApplicationId, false).Result; Assert.NotNull(registration.Application.NotSeenSince); service.EnableApplicationAsync(app.ApplicationId, null).Wait(); registration = service.GetApplicationAsync(app.ApplicationId, false).Result; Assert.Null(registration.Application.NotSeenSince); } }
public void DisableEnableApplication() { 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>(); var app = apps.First(); service.DisableApplicationAsync(app.ApplicationId, null).Wait(); var registration = service.GetApplicationAsync(app.ApplicationId, false).Result; Assert.NotNull(registration.Application.NotSeenSince); service.EnableApplicationAsync(app.ApplicationId, null).Wait(); registration = service.GetApplicationAsync(app.ApplicationId, false).Result; Assert.Null(registration.Application.NotSeenSince); } }