public override void Setup()
        {
            base.Setup();
            DeviceInfo.SetCurrent(mockDeviceInfo = new MockDeviceInfo());
            var nsManager = new XmlNamespaceManager(new NameTable());

            nsManager.AddNamespace("local", "clr-namespace:Microsoft.Maui.Controls.Xaml.UnitTests;assembly=Microsoft.Maui.Controls.Xaml.UnitTests");
            nsManager.AddNamespace("x", "http://schemas.microsoft.com/winfx/2009/xaml");
            typeResolver = new Internals.XamlTypeResolver(nsManager, XamlParser.GetElementType, Assembly.GetCallingAssembly());
        }
        public void BaseHidDeviceInfoTest(string path, string description)
        {
            var stub = new StubNativeHelper();
            var mock = new MockDeviceInfo(path, description, stub);

            mock.IsNotNull();
            mock.DevicePath.Is(path);
            mock.Description.Is(description);

            mock.Capabilities.IsNotNull();
            stub.IsGetCapabilities.IsTrue();

            mock.Attributes.IsNotNull();
            stub.IsGetAttributes.IsTrue();
        }
        public async Task IncludesExpectedHeaders()
        {
            using (new MockServer(MockApiClientOptions.TestPort, string.Empty, (req, rsp, prm) =>
            {
                var appInfo = new MockAppInfo();
                var deviceInfo = new MockDeviceInfo();
                foreach (var key in req.Headers.AllKeys)
                {
                    TestOutputHelper.WriteLine($"{key}: {req.Headers.Get(key)}");
                }
                Assert.Contains("Authorization", req.Headers.AllKeys);
                Assert.Equal($"BEARER {MockAuthenticationHandler.Token}", req.Headers.Get("Authorization"));

                Assert.Contains("X-MobileAppVer", req.Headers.AllKeys);
                Assert.Equal(appInfo.VersionString, req.Headers.Get("X-MobileAppVer"));
                Assert.Contains("X-DeviceModel", req.Headers.AllKeys);
                Assert.Equal(deviceInfo.Model, req.Headers["X-DeviceModel"]);
                Assert.Contains("X-DeviceManufacturer", req.Headers.AllKeys);
                Assert.Equal(deviceInfo.Manufacturer, req.Headers["X-DeviceManufacturer"]);
                Assert.Contains("X-DeviceName", req.Headers.AllKeys);
                Assert.Equal(deviceInfo.Name, req.Headers["X-DeviceName"]);
                Assert.Contains("X-DevicePlatform", req.Headers.AllKeys);
                Assert.Equal(deviceInfo.Platform.ToString(), req.Headers["X-DevicePlatform"]);
                Assert.Contains("X-DeviceIdiom", req.Headers.AllKeys);
                Assert.Equal(deviceInfo.Idiom.ToString(), req.Headers["X-DeviceIdiom"]);
                Assert.Contains("User-Agent", req.Headers.AllKeys);
                Assert.Equal($"{appInfo.Name}/{appInfo.VersionString}", req.Headers["User-Agent"]);

                Assert.Contains("Cache-Control", req.Headers.AllKeys);
                Assert.Equal("no-cache", req.Headers["Cache-Control"]);

                Assert.Contains("Accept", req.Headers.AllKeys);
                Assert.Equal("application/json", req.Headers["Accept"]);
            }))
            {
                var client  = CreateClient();
                var service = new MockApiService(client);
                await service.MockGet();
            }
        }
Esempio n. 4
0
 public void Setup()
 {
     DeviceInfo.SetCurrent(mockDeviceInfo = new MockDeviceInfo());
 }
Esempio n. 5
0
 public override void Setup()
 {
     base.Setup();
     DeviceInfo.SetCurrent(mockDeviceInfo = new MockDeviceInfo());
 }
Esempio n. 6
0
 public void Setup()
 {
     DeviceInfo.SetCurrent(mockDeviceInfo = new MockDeviceInfo(platform: DevicePlatform.iOS));
     DispatcherProvider.SetCurrent(new DispatcherProviderStub());
 }
Esempio n. 7
0
 public void Setup()
 {
     DeviceInfo.SetCurrent(mockDeviceInfo = new MockDeviceInfo());
     Device.PlatformServices = new MockPlatformServices();
 }