public void ResizeAggregateToGreaterSIzeAllVariablesNotNull() { var sut = new AggregateVariableModel(new WorkspaceModel().Model, new ModelName("x")); sut.Resize(10); Assert.That(sut.Variables, Is.All.InstanceOf <VariableModel>()); }
public void ResizeAggregateWithTenSetsNewSize() { var sut = new AggregateVariableModel(new WorkspaceModel().Model, new ModelName("x")); sut.Resize(10); Assert.That(sut.AggregateCount, Is.EqualTo(10)); }
private void ReadAggregateVariable(XmlNode variableNode) { var variableIdAttribute = variableNode.Attributes["id"]; var variableId = variableIdAttribute.Value; var variableSizeAttribute = variableNode.Attributes["size"]; var variableSize = variableSizeAttribute.Value; var variableName = string.Empty; var domainExpression = string.Empty; for (var i = 0; i < variableNode.ChildNodes.Count; i++) { var childNode = variableNode.ChildNodes[i]; switch (childNode.Name) { case "name": variableName = childNode.InnerText; break; case "domain": domainExpression = childNode.InnerText; break; } } var variableModel = new AggregateVariableModel(_model.Workspace, new ModelName(variableName), Convert.ToInt32(variableSize), new InlineDomainModel(domainExpression)); variableModel.Id = Convert.ToInt32(variableId); _model.AddVariable(variableModel); }
public void ChangeDomainOfAggregatedVariableWithValueOutsideAggregateDomainX() { var sut = new AggregateVariableModel(new WorkspaceModel().Model, new ModelName("A test"), 1, new InlineDomainModel("1..10")); sut.Resize(10); Assert.Throws <ArgumentOutOfRangeException>(() => sut.OverrideDomainTo(10, new VariableDomainExpressionModel("8..10"))); }
internal void AddVariableDomainValue(AggregateVariableModel theAggregate, DomainValue theVariableBand) { foreach (var variableModel in theAggregate.Variables) { this.valueVariableDictionary.Add(variableModel.Name.Text, theVariableBand); } }
public AggregateVariableModelItemViewModel MapFrom(AggregateVariableModel theVariableModel) { Debug.Assert(theVariableModel.HasIdentity); var variableViewModel = new AggregateVariableModelItemViewModel(theVariableModel, _windowManager, _eventAggregator); return(variableViewModel); }
public AggregateVariableModelItemViewModel(AggregateVariableModel theAggregateVariableModel, IWindowManager theWindowManager, IEventAggregator theEventAggregator) : base(theAggregateVariableModel) { Validator = new AggregateVariableModelItemViewModelValidator(); AggregateVariable = theAggregateVariableModel; _eventAggregator = theEventAggregator; _windowManager = theWindowManager; Variables = new BindableCollection <VariableModelItemViewModel>(); }
public void ChangeDomainOfAggregatedVariableWithValueInsideAggregateDomain() { var sut = new AggregateVariableModel(new WorkspaceModel().Model, new ModelName("A test"), 10, new InlineDomainModel("1..10")); sut.Resize(10); sut.OverrideDomainTo(9, new VariableDomainExpressionModel("1..5")); var actualVariable = sut.GetVariableByIndex(9); Assert.That(actualVariable.DomainExpression.Text, Is.EqualTo("1..5")); }
/// <summary> /// Add an aggregate variable. /// </summary> /// <param name="newAggregateName">Variable name.</param> /// <param name="aggregateSize">Size.</param> /// <param name="newDomainExpression">Variable domain.</param> /// <returns>Workspace context.</returns> public WorkspaceBuilder AddAggregate(string newAggregateName, int aggregateSize, string newDomainExpression) { if (string.IsNullOrWhiteSpace(newAggregateName)) { throw new ArgumentException(nameof(newAggregateName)); } if (aggregateSize <= 0) { throw new ArgumentOutOfRangeException(nameof(aggregateSize)); } if (string.IsNullOrWhiteSpace(newDomainExpression)) { throw new ArgumentException(nameof(newDomainExpression)); } var newVariable = new AggregateVariableModel(_model, new ModelName(newAggregateName), aggregateSize, new InlineDomainModel(newDomainExpression)); _model.AddVariable(newVariable); return(this); }
private void WriteVariable(AggregateVariableModel aVariable, XmlElement variablesRoot) { var variableElement = Document.CreateElement("aggregate-variable"); var idAttribute = Document.CreateAttribute("id"); idAttribute.Value = Convert.ToString(aVariable.Id); variableElement.Attributes.Append(idAttribute); var nameElement = Document.CreateElement("name"); var encodedNameNode = Document.CreateCDataSection(aVariable.Name); nameElement.AppendChild(encodedNameNode); variableElement.AppendChild(nameElement); var sizeAttribute = Document.CreateAttribute("size"); sizeAttribute.Value = Convert.ToString(aVariable.GetSize()); variableElement.Attributes.Append(sizeAttribute); var domainElement = Document.CreateElement("domain"); var encodedDomainNode = Document.CreateCDataSection(aVariable.DomainExpression.Text); domainElement.AppendChild(encodedDomainNode); variableElement.AppendChild(domainElement); variablesRoot.AppendChild(variableElement); }
internal OrangeAggregateVariableMap(AggregateVariableModel modelVariable, AggregateSolverVariable solverVariable) { ModelVariable = modelVariable; SolverVariable = solverVariable; }
private object ConvertSolverValueToModel(AggregateVariableModel theVariable, long solverValue) { var variableDomainValue = this.valueMapper.GetDomainValueFor(theVariable); return(variableDomainValue.MapFrom(solverValue)); }
private AggregateSolverVariable CreateIntegerVariableFrom(AggregateVariableModel aggregateVariable) { return(new AggregateSolverVariable(aggregateVariable.Name, aggregateVariable.AggregateCount, CreateRangeFrom(aggregateVariable))); }
/// <summary> /// Initialize the new aggregate added message with the new aggregate variable. /// </summary> /// <param name="newVariable"></param> public AggregateVariableAddedMessage(AggregateVariableModel newVariable) { Added = newVariable; }
public void InitializeAggregateWithValidNameSetsExpectedNameInVariable() { var sut = new AggregateVariableModel(new WorkspaceModel().Model, new ModelName("x")); Assert.That(sut.Name, Is.EqualTo(new ModelName("x"))); }
public void InitializeVariableWithEmptyExpressionWoutWhitespace() { var sut = new AggregateVariableModel(new WorkspaceModel().Model, new ModelName("x"), 5, new InlineDomainModel()); Assert.That(sut.DomainExpression.IsEmpty, Is.True); }
public void ResizeAggregateWithZeroThrowsArgumentOutOfRangeException() { var sut = new AggregateVariableModel(new WorkspaceModel().Model, new ModelName("x")); Assert.Throws <ArgumentOutOfRangeException>(() => sut.Resize(0)); }
public void InitializeVariableWithDomainReferenceRawExpressionWoutWhitespace() { var sut = new AggregateVariableModel(new WorkspaceModel().Model, new ModelName("x"), 1, new InlineDomainModel("$A")); Assert.That(sut.DomainExpression.DomainReference.DomainName.Name, Is.EqualTo("A")); }
public void InitializeVariableWithInlineRawExpressionWoutWhitespace() { var sut = new AggregateVariableModel(new WorkspaceModel().Model, new ModelName("x"), 10, new InlineDomainModel("1..10")); Assert.That(sut.DomainExpression.InlineDomain, Is.Not.Null); }