public void ConstructorShouldSetScopeId() { var scopes = new ParsingScopes(_lifeTimeEventHandler); var scope = new ParsingScope(scopes, RangeAddress.Empty); var dependency = new FormulaDependency(scope); Assert.AreEqual(scope.ScopeId, dependency.ScopeId); }
public ParsingScope(ParsingScopes parsingScopes, ParsingScope parent, RangeAddress address) { _parsingScopes = parsingScopes; Parent = parent; Address = address; ScopeId = Guid.NewGuid(); }
public virtual void KillScope(ParsingScope parsingScope) { _scopes.Pop(); if (_scopes.Count() == 0) { _lifetimeEventHandler.ParsingCompleted(); } }
public void ClearShouldClearDictionary() { var scope = new ParsingScope(_scopes, _factory.Create("A1")); _formulaDependencies.AddFormulaScope(scope); Assert.AreEqual(1, _formulaDependencies.Dependencies.Count()); _formulaDependencies.Clear(); Assert.AreEqual(0, _formulaDependencies.Dependencies.Count()); }
public void ConstructorShouldSetAddress() { var scopes = new ParsingScopes(_lifeTimeEventHandler); var expectedAddress = _factory.Create("A1"); var scope = new ParsingScope(scopes, expectedAddress); var dependency = new FormulaDependency(scope); Assert.AreEqual(expectedAddress, dependency.Address); }
public virtual ParsingScope NewScope(RangeAddress address) { ParsingScope scope; if (_scopes.Count() > 0) { scope = new ParsingScope(this, _scopes.Peek(), address); } else { scope = new ParsingScope(this, address); } _scopes.Push(scope); return scope; }
public void ShouldAddReferenceToParent() { var parentScope = new ParsingScope(_scopes, _factory.Create("A1")); var parentDependency = MockRepository.GenerateStub<FormulaDependency>(parentScope); _formulaDependencyFactory.Stub(x => x.Create(parentScope)).Return(parentDependency); _formulaDependencies.AddFormulaScope(parentScope); var childScope = new ParsingScope(_scopes, parentScope, _factory.Create("A2")); var childDependency = MockRepository.GenerateStub<FormulaDependency>(childScope); _formulaDependencyFactory.Stub(x => x.Create(childScope)).Return(childDependency); _formulaDependencies.AddFormulaScope(childScope); parentDependency.AssertWasCalled(x => x.AddReferenceTo(childScope.Address)); }
public virtual ParsingScope NewScope(RangeAddress address) { ParsingScope scope; if (_scopes.Count() > 0) { scope = new ParsingScope(this, _scopes.Peek(), address); } else { scope = new ParsingScope(this, address); } _scopes.Push(scope); return(scope); }
public void Setup() { _parsingContext = ParsingContext.Create(); _scope = _parsingContext.Scopes.NewScope(RangeAddress.Empty); }
public void ScopeShouldCallKillScopeOnDispose() { var scope = new ParsingScope(_parsingScopes, _factory.Create("A1")); ((IDisposable)scope).Dispose(); _parsingScopes.AssertWasCalled(x => x.KillScope(scope)); }
public void ConstructorShouldSetParent() { var parent = new ParsingScope(_parsingScopes, _factory.Create("A1")); var scope = new ParsingScope(_parsingScopes, parent, _factory.Create("A2")); Assert.AreEqual(parent, scope.Parent); }
public void ConstructorShouldSetAddress() { var expectedAddress = _factory.Create("A1"); var scope = new ParsingScope(_parsingScopes, expectedAddress); Assert.AreEqual(expectedAddress, scope.Address); }