Ejemplo n.º 1
0
        internal static WheelEventArgs Read(JsonElement jsonElement)
        {
            var eventArgs = new WheelEventArgs();

            foreach (var property in jsonElement.EnumerateObject())
            {
                if (property.NameEquals(DeltaX.EncodedUtf8Bytes))
                {
                    eventArgs.DeltaX = property.Value.GetDouble();
                }
                else if (property.NameEquals(DeltaY.EncodedUtf8Bytes))
                {
                    eventArgs.DeltaY = property.Value.GetDouble();
                }
                else if (property.NameEquals(DeltaZ.EncodedUtf8Bytes))
                {
                    eventArgs.DeltaZ = property.Value.GetDouble();
                }
                else if (property.NameEquals(DeltaMode.EncodedUtf8Bytes))
                {
                    eventArgs.DeltaMode = property.Value.GetInt64();
                }
                else
                {
                    MouseEventArgsReader.ReadProperty(eventArgs, property);
                }
            }

            return(eventArgs);
        }
Ejemplo n.º 2
0
        public void Read_Works()
        {
            // Arrange
            var args = new WheelEventArgs
            {
                AltKey    = false,
                CtrlKey   = true,
                MetaKey   = true,
                ShiftKey  = false,
                Type      = "type1",
                Detail    = 789,
                Button    = 7,
                Buttons   = 234,
                ClientX   = 3.2,
                ClientY   = 33.1,
                DeltaMode = 2,
                DeltaX    = 11.1,
                DeltaY    = 21.2,
                DeltaZ    = 9.1,
                OffsetX   = 7.2,
                OffsetY   = 1.2,
                PageX     = 5.6,
                PageY     = 7.8,
                ScreenX   = 3.56,
                ScreenY   = 8.32,
            };

            var jsonElement = GetJsonElement(args);

            // Act
            var result = WheelEventArgsReader.Read(jsonElement);

            // Assert
            MouseEventArgsReaderTest.AssertEqual(args, result);
            Assert.Equal(args.DeltaMode, result.DeltaMode);
            Assert.Equal(args.DeltaX, result.DeltaX);
            Assert.Equal(args.DeltaY, result.DeltaY);
            Assert.Equal(args.DeltaZ, result.DeltaZ);
        }