public void Can_use_PropertyAccessorsFactory_on_indexed_property()
    {
        var modelBuilder      = InMemoryTestHelpers.Instance.CreateConventionBuilder();
        var entityTypeBuilder = modelBuilder.Entity <IndexedClass>();

        entityTypeBuilder.Property <int>("Id");
        var propertyA = entityTypeBuilder.IndexerProperty <string>("PropertyA").Metadata;

        var model = modelBuilder.FinalizeModel();

        var contextServices = InMemoryTestHelpers.Instance.CreateContextServices(model);
        var stateManager    = contextServices.GetRequiredService <IStateManager>();

        var entity = new IndexedClass();
        var entry  = new InternalEntityEntry(stateManager, (IEntityType)entityTypeBuilder.Metadata, entity);

        var propertyAccessors = new PropertyAccessorsFactory().Create((IProperty)propertyA);

        Assert.Equal("ValueA", ((Func <InternalEntityEntry, string>)propertyAccessors.CurrentValueGetter)(entry));
        Assert.Equal("ValueA", ((Func <InternalEntityEntry, string>)propertyAccessors.OriginalValueGetter)(entry));
        Assert.Equal("ValueA", ((Func <InternalEntityEntry, string>)propertyAccessors.PreStoreGeneratedCurrentValueGetter)(entry));
        Assert.Equal("ValueA", ((Func <InternalEntityEntry, string>)propertyAccessors.RelationshipSnapshotGetter)(entry));

        var valueBuffer = new ValueBuffer(new object[] { 1, "ValueA" });

        Assert.Equal("ValueA", propertyAccessors.ValueBufferGetter(valueBuffer));
    }
    public void Delegate_setter_can_set_index_properties()
    {
        var entityType = CreateModel().AddEntityType(typeof(IndexedClass));
        var propertyA  = entityType.AddIndexerProperty("PropertyA", typeof(string));
        var propertyB  = entityType.AddIndexerProperty("PropertyB", typeof(int));

        var indexedClass = new IndexedClass {
            Id = 7
        };

        Assert.Equal("ValueA", indexedClass["PropertyA"]);
        Assert.Equal(123, indexedClass["PropertyB"]);

        new ClrPropertySetterFactory().Create((IProperty)propertyA).SetClrValue(indexedClass, "UpdatedValue");
        new ClrPropertySetterFactory().Create((IProperty)propertyB).SetClrValue(indexedClass, 42);

        Assert.Equal("UpdatedValue", indexedClass["PropertyA"]);
        Assert.Equal(42, indexedClass["PropertyB"]);
    }