Ejemplo n.º 1
0
    public void Identity_conflict_throws_for_owned_composite_primary_key_logged()
    {
        using var context = new SensitiveIdentityConflictContext();
        context.Attach(
            new CompositeKey
        {
            Id1          = 77,
            Id2          = 78,
            AlternateId1 = 66,
            AlternateId2 = 67,
            Owned        = new CompositeKeyOwned()
        });

        var duplicateOwned = new CompositeKeyOwned();

        context.Entry(duplicateOwned).Property("CompositeKeyId1").CurrentValue = 77;
        context.Entry(duplicateOwned).Property("CompositeKeyId2").CurrentValue = 78;

        Assert.Equal(
            CoreStrings.IdentityConflictOwnedSensitive("CompositeKeyOwned", "{CompositeKeyId1: 77, CompositeKeyId2: 78}"),
            Assert.Throws <InvalidOperationException>(
                () => context.Attach(
                    new CompositeKey
        {
            Id1          = 177,
            Id2          = 178,
            AlternateId1 = 166,
            AlternateId2 = 168,
            Owned        = duplicateOwned
        })).Message);
    }
Ejemplo n.º 2
0
    public void Identity_conflict_throws_for_owned_primary_keylogged()
    {
        using var context = new SensitiveIdentityConflictContext();
        context.Attach(
            new SingleKey
        {
            Id          = 77,
            AlternateId = 66,
            Owned       = new SingleKeyOwned()
        });

        var duplicateOwned = new SingleKeyOwned();

        context.Entry(duplicateOwned).Property("SingleKeyId").CurrentValue = 77;

        Assert.Equal(
            CoreStrings.IdentityConflictOwnedSensitive("SingleKeyOwned", "{SingleKeyId: 77}"),
            Assert.Throws <InvalidOperationException>(
                () => context.Attach(
                    new SingleKey
        {
            Id          = 78,
            AlternateId = 67,
            Owned       = duplicateOwned
        })).Message);
    }
Ejemplo n.º 3
0
        public void Identity_conflict_throws_for_composite_alternate_key_values_logged()
        {
            using (var context = new SensitiveIdentityConflictContext())
            {
                context.Attach(
                    new CompositeKey
                {
                    Id1          = 77,
                    Id2          = 78,
                    AlternateId1 = 66,
                    AlternateId2 = 67
                });

                Assert.Equal(
                    CoreStrings.IdentityConflictSensitive("CompositeKey", "{AlternateId1: 66, AlternateId2: 67}"),
                    Assert.Throws <InvalidOperationException>(
                        () => context.Attach(
                            new CompositeKey
                {
                    Id1          = 77,
                    Id2          = 79,
                    AlternateId1 = 66,
                    AlternateId2 = 67
                })).Message);
            }
        }
Ejemplo n.º 4
0
    public void Identity_conflict_throws_for_alternate_key_values_logged()
    {
        using var context = new SensitiveIdentityConflictContext();
        context.Attach(
            new SingleKey {
            Id = 77, AlternateId = 66
        });

        Assert.Equal(
            CoreStrings.IdentityConflictSensitive("SingleKey", "{AlternateId: 66}"),
            Assert.Throws <InvalidOperationException>(
                () => context.Attach(
                    new SingleKey {
            Id = 78, AlternateId = 66
        })).Message);
    }