public CreateProductTypeCommandHandler(
     IRepository <ProductType> productTypeRepository,
     IChangeTracker <ProductType> changeTracker)
 {
     _productTypeRepository = productTypeRepository;
     _changeTracker         = changeTracker;
 }
Ejemplo n.º 2
0
        public SQLTriggerBinding(ParameterInfo parameter, INameResolver nameResolver,
                                 IChangeTracker changeTracker, SQLTriggerAttribute attribute)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException(nameof(parameter));
            }
            if (nameResolver == null)
            {
                throw new ArgumentNullException(nameof(nameResolver));
            }
            if (attribute == null)
            {
                throw new ArgumentNullException(nameof(attribute));
            }
            if (changeTracker == null)
            {
                throw new ArgumentNullException(nameof(changeTracker));
            }

            this._parameter     = parameter;
            this._nameResolver  = nameResolver;
            this._attribute     = attribute;
            this._changeTracker = changeTracker;
        }
Ejemplo n.º 3
0
        private object AddElement <T>(IChangeTracker changeTracker, IEntityManager entityManager, T existing, object updateItem, object dbCollection)
        {
            if (!_isOwned)
            {
                updateItem = changeTracker.AttachAndReloadAssociatedEntity(updateItem);
            }
            else if (changeTracker.GetItemState(updateItem) == EntityState.Detached)
            {
                var instance = entityManager.CreateEmptyEntityWithKey(updateItem);

                changeTracker.AddItem(instance);
                changeTracker.UpdateItem(updateItem, instance);

                foreach (var childMember in Members)
                {
                    childMember.Update(changeTracker, entityManager, instance, updateItem);
                }

                updateItem = instance;
            }

            dbCollection.GetType().GetMethod("Add").Invoke(dbCollection, new[] { updateItem });

            if (_isOwned)
            {
                changeTracker.AttachCyclicNavigationProperty(existing, updateItem, GetMappedNaviationProperties());
            }

            return(updateItem);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FakeTrackableProxyClass"/> class.
 /// </summary>
 /// <param name="typeToProxy">The type to proxy.</param>
 /// <param name="proxyHydrator">The proxy hydrator.</param>
 public FakeTrackableProxyClass(Type typeToProxy, IProxyHydrator proxyHydrator)
 {
     _typeToProxy   = typeToProxy;
     _isLoaded      = (proxyHydrator == null);
     _proxyHydrator = proxyHydrator;
     _changeTracker = new ChangeTracker(GetInitialValues);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a instance of the NubeSync client
        /// </summary>
        /// <param name="dataStore">The local storage</param>
        /// <param name="url">The address of the server hosting the NubeSync REST APIs</param>
        /// <param name="authentication">Optional: a authentication provider, if the server requires the requests to be authenticated.</param>
        /// <param name="httpClient">Optional: the HttpClient that is used for communicating with the server.</param>
        /// <param name="changeTracker">Optional: the change tracker generating the operations.</param>
        public NubeClient(
            IDataStore dataStore,
            string?url = null,
            INubeAuthentication?authentication = null,
            HttpClient?httpClient        = null,
            IChangeTracker?changeTracker = null,
            string?operationsUrl         = null)
        {
            if (string.IsNullOrEmpty(url) && httpClient == null)
            {
                throw new Exception("Either the server url or a HttpClient instance has to be provided.");
            }

            _dataStore      = dataStore;
            _authentication = authentication;
            _httpClient     = httpClient ?? new HttpClient();
            _changeTracker  = changeTracker ?? new ChangeTracker();
            _operationsUrl  = operationsUrl ?? "/operations";

            _nubeTableTypes = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(url))
            {
                _httpClient.BaseAddress = new Uri(url);
            }
        }
        public override void Update <T>(IChangeTracker changeTracker, IEntityManager entityManager, T existing, T entity)
        {
            var innerElementType = GetCollectionElementType();
            var updateValues     = GetValue <IEnumerable>(entity) ?? new List <object>();
            var dbCollection     = GetValue <IEnumerable>(existing) ?? CreateMissingCollection(existing, innerElementType);

            var dbHash = dbCollection.Cast <object>().ToDictionary(item => entityManager.CreateEntityKey(item));

            // Iterate through the elements from the updated graph and try to match them against the db graph
            var updateList = updateValues.OfType <object>().ToList();

            for (int i = 0; i < updateList.Count; i++)
            {
                var updateItem = updateList[i];
                var key        = entityManager.CreateEntityKey(updateItem);

                // try to find item with same key in db collection
                object dbItem;
                if (dbHash.TryGetValue(key, out dbItem))
                {
                    UpdateElement(changeTracker, entityManager, existing, updateItem, dbItem);
                    dbHash.Remove(key);
                }
                else
                {
                    updateList[i] = AddElement(changeTracker, entityManager, existing, updateItem, dbCollection);
                }
            }

            // remove obsolete items
            foreach (var dbItem in dbHash.Values)
            {
                RemoveElement(changeTracker, dbItem, dbCollection);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        ///     Parses the relationship.
        /// </summary>
        /// <param name="relationship">The relationship.</param>
        /// <param name="invalidObjects">The invalid objects.</param>
        private void ParseRelationship(IChangeTracker <IMutableIdKey> relationship, ISet <long> invalidObjects)
        {
            /////
            // Argument check.
            /////
            if (relationship == null)
            {
                return;
            }

            if (invalidObjects == null)
            {
                /////
                // Reinitialize the set.
                /////
                invalidObjects = new HashSet <long>( );
            }

            if (relationship.Flushed)
            {
                /////
                // All entities are invalid.
                /////
                foreach (var modification in relationship.Where(pair => pair != null))
                {
                    invalidObjects.Add(modification.Key);
                }

                return;
            }

            /////
            // Process the added relationships.
            /////
            if (relationship.Added != null && relationship.Added.Any( ))
            {
                /////
                // All added entities are invalid.
                /////
                foreach (var modification in relationship.Added.Where(pair => pair != null))
                {
                    invalidObjects.Add(modification.Key);
                }
            }

            /////
            // Process the removed relationships.
            /////
            if (relationship.Removed != null && relationship.Removed.Any( ))
            {
                /////
                // All removed entities are invalid.
                /////
                foreach (var modification in relationship.Removed.Where(pair => pair != null))
                {
                    invalidObjects.Add(modification.Key);
                }
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 ///     Sets the entity relationships.
 /// </summary>
 /// <param name="entityId">The entity id.</param>
 /// <param name="relationshipId">The relationship id.</param>
 /// <param name="direction">The direction.</param>
 /// <param name="value">The value.</param>
 internal void SetEntityRelationships(long entityId, long relationshipId, Direction direction, IChangeTracker <IMutableIdKey> value)
 {
     if (IsValid)
     {
         string key = string.Format("{0}.{1}.{2}", entityId, relationshipId, direction);
         _entityRelationshipCache[key] = value;
     }
 }
Ejemplo n.º 9
0
 public Repository()
 {
     Items = new Dictionary <Guid, BaseModel>();
     _proxyClassBuilder = new ProxyClassBuilder(this);
     ChangeTracker      = new RepositoryChangeTracker {
         Repository = this
     };
 }
Ejemplo n.º 10
0
 internal AppLibraryStore(Settings settings, XmlStore inner, IChangeTracker changeTracker)
 {
     Ensure.NotNull(settings, "settings");
     Ensure.NotNull(inner, "inner");
     Ensure.NotNull(changeTracker, "changeTracker");
     this.settings      = settings;
     this.inner         = inner;
     this.changeTracker = changeTracker;
 }
Ejemplo n.º 11
0
 public DeleteMovieCommand(MovieCollection collection, INavigator navigator, IChangeTracker changeTracker)
 {
     Ensure.NotNull(collection, "collection");
     Ensure.NotNull(navigator, "navigator");
     Ensure.NotNull(changeTracker, "changeTracker");
     this.collection    = collection;
     this.navigator     = navigator;
     this.changeTracker = changeTracker;
 }
Ejemplo n.º 12
0
 public AppNavigator(App application, ILibraryStore store, IChangeTracker changeTracker)
 {
     Ensure.NotNull(application, "application");
     Ensure.NotNull(store, "store");
     Ensure.NotNull(changeTracker, "changeTracker");
     this.application   = application;
     this.store         = store;
     this.changeTracker = changeTracker;
 }
        /// <summary>
        /// Adds an element with the provided key and value to the <see cref="T:System.Collections.Generic.IDictionary`2" />.
        /// </summary>
        /// <param name="key">The object to use as the key of the element to add.</param>
        /// <param name="value">The object to use as the value of the element to add.</param>
        public void Add(long key, IChangeTracker <IMutableIdKey> value)
        {
            if (!IsAttached)
            {
                Attach( );
            }

            Value.Add(key, value);
        }
Ejemplo n.º 14
0
 /// <inheritdoc />
 public MyOrm(
     IDatabaseDriver driver,
     ISqlStatementBuilder sqlBuilder,
     IChangeTracker changeTracker)
 {
     _dbDriver     = driver;
     _sqlBuilder   = sqlBuilder;
     ChangeTracker = changeTracker;
 }
Ejemplo n.º 15
0
        private object CreateNewPersistedEntity <T>(IChangeTracker changeTracker, T existing, object newValue) where T : class
        {
            var instance = Activator.CreateInstance(newValue.GetType(), true);

            SetValue(existing, instance);
            changeTracker.AddItem(instance);
            changeTracker.UpdateItem(newValue, instance);
            return(instance);
        }
Ejemplo n.º 16
0
        // overridden by different implementations
        public virtual void Update <T>(IChangeTracker changeTracker, IEntityManager entityManager, T persisted, T updating) where T : class
        {
            changeTracker.UpdateItem(updating, persisted, true);

            // Foreach branch perform recursive update
            foreach (var member in Members)
            {
                member.Update(changeTracker, entityManager, persisted, updating);
            }
        }
Ejemplo n.º 17
0
        private void RemoveElement(IChangeTracker changeTracker, object dbItem, object dbCollection)
        {
            dbCollection.GetType().GetMethod("Remove").Invoke(dbCollection, new[] { dbItem });
            changeTracker.AttachRequiredNavigationProperties(dbItem, dbItem);

            if (_isOwned)
            {
                changeTracker.RemoveItem(dbItem);
            }
        }
Ejemplo n.º 18
0
 public TodoItemsController(
     IAuthentication authentication,
     IOperationService operationService,
     IChangeTracker changeTracker,
     DataContext context)
 {
     _authentication   = authentication;
     _operationService = operationService;
     _changeTracker    = changeTracker;
     _context          = context;
 }
Ejemplo n.º 19
0
 public ImpactController(
     ILoggerFactory loggerFactory,
     TelemetryClient telemetry,
     IHttpContextAccessor contextAccessor,
     IChangeTracker changeTracker)
 {
     _logger          = loggerFactory.CreateLogger <ImpactController>();
     _telemetry       = telemetry;
     _contextAccessor = contextAccessor;
     _changeTracker   = changeTracker;
 }
Ejemplo n.º 20
0
 public ChangeModelTester(bool startTrackingOnInit)
 {
     changeTracker = new ChangeTracker(LoadInitialValues);
     if (!startTrackingOnInit)
     {
         return;
     }
     changeTracker.Init();
     changeTracker.Start();
     Version = changeTracker.Version;
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PersistenceAction"/> class.
        /// </summary>
        /// <param name="mongoSession">The mongo session.</param>
        /// <param name="mongoSessionCache">The mongo session cache.</param>
        /// <param name="changeTracker">The change tracker.</param>
        public PersistenceAction(IMongoSessionImplementor mongoSession, IMongoSessionCache mongoSessionCache, IChangeTracker changeTracker)
        {
            if (mongoSession == null)
                throw new ArgumentNullException("mongoSession");
            if (mongoSessionCache == null)
                throw new ArgumentNullException("mongoSessionCache");
            if (changeTracker == null)
                throw new ArgumentNullException("changeTracker");

            this.ChangeTracker = changeTracker;
            this.MongoSessionCache = mongoSessionCache;
            this.MongoSession = mongoSession;
        }
Ejemplo n.º 22
0
 public RecipeRepository(
     ISessionHolder sessionHolder,
     IMongoDatabase mongoDatabase,
     IChangeTracker changeTracker)
 {
     this.sessionHolder = sessionHolder ?? throw new ArgumentNullException(nameof(sessionHolder));
     this.changeTracker = changeTracker ?? throw new ArgumentNullException(nameof(changeTracker));
     if (mongoDatabase == null)
     {
         throw new ArgumentNullException(nameof(mongoDatabase));
     }
     this.recipesCollection = mongoDatabase.GetCollection <Recipe>(RecipesCollectionName);
 }
Ejemplo n.º 23
0
        private void UpdateElement <T>(IChangeTracker changeTracker, IEntityManager entityManager, T existing, object updateItem, object dbItem)
        {
            if (!_isOwned)
            {
                return;
            }

            changeTracker.UpdateItem(updateItem, dbItem);
            changeTracker.AttachCyclicNavigationProperty(existing, updateItem, GetMappedNaviationProperties());

            foreach (var childMember in Members)
            {
                childMember.Update(changeTracker, entityManager, dbItem, updateItem);
            }
        }
Ejemplo n.º 24
0
        public MovieEditWindow(INavigator navigator, IChangeTracker changeTracker, Library library, Movie model)
            : base(navigator, library)
        {
            Ensure.NotNull(changeTracker, "changeTracker");
            Ensure.NotNull(library, "library");

            InitializeComponent();

            kebClose.Command = new DelegateCommand(Close);

            this.changeTracker   = changeTracker;
            this.library         = library;
            this.modelDefinition = library.MovieDefinition;
            this.model           = model;
        }
Ejemplo n.º 25
0
        private void Init()
        {
            _container.Configure(_ =>
            {
                _.Scan(s =>
                {
                    s.TheCallingAssembly();
                    s.WithDefaultConventions();
                });

                _.For <IChangeTracker>().Singleton();
            });

            _tracker = _container.GetInstance <IChangeTracker>();
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Creates a instance of the NubeSync client
        /// </summary>
        /// <param name="dataStore">The local storage</param>
        /// <param name="url">The address of the server hosting the NubeSync REST APIs</param>
        /// <param name="authentication">Optional: a authentication provider, if the server requires the requests to be authenticated.</param>
        /// <param name="httpClient">Optional: the HttpClient that is used for communicating with the server.</param>
        /// <param name="changeTracker">Optional: the change tracker generating the operations.</param>
        public NubeClient(
            IDataStore dataStore,
            string url,
            INubeAuthentication?authentication = null,
            HttpClient?httpClient        = null,
            IChangeTracker?changeTracker = null)
        {
            _dataStore      = dataStore;
            _authentication = authentication;
            _httpClient     = httpClient ?? new HttpClient();
            _changeTracker  = changeTracker ?? new ChangeTracker();

            _nubeTableTypes         = new Dictionary <string, string>();
            _httpClient.BaseAddress = new Uri(url);
        }
Ejemplo n.º 27
0
        /// <summary>
        ///     Aggregates the types.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <param name="field">The field.</param>
        /// <param name="direction">The direction.</param>
        /// <param name="accumulator">The accumulator.</param>
        private static void AggregateTypes(IEntity entity, IEntityRef field, Direction direction, HashSet <long> accumulator)
        {
            /////
            // Get the entities specified field.
            /////
            IChangeTracker <IMutableIdKey> results = Entity.GetRelationships(entity, field, direction);

            if (results != null)
            {
                foreach (var result in results)
                {
                    /////
                    // Stop infinite recursion.
                    /////
                    if (!accumulator.Contains(result.Key))
                    {
                        /////
                        // Add the entity id to the accumulator.
                        /////
                        accumulator.Add(result.Key);

                        IEntity destination;

                        var localCache = Entity.GetLocalCache();

                        if (!localCache.TryGetValue(result.Key, out destination))
                        {
                            EntityCache.Instance.TryGetValue(result.Key, out destination);
                        }

                        if (destination == null)
                        {
                            destination = Entity.Get(result.Key);
                        }

                        if (destination != null)
                        {
                            /////
                            // Aggregate the results from the result.
                            /////
                            AggregateTypes(destination, field, direction, accumulator);
                        }
                    }
                }
            }
        }
        public LibraryConfigurationWindow(INavigator navigator, IChangeTracker changeTracker, Library library)
            : base(navigator, library)
        {
            Ensure.NotNull(changeTracker, "changeTracker");
            Ensure.NotNull(library, "library");

            UserModelPresenter.SetContainer(this, new ModelDefinitionContainer());
            UserModelPresenter.SetValueProviderCollection(this, new FieldValueProviderCollection());

            InitializeComponent();

            kebClose.Command = new DelegateCommand(Close);

            this.changeTracker   = changeTracker;
            this.library         = library;
            this.modelDefinition = library.ConfigurationDefinition;
        }
Ejemplo n.º 29
0
        public SQLTriggerListener(ITriggeredFunctionExecutor executor,
                                  IChangeTracker changeTracker, SQLTriggerAttribute attribute)
        {
            if (executor == null)
            {
                throw new ArgumentNullException(nameof(executor));
            }
            if (attribute == null)
            {
                throw new ArgumentNullException(nameof(attribute));
            }
            if (changeTracker == null)
            {
                throw new ArgumentNullException(nameof(changeTracker));
            }

            this._executor      = executor;
            this._changeTracker = changeTracker;
            this._attribute     = attribute;
        }
Ejemplo n.º 30
0
        public override void Update <T>(IChangeTracker changeTracker, IEntityManager entityManager, T persisted, T updating)
        {
            var dbValue  = GetValue <object>(persisted);
            var newValue = GetValue <object>(updating);

            if (newValue == null)
            {
                SetValue(persisted, null);
                return;
            }

            // do nothing if the key is already identical
            if (entityManager.AreKeysIdentical(newValue, dbValue))
            {
                return;
            }

            newValue = changeTracker.AttachAndReloadAssociatedEntity(newValue);
            SetValue(persisted, newValue);
        }
        public SQLTriggerConfigProvider(INameResolver nameResolver,
                                        ILoggerFactory loggerFactory, IChangeTracker changeTracker)
        {
            if (nameResolver == null)
            {
                throw new ArgumentNullException(nameof(nameResolver));
            }
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }
            if (changeTracker == null)
            {
                throw new ArgumentNullException(nameof(changeTracker));
            }

            this._nameResolver  = nameResolver;
            this._loggerFactory = loggerFactory;
            this._changeTracker = changeTracker;
        }
Ejemplo n.º 32
0
 public static Mock<IVim> CreateVim(
     IRegisterMap registerMap = null,
     MarkMap map = null,
     IVimGlobalSettings settings = null,
     IVimHost host = null,
     IKeyMap keyMap = null,
     IChangeTracker changeTracker = null,
     IKeyboardDevice keyboardDevice = null,
     IMouseDevice mouseDevice = null)
 {
     registerMap = registerMap ?? CreateRegisterMap().Object;
     map = map ?? new MarkMap(new TrackingLineColumnService());
     settings = settings ?? new GlobalSettings();
     host = host ?? new MockVimHost();
     keyMap = keyMap ?? (new KeyMap());
     keyboardDevice = keyboardDevice ?? (new Mock<IKeyboardDevice>(MockBehavior.Loose)).Object;
     mouseDevice = mouseDevice ?? (new Mock<IMouseDevice>(MockBehavior.Loose)).Object;
     changeTracker = changeTracker ?? new ChangeTracker(new TextChangeTrackerFactory(keyboardDevice, mouseDevice));
     var mock = new Mock<IVim>(MockBehavior.Strict);
     mock.Setup(x => x.RegisterMap).Returns(registerMap);
     mock.Setup(x => x.MarkMap).Returns(map);
     mock.Setup(x => x.Settings).Returns(settings);
     mock.Setup(x => x.VimHost).Returns(host);
     mock.Setup(x => x.KeyMap).Returns(keyMap);
     mock.Setup(x => x.ChangeTracker).Returns(changeTracker);
     return mock;
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FindOneAction"/> class.
 /// </summary>
 /// <param name="mongoSession">The mongoSession.</param>
 /// <param name="mongoSessionCache">The mongo session cache.</param>
 /// <param name="changeTracker">The change tracker.</param>
 public FindOneAction(IMongoSessionImplementor mongoSession, IMongoSessionCache mongoSessionCache, IChangeTracker changeTracker)
     : base(mongoSession, mongoSessionCache, changeTracker)
 {
 }
Ejemplo n.º 34
0
 private void CreateForText(params string[] lines)
 {
     _textBuffer = Utils.EditorUtil.CreateBuffer(lines);
     _textView = Utils.MockObjectFactory.CreateTextView(_textBuffer);
     _textView.SetupGet(x => x.HasAggregateFocus).Returns(true);
     _buffer = new MockVimBuffer();
     _buffer.TextViewImpl = _textView.Object;
     _buffer.TextBufferImpl = _textBuffer;
     _normalMode = new MockNormalMode();
     _buffer.ModeImpl = _normalMode;
     _trackerRaw = new ChangeTracker();
     _tracker = _trackerRaw;
     _trackerRaw.OnVimBufferCreated(_buffer);
 }
Ejemplo n.º 35
0
 internal static Mock<IVim> CreateVim(
     IRegisterMap registerMap = null,
     MarkMap map = null,
     IVimGlobalSettings settings = null,
     IVimHost host = null,
     IKeyMap keyMap = null,
     IChangeTracker changeTracker = null)
 {
     registerMap = registerMap ?? CreateRegisterMap().Object;
     map = map ?? new MarkMap(new TrackingLineColumnService());
     settings = settings ?? new GlobalSettings();
     host = host ?? new FakeVimHost();
     keyMap = keyMap ?? (new KeyMap());
     changeTracker = changeTracker ?? new ChangeTracker();
     var mock = new Mock<IVim>(MockBehavior.Strict);
     mock.Setup(x => x.RegisterMap).Returns(registerMap);
     mock.Setup(x => x.MarkMap).Returns(map);
     mock.Setup(x => x.Settings).Returns(settings);
     mock.Setup(x => x.VimHost).Returns(host);
     mock.Setup(x => x.KeyMap).Returns(keyMap);
     mock.Setup(x => x.ChangeTracker).Returns(changeTracker);
     return mock;
 }
Ejemplo n.º 36
0
        private void CreateForText(params string[] lines)
        {
            _textBuffer = Utils.EditorUtil.CreateBuffer(lines);
            _textView = Mock.MockObjectFactory.CreateTextView(_textBuffer);
            _textView.SetupGet(x => x.HasAggregateFocus).Returns(true);
            _buffer = new MockVimBuffer();
            _buffer.TextViewImpl = _textView.Object;
            _buffer.TextBufferImpl = _textBuffer;

            var factory = new MockFactory(MockBehavior.Loose);
            factory.DefaultValue = DefaultValue.Mock;
            _buffer.NormalModeImpl = factory.Create<INormalMode>().Object;
            _buffer.VisualBlockModeImpl = factory.Create<IVisualMode>().Object;
            _buffer.VisualCharacterModeImpl = factory.Create<IVisualMode>().Object;
            _buffer.VisualLineModeImpl = factory.Create<IVisualMode>().Object;
            _trackerRaw = new ChangeTracker();
            _tracker = _trackerRaw;
            _trackerRaw.OnVimBufferCreated(_buffer);
        }
Ejemplo n.º 37
0
        private void CreateForText(params string[] lines)
        {
            _textBuffer = EditorUtil.CreateBuffer(lines);
            _textView = MockObjectFactory.CreateTextView(_textBuffer);
            _textView.SetupGet(x => x.HasAggregateFocus).Returns(true);

            _normalModeRunner = new MockCommandRunner();
            _normalMode = new MockNormalMode() { CommandRunnerImpl = _normalModeRunner };
            _buffer = new MockVimBuffer() { TextViewImpl = _textView.Object, TextBufferImpl = _textBuffer, NormalModeImpl = _normalMode };
            _textChangeTracker = new MockTextChangeTracker() { VimBufferImpl = _buffer };

            _factory = new MockRepository(MockBehavior.Loose);
            _factory.DefaultValue = DefaultValue.Mock;
            _textChangeTrackerFactory = _factory.Create<ITextChangeTrackerFactory>();
            _textChangeTrackerFactory.Setup(x => x.GetTextChangeTracker(_buffer)).Returns(_textChangeTracker);
            _buffer.VisualBlockModeImpl = _factory.Create<IVisualMode>().Object;
            _buffer.VisualCharacterModeImpl = _factory.Create<IVisualMode>().Object;
            _buffer.VisualLineModeImpl = _factory.Create<IVisualMode>().Object;
            _trackerRaw = new ChangeTracker(_textChangeTrackerFactory.Object);
            _tracker = _trackerRaw;
            _trackerRaw.OnVimBufferCreated(_buffer);
        }