Ejemplo n.º 1
0
        public static WebEventData Parse(
            Renderer renderer,
            JsonSerializerOptions jsonSerializerOptions,
            JsonElement eventDescriptorJson,
            JsonElement eventArgsJson)
        {
            WebEventDescriptor eventDescriptor;
            try
            {
                eventDescriptor = WebEventDescriptorReader.Read(eventDescriptorJson);
            }
            catch (Exception e)
            {
                throw new InvalidOperationException("Error parsing the event descriptor", e);
            }

            return Parse(renderer, jsonSerializerOptions, eventDescriptor, eventArgsJson);
        }
        public void Read_WithBoolValue_Works(bool value)
        {
            // Arrange
            var args = new WebEventDescriptor
            {
                EventFieldInfo = new EventFieldInfo
                {
                    ComponentId = 89,
                    FieldValue  = value,
                },
                EventHandlerId = 897,
                EventName      = "test1",
            };
            var jsonElement = GetJsonElement(args);

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

            // Assert
            Assert.Equal(args.EventHandlerId, result.EventHandlerId);
            Assert.Equal(args.EventName, result.EventName);
            Assert.Equal(args.EventFieldInfo.ComponentId, result.EventFieldInfo.ComponentId);
            Assert.Equal(args.EventFieldInfo.FieldValue, result.EventFieldInfo.FieldValue);
        }