Exemple #1
0
        public void Can_set_and_get_concurrency_token_original_value_generic_full_notification_entities()
        {
            var entity = new FullyNotifyingWotty {
                Id = 1, ConcurrentPrimate = "Monkey"
            };

            var entry = InMemoryTestHelpers.Instance.CreateInternalEntry(
                BuildModel(),
                EntityState.Unchanged,
                entity);

            Assert.Equal("Monkey", new PropertyEntry <FullyNotifyingWotty, string>(entry, "ConcurrentPrimate").OriginalValue);

            new PropertyEntry <FullyNotifyingWotty, string>(entry, "ConcurrentPrimate").OriginalValue = "Chimp";

            Assert.Equal("Chimp", new PropertyEntry <FullyNotifyingWotty, string>(entry, "ConcurrentPrimate").OriginalValue);
            Assert.Equal("Monkey", entity.ConcurrentPrimate);
        }
Exemple #2
0
        public void Can_set_or_get_original_value_when_property_explicitly_marked_to_be_tracked_generic()
        {
            var entity = new FullyNotifyingWotty {
                Id = 1, Primate = "Monkey"
            };

            var entry = InMemoryTestHelpers.Instance.CreateInternalEntry(
                BuildModel(ChangeTrackingStrategy.ChangingAndChangedNotificationsWithOriginalValues),
                EntityState.Unchanged,
                entity);

            Assert.Equal("Monkey", new PropertyEntry <FullyNotifyingWotty, string>(entry, "Primate").OriginalValue);

            new PropertyEntry <FullyNotifyingWotty, string>(entry, "Primate").OriginalValue = "Chimp";

            Assert.Equal("Chimp", new PropertyEntry <FullyNotifyingWotty, string>(entry, "Primate").OriginalValue);
            Assert.Equal("Monkey", entity.Primate);
        }
Exemple #3
0
        public void Cannot_set_or_get_original_value_when_not_tracked_generic()
        {
            var entity = new FullyNotifyingWotty {
                Id = 1, ConcurrentPrimate = "Monkey"
            };

            var entry = InMemoryTestHelpers.Instance.CreateInternalEntry(
                BuildModel(),
                EntityState.Unchanged,
                entity);

            var propertyEntry = new PropertyEntry <FullyNotifyingWotty, string>(entry, "Primate");

            Assert.Equal(
                CoreStrings.OriginalValueNotTracked("Primate", "FullyNotifyingWotty"),
                Assert.Throws <InvalidOperationException>(() => propertyEntry.OriginalValue).Message);

            Assert.Equal(
                CoreStrings.OriginalValueNotTracked("Primate", "FullyNotifyingWotty"),
                Assert.Throws <InvalidOperationException>(() => propertyEntry.OriginalValue = "Chimp").Message);
        }
        public void Can_set_or_get_original_value_when_property_explicitly_marked_to_be_tracked_generic()
        {
            var entity = new FullyNotifyingWotty { Id = 1, Primate = "Monkey" };

            var entry = TestHelpers.Instance.CreateInternalEntry(
                BuildModel(ChangeTrackingStrategy.ChangingAndChangedNotificationsWithOriginalValues),
                EntityState.Unchanged,
                entity);

            Assert.Equal("Monkey", new PropertyEntry<FullyNotifyingWotty, string>(entry, "Primate").OriginalValue);

            new PropertyEntry<FullyNotifyingWotty, string>(entry, "Primate").OriginalValue = "Chimp";

            Assert.Equal("Chimp", new PropertyEntry<FullyNotifyingWotty, string>(entry, "Primate").OriginalValue);
            Assert.Equal("Monkey", entity.Primate);
        }
        public void Cannot_set_or_get_original_value_when_not_tracked_generic()
        {
            var entity = new FullyNotifyingWotty { Id = 1, ConcurrentPrimate = "Monkey" };

            var entry = TestHelpers.Instance.CreateInternalEntry(
                BuildModel(),
                EntityState.Unchanged,
                entity);

            var propertyEntry = new PropertyEntry<FullyNotifyingWotty, string>(entry, "Primate");

            Assert.Equal(
                CoreStrings.OriginalValueNotTracked("Primate", "FullyNotifyingWotty"),
                Assert.Throws<InvalidOperationException>(() => propertyEntry.OriginalValue).Message);

            Assert.Equal(
                CoreStrings.OriginalValueNotTracked("Primate", "FullyNotifyingWotty"),
                Assert.Throws<InvalidOperationException>(() => propertyEntry.OriginalValue = "Chimp").Message);
        }
        public void Can_set_and_get_concurrency_token_original_value_generic_full_notification_entities()
        {
            var entity = new FullyNotifyingWotty { Id = 1, ConcurrentPrimate = "Monkey" };

            var entry = TestHelpers.Instance.CreateInternalEntry(
                BuildModel(),
                EntityState.Unchanged,
                entity);

            Assert.Equal("Monkey", new PropertyEntry<FullyNotifyingWotty, string>(entry, "ConcurrentPrimate").OriginalValue);

            new PropertyEntry<FullyNotifyingWotty, string>(entry, "ConcurrentPrimate").OriginalValue = "Chimp";

            Assert.Equal("Chimp", new PropertyEntry<FullyNotifyingWotty, string>(entry, "ConcurrentPrimate").OriginalValue);
            Assert.Equal("Monkey", entity.ConcurrentPrimate);
        }