public void Creates_mixed_entry_from_value_buffer_when_entity_CLR_entity_type_and_shadow_properties() { var entityType = new EntityType(typeof(RedHook)); var property1 = entityType.GetOrAddProperty("Long", typeof(int)); var property2 = entityType.GetOrAddProperty("Hammer", typeof(string), shadowProperty: true); var servicesMock = new Mock <ContextServices>(); servicesMock.Setup(m => m.ClrPropertyGetterSource).Returns(new ClrPropertyGetterSource()); var configurationMock = new Mock <DbContextConfiguration>(); configurationMock.Setup(m => m.Services).Returns(servicesMock.Object); var entry = new StateEntryFactory(configurationMock.Object, new EntityMaterializerSource(new MemberMapper(new FieldMatcher()))) .Create(entityType, new ObjectArrayValueReader(new object[] { "Green", 77 })); Assert.IsType <MixedStateEntry>(entry); Assert.Same(configurationMock.Object, entry.Configuration); Assert.Same(entityType, entry.EntityType); Assert.Equal(77, entry[property1]); Assert.Equal("Green", entry[property2]); var entity = (RedHook)entry.Entity; Assert.Equal(77, entity.Long); Assert.Null(entity.Hammer); }
public void Creates_mixed_entry_when_entity_CLR_entity_type_and_shadow_properties() { var entityType = new EntityType(typeof(RedHook)); entityType.GetOrAddProperty("Long", typeof(int)); entityType.GetOrAddProperty("Hammer", typeof(string), shadowProperty: true); var servicesMock = new Mock <ContextServices>(); servicesMock.Setup(m => m.ClrPropertyGetterSource).Returns(new ClrPropertyGetterSource()); var configurationMock = new Mock <DbContextConfiguration>(); configurationMock.Setup(m => m.Services).Returns(servicesMock.Object); var entity = new RedHook(); var entry = new StateEntryFactory( configurationMock.Object, new EntityMaterializerSource(new MemberMapper(new FieldMatcher()))).Create(entityType, entity); Assert.IsType <MixedStateEntry>(entry); Assert.Same(configurationMock.Object, entry.Configuration); Assert.Same(entityType, entry.EntityType); Assert.Same(entity, entry.Entity); }
public ThrowingMonsterStateManager( DbContextConfiguration configuration, StateEntryFactory factory, EntityKeyFactorySource entityKeyFactorySource, StateEntrySubscriber subscriber) : base(configuration, factory, entityKeyFactorySource, subscriber) { }
public ThrowingMonsterStateManager( StateEntryFactory factory, EntityKeyFactorySource entityKeyFactorySource, StateEntrySubscriber subscriber, StateEntryNotifier notifier, ValueGenerationManager valueGeneration, DbContextService <IModel> model, DbContextService <DataStore> dataStore) : base(factory, entityKeyFactorySource, subscriber, notifier, valueGeneration, model, dataStore) { }
public StateEntryQueryBuffer( [NotNull] StateManager stateManager, [NotNull] EntityKeyFactorySource entityKeyFactorySource, [NotNull] StateEntryFactory stateEntryFactory) { Check.NotNull(stateManager, "stateManager"); Check.NotNull(entityKeyFactorySource, "entityKeyFactorySource"); Check.NotNull(stateEntryFactory, "stateEntryFactory"); _stateManager = stateManager; _entityKeyFactorySource = entityKeyFactorySource; _stateEntryFactory = stateEntryFactory; }
public void Creates_shadow_state_only_entry_when_entity_is_fully_shadow_state() { var entityType = new EntityType("RedHook"); entityType.GetOrAddProperty("Long", typeof(int), shadowProperty: true); entityType.GetOrAddProperty("Hammer", typeof(string), shadowProperty: true); var servicesMock = new Mock <ContextServices>(); servicesMock.Setup(m => m.ClrPropertyGetterSource).Returns(new ClrPropertyGetterSource()); var configurationMock = new Mock <DbContextConfiguration>(); configurationMock.Setup(m => m.Services).Returns(servicesMock.Object); var entry = new StateEntryFactory( configurationMock.Object, new EntityMaterializerSource(new MemberMapper(new FieldMatcher()))).Create(entityType, new Random()); Assert.IsType <ShadowStateEntry>(entry); Assert.Same(configurationMock.Object, entry.Configuration); Assert.Same(entityType, entry.EntityType); Assert.Null(entry.Entity); }
public void Creates_shadow_state_only_entry_from_value_buffer_when_entity_is_fully_shadow_state() { var entityType = new EntityType("RedHook"); var property1 = entityType.AddProperty("Long", typeof(int), shadowProperty: true, concurrencyToken: false); var property2 = entityType.AddProperty("Hammer", typeof(string), shadowProperty: true, concurrencyToken: false); var servicesMock = new Mock <ContextServices>(); servicesMock.Setup(m => m.ClrPropertyGetterSource).Returns(new ClrPropertyGetterSource()); var configurationMock = new Mock <DbContextConfiguration>(); configurationMock.Setup(m => m.Services).Returns(servicesMock.Object); var entry = new StateEntryFactory(configurationMock.Object, new EntityMaterializerSource(new MemberMapper(new FieldMatcher()))) .Create(entityType, new ObjectArrayValueReader(new object[] { "Green", 77 })); Assert.IsType <ShadowStateEntry>(entry); Assert.Same(configurationMock.Object, entry.Configuration); Assert.Same(entityType, entry.EntityType); Assert.Equal(77, entry[property1]); Assert.Equal("Green", entry[property2]); Assert.Null(entry.Entity); }