示例#1
0
        public async Task SetEnvironmentInfo_SetsProperty()
        {
            var sink = new PiwikSink(defaultOptions);

            var environment = new Core.EnvironmentInfo()
            {
                DeviceName      = "device name",
                DeviceType      = "device type",
                OperatingSystem = "operating system",
                DeviceScreen    = new Core.ScreenResolution()
                {
                    Width  = 123,
                    Height = 456,
                    Dpi    = 789
                }
            };

            await telemetryProvider.Activity.SetEnvironmentInfoAsync(environment);

            Assert.IsNotNull(sink.EnvironmentInfo);
            Assert.AreEqual(environment.DeviceName, sink.EnvironmentInfo.DeviceName);
            Assert.AreEqual(environment.DeviceType, sink.EnvironmentInfo.DeviceType);
            Assert.AreEqual(environment.OperatingSystem, sink.EnvironmentInfo.OperatingSystem);
            Assert.IsNotNull(sink.EnvironmentInfo.DeviceScreen);
            Assert.AreEqual(environment.DeviceScreen.Width, sink.EnvironmentInfo.DeviceScreen.Width);
            Assert.AreEqual(environment.DeviceScreen.Height, sink.EnvironmentInfo.DeviceScreen.Height);
            Assert.AreEqual(environment.DeviceScreen.Dpi, sink.EnvironmentInfo.DeviceScreen.Dpi);
        }
示例#2
0
 private async Task Activity_OnSetEnvironmentInfoAsync(object sender, Core.EnvironmentInfo environment)
 {
     using (await padlock.WriterLockAsync())
     {
         EnvironmentInfo = new Api.PiwikEnvironmentInfo()
         {
             DeviceName      = environment.DeviceName,
             DeviceType      = environment.DeviceType,
             OperatingSystem = environment.OperatingSystem,
         };
         if (null != environment.DeviceScreen)
         {
             EnvironmentInfo.DeviceScreen = new Api.PiwikScreenResolution()
             {
                 Dpi    = environment.DeviceScreen.Dpi,
                 Height = environment.DeviceScreen.Height,
                 Width  = environment.DeviceScreen.Width
             };
         }
     }
 }