Beispiel #1
0
        public void PropertyManipulation(int propertyCount)
        {
            var data = new InternalEntityEntry.StateData(propertyCount);

            Assert.False(data.AnyPropertiesFlagged());

            for (var i = 0; i < propertyCount; i++)
            {
                data.FlagProperty(i, true);

                for (var j = 0; j < propertyCount; j++)
                {
                    Assert.Equal(j <= i, data.IsPropertyFlagged(j));
                }

                Assert.True(data.AnyPropertiesFlagged());
            }

            for (var i = 0; i < propertyCount; i++)
            {
                data.FlagProperty(i, false);

                for (var j = 0; j < propertyCount; j++)
                {
                    Assert.Equal(j > i, data.IsPropertyFlagged(j));
                }

                Assert.Equal(i < propertyCount - 1, data.AnyPropertiesFlagged());
            }

            for (var i = 0; i < propertyCount; i++)
            {
                Assert.False(data.IsPropertyFlagged(i));
            }

            data.FlagAllProperties(propertyCount, isFlagged: true);

            Assert.Equal(propertyCount > 0, data.AnyPropertiesFlagged());

            for (var i = 0; i < propertyCount; i++)
            {
                Assert.True(data.IsPropertyFlagged(i));
            }

            data.FlagAllProperties(propertyCount, isFlagged: false);

            Assert.False(data.AnyPropertiesFlagged());

            for (var i = 0; i < propertyCount; i++)
            {
                Assert.False(data.IsPropertyFlagged(i));
            }
        }
Beispiel #2
0
        public void Can_get_and_set_EntityState()
        {
            var data = new InternalEntityEntry.StateData(70);

            Assert.Equal(EntityState.Detached, data.EntityState);

            data.EntityState = EntityState.Unchanged;
            Assert.Equal(EntityState.Unchanged, data.EntityState);

            data.EntityState = EntityState.Modified;
            Assert.Equal(EntityState.Modified, data.EntityState);

            data.EntityState = EntityState.Added;
            Assert.Equal(EntityState.Added, data.EntityState);

            data.EntityState = EntityState.Deleted;
            Assert.Equal(EntityState.Deleted, data.EntityState);

            data.FlagAllProperties(70, isFlagged: true);

            Assert.Equal(EntityState.Deleted, data.EntityState);

            data.EntityState = EntityState.Unchanged;
            Assert.Equal(EntityState.Unchanged, data.EntityState);

            data.EntityState = EntityState.Modified;
            Assert.Equal(EntityState.Modified, data.EntityState);

            data.EntityState = EntityState.Added;
            Assert.Equal(EntityState.Added, data.EntityState);

            data.EntityState = EntityState.Detached;
            Assert.Equal(EntityState.Detached, data.EntityState);
        }
Beispiel #3
0
        public void Can_get_and_set_sidecar_flag()
        {
            var data = new InternalEntityEntry.StateData(70);

            Assert.False(data.TransparentSidecarInUse);

            data.TransparentSidecarInUse = true;
            Assert.True(data.TransparentSidecarInUse);

            data.TransparentSidecarInUse = false;
            Assert.False(data.TransparentSidecarInUse);

            data.FlagAllProperties(70, isFlagged: true);

            Assert.False(data.TransparentSidecarInUse);

            data.TransparentSidecarInUse = true;
            Assert.True(data.TransparentSidecarInUse);

            data.TransparentSidecarInUse = false;
        }
Beispiel #4
0
        private void PropertyManipulation(
            int propertyCount,
            InternalEntityEntry.PropertyFlag propertyFlag,
            InternalEntityEntry.PropertyFlag unusedFlag1,
            InternalEntityEntry.PropertyFlag unusedFlag2)
        {
            var data = new InternalEntityEntry.StateData(propertyCount);

            Assert.False(data.AnyPropertiesFlagged(propertyFlag));
            Assert.False(data.AnyPropertiesFlagged(unusedFlag1));
            Assert.False(data.AnyPropertiesFlagged(unusedFlag2));

            for (var i = 0; i < propertyCount; i++)
            {
                data.FlagProperty(i, propertyFlag, true);

                for (var j = 0; j < propertyCount; j++)
                {
                    Assert.Equal(j <= i, data.IsPropertyFlagged(j, propertyFlag));
                    Assert.False(data.IsPropertyFlagged(j, unusedFlag1));
                    Assert.False(data.IsPropertyFlagged(j, unusedFlag2));
                }

                Assert.True(data.AnyPropertiesFlagged(propertyFlag));
                Assert.False(data.AnyPropertiesFlagged(unusedFlag1));
                Assert.False(data.AnyPropertiesFlagged(unusedFlag2));
            }

            for (var i = 0; i < propertyCount; i++)
            {
                data.FlagProperty(i, propertyFlag, false);

                for (var j = 0; j < propertyCount; j++)
                {
                    Assert.Equal(j > i, data.IsPropertyFlagged(j, propertyFlag));
                    Assert.False(data.IsPropertyFlagged(j, unusedFlag1));
                    Assert.False(data.IsPropertyFlagged(j, unusedFlag2));
                }

                Assert.Equal(i < propertyCount - 1, data.AnyPropertiesFlagged(propertyFlag));
                Assert.False(data.AnyPropertiesFlagged(unusedFlag1));
                Assert.False(data.AnyPropertiesFlagged(unusedFlag2));
            }

            for (var i = 0; i < propertyCount; i++)
            {
                Assert.False(data.IsPropertyFlagged(i, propertyFlag));
                Assert.False(data.IsPropertyFlagged(i, unusedFlag1));
                Assert.False(data.IsPropertyFlagged(i, unusedFlag2));
            }

            data.FlagAllProperties(propertyCount, propertyFlag, flagged: true);

            Assert.Equal(propertyCount > 0, data.AnyPropertiesFlagged(propertyFlag));
            Assert.False(data.AnyPropertiesFlagged(unusedFlag1));
            Assert.False(data.AnyPropertiesFlagged(unusedFlag2));

            for (var i = 0; i < propertyCount; i++)
            {
                Assert.True(data.IsPropertyFlagged(i, propertyFlag));
                Assert.False(data.IsPropertyFlagged(i, unusedFlag1));
                Assert.False(data.IsPropertyFlagged(i, unusedFlag2));
            }

            data.FlagAllProperties(propertyCount, propertyFlag, flagged: false);

            Assert.False(data.AnyPropertiesFlagged(propertyFlag));
            Assert.False(data.AnyPropertiesFlagged(unusedFlag1));
            Assert.False(data.AnyPropertiesFlagged(unusedFlag2));

            for (var i = 0; i < propertyCount; i++)
            {
                Assert.False(data.IsPropertyFlagged(i, propertyFlag));
                Assert.False(data.IsPropertyFlagged(i, unusedFlag1));
                Assert.False(data.IsPropertyFlagged(i, unusedFlag2));
            }
        }