Exemplo n.º 1
0
        public void Load_With_Valid_Model_Sets_Expected_Workspace_Model()
        {
            var sut = CreateSut();
            var actualWorkspaceViewModel = sut.Load(WorkspaceModelFactory.Create());

            Assert.That(actualWorkspaceViewModel.WorkspaceModel, Is.Not.Null);
        }
Exemplo n.º 2
0
        public void InitializeWithRawExpressionParsesExpectedAggregateVariableSubscriptOnLeft()
        {
            var sut = new ExpressionConstraintModel(WorkspaceModelFactory.Create().Model, new ConstraintExpressionModel("$xx[1] > 1"));
            var leftVariableReference = (AggregateVariableReferenceNode)sut.Expression.Node.InnerExpression.LeftExpression.InnerExpression;

            Assert.That(leftVariableReference.SubscriptStatement.Subscript, Is.EqualTo(1));
        }
Exemplo n.º 3
0
        public void Load_With_Valid_Model_Returns_Expected_Constraints()
        {
            var sut = CreateSut();
            var actualWorkspaceViewModel = sut.Load(WorkspaceModelFactory.Create());

            Assert.That(actualWorkspaceViewModel.ModelEditor.Constraints.Count, Is.EqualTo(1));
        }
Exemplo n.º 4
0
        public void InitializeWithRawExpressionParsesExpectedAggregateVariableNameOnRight()
        {
            var sut = new ExpressionConstraintModel(WorkspaceModelFactory.Create().Model, new ConstraintExpressionModel("$x[1] > $x[2]"));
            var rightVariableReference = (AggregateVariableReferenceNode)sut.Expression.Node.InnerExpression.RightExpression.InnerExpression;

            Assert.That(rightVariableReference.VariableName, Is.EqualTo("x"));
        }
Exemplo n.º 5
0
        public void Initialize_With_Raw_Expression_Parses_Expected_Variable_Name_On_Right()
        {
            var sut = new ExpressionConstraintModel(WorkspaceModelFactory.Create().Model, new ConstraintExpressionModel("$y = $x"));
            var rightVariableReference = (SingletonVariableReferenceNode)sut.Expression.Node.InnerExpression.RightExpression.InnerExpression;

            Assert.That(rightVariableReference.VariableName, Is.EqualTo("x"));
        }
Exemplo n.º 6
0
        public void Initialize_With_Raw_Expression_Parses_Expected_Literal_On_Right()
        {
            var sut          = new ExpressionConstraintModel(WorkspaceModelFactory.Create().Model, new ConstraintExpressionModel("$y <= 44"));
            var rightLiteral = (IntegerLiteralNode)sut.Expression.Node.InnerExpression.RightExpression.InnerExpression;

            Assert.That(rightLiteral.Value, Is.EqualTo(44));
        }
        public void Initialize_With_Character_Range_Parses_Expected_Lower_Band()
        {
            var sut = new SharedDomainModel(WorkspaceModelFactory.Create().Model, new ModelName("A domain"), new SharedDomainExpressionModel("    'a'..'z'     "));
            var rangeExpressionNode = (RangeDomainExpressionNode)sut.Expression.Node.Inner;

            Assert.That(rangeExpressionNode.RightExpression, Is.InstanceOf <BandExpressionNode>());
        }
        public void Initialize_With_List_Expression_Parses_Expected_Inner()
        {
            var sut = new SharedDomainModel(WorkspaceModelFactory.Create().Model, new ModelName("A domain"), new SharedDomainExpressionModel("\"rita\", \"sue\", \"bob\""));
            var rangeExpressionNode = (ListDomainExpressionNode)sut.Expression.Node.Inner;

            Assert.That(rangeExpressionNode.Items.Values, Is.All.Not.Null);
            Assert.That(rangeExpressionNode.Items.Values, Is.All.InstanceOf <ItemNameNode>());
            Assert.That(rangeExpressionNode.Items.Values, Has.Count.EqualTo(3));
        }
        private static VariableModel CreatedDeletedVariable()
        {
            var x = WorkspaceModelFactory.Create();

            return(x.Model.GetVariableByName("x"));
        }
Exemplo n.º 10
0
 private DisplayModel CreateDisplayModel()
 {
     return(new DisplayModel(WorkspaceModelFactory.Create().Model));
 }
Exemplo n.º 11
0
        public void CreateWorkspaceWithBlankNameReturnsModelWithBlankName()
        {
            var sut = WorkspaceModelFactory.Create();

            Assert.That(sut.Model.Name.Text, Is.Empty);
        }
Exemplo n.º 12
0
        public void Initialize_With_Raw_Expression_Parses_Expected_Operator()
        {
            var sut = new ExpressionConstraintModel(WorkspaceModelFactory.Create().Model, new ConstraintExpressionModel("     $a1    >    999      "));

            Assert.That(sut.Expression.OperatorType, Is.EqualTo(OperatorType.Greater));
        }