예제 #1
0
        public void GetTwinThatExists()
        {
            CreateEndpointFixtures(out var site, out var super, out var endpoints, out var devices);
            var first = endpoints.First();
            var id    = EndpointInfoModelEx.CreateEndpointId(first.ApplicationId,
                                                             first.Registration.EndpointUrl, first.Registration.Endpoint.SecurityMode,
                                                             first.Registration.Endpoint.SecurityPolicy);

            using (var mock = AutoMock.GetLoose()) {
                mock.Provide <IIoTHubTwinServices>(new IoTHubServices(devices));
                var service = mock.Create <RegistryServices>();

                // Run
                var result = service.GetEndpointAsync(id, false).Result;

                // Assert
                Assert.True(result.IsSameAs(endpoints.First()));
            }
        }
예제 #2
0
        public void GetTwinThatExists()
        {
            CreateEndpointFixtures(out var site, out var super, out var endpoints, out var devices);
            var first = endpoints.First();
            var id    = EndpointInfoModelEx.CreateEndpointId(first.ApplicationId,
                                                             first.Registration.EndpointUrl, first.Registration.Endpoint.SecurityMode,
                                                             first.Registration.Endpoint.SecurityPolicy);

            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>();
            })) {
                IEndpointRegistry service = mock.Create <EndpointRegistry>();

                // Run
                var result = service.GetEndpointAsync(id, false).Result;

                // Assert
                Assert.True(result.IsSameAs(endpoints.First()));
            }
        }