public void TestRemoveModifierExpression() { var attribute = new Attribute(null, 1, "test", true, true, 12); var attribute2 = new Attribute(null, 11, "test2", true, true, 12); attribute.AdditionAssociations.Add(attribute2); _self.AddAttributeRange(new[] { attribute2 }); Assert.AreEqual(24,attribute.Value); var targetAttributes = new[] { attribute.AdditionAssociations }; var e = new RemoveModifierExpression(new ConstantExpression(targetAttributes), new ConstantExpression(11)); e.Execute(_context, _stack); Assert.IsFalse(_stack.Any()); Assert.AreEqual(12, attribute.Value); }
public void TestGetItemModifierExpression() { var attribute = new Attribute(null,1, "test", true, true,12); _self.AddAttributeRange(new[] {attribute}); var e = new GetItemModifierExpression(new ConstantExpression("ModAdd"), new ConstantExpression(attribute)); e.Execute(_context, _stack); Assert.IsTrue(attribute.AdditionAssociations == _stack.Pop()); Assert.IsFalse(_stack.Any()); e = new GetItemModifierExpression(new ConstantExpression("ModSub"), new ConstantExpression(attribute)); e.Execute(_context, _stack); Assert.IsTrue(attribute.SubstractionAssociations == _stack.Pop()); Assert.IsFalse(_stack.Any()); e = new GetItemModifierExpression(new ConstantExpression("PreMul"), new ConstantExpression(attribute)); e.Execute(_context, _stack); Assert.IsTrue(attribute.PreMultiplicationAssociations == _stack.Pop()); Assert.IsFalse(_stack.Any()); e = new GetItemModifierExpression(new ConstantExpression("PostMul"), new ConstantExpression(attribute)); e.Execute(_context, _stack); Assert.IsTrue(attribute.PostMultiplicationAssociations == _stack.Pop()); Assert.IsFalse(_stack.Any()); e = new GetItemModifierExpression(new ConstantExpression("PreDiv"), new ConstantExpression(attribute)); e.Execute(_context, _stack); Assert.IsTrue(attribute.PreDivisionAssociations == _stack.Pop()); Assert.IsFalse(_stack.Any()); e = new GetItemModifierExpression(new ConstantExpression("PostDiv"), new ConstantExpression(attribute)); e.Execute(_context, _stack); Assert.IsTrue(attribute.PostDivisionAssociations == _stack.Pop()); Assert.IsFalse(_stack.Any()); e = new GetItemModifierExpression(new ConstantExpression("PreAssignment"), new ConstantExpression(attribute)); e.Execute(_context, _stack); Assert.IsTrue(attribute.PreAssignmentAssociations == _stack.Pop()); Assert.IsFalse(_stack.Any()); e = new GetItemModifierExpression(new ConstantExpression("PostAssignment"), new ConstantExpression(attribute)); e.Execute(_context, _stack); Assert.IsTrue(attribute.PostAssignmentAssociations == _stack.Pop()); Assert.IsFalse(_stack.Any()); e = new GetItemModifierExpression(new ConstantExpression("PostPercent"), new ConstantExpression(attribute)); e.Execute(_context, _stack); Assert.IsTrue(attribute.PostPercentAssociations == _stack.Pop()); Assert.IsFalse(_stack.Any()); var attribute2 = new Attribute(null, 12, "test", true, true, 122); e = new GetItemModifierExpression(new ConstantExpression("ModAdd"), new ConstantExpression(new[] {attribute, attribute2})); e.Execute(_context, _stack); var attributes = (IEnumerable<IAssociations>) _stack.Pop(); Assert.AreEqual(2, attributes.Count()); Assert.IsTrue(attributes.Any(x => x == attribute.AdditionAssociations)); Assert.IsTrue(attributes.Any(x => x == attribute2.AdditionAssociations)); }
public void TestAttributeAssignmentExpression() { var attribute = new Attribute(null, 1, "test", true, true, 7); var e = new AttributeAssignmentExpression(new ConstantExpression(new[] { attribute }), new ConstantExpression(27.0)); e.Execute(_context, _stack); Assert.IsFalse(_stack.Any()); Assert.AreEqual(27.0, attribute.Value); }
public void TestGetItemAttributeExpression() { var item = new Item("test", 14, 1, 2, 3, 4); const int ATTRIBUTE_ID = 1; const double ATTRIBUTE_VALUE = 15.0; var attribute = new Attribute(item, ATTRIBUTE_ID, "testAttribute", true , true, ATTRIBUTE_VALUE); item.AddAttributeRange(new[] {attribute}); var e = new GetItemAttributeExpression(new ConstantExpression(item), new ConstantExpression(ATTRIBUTE_ID)); e.Execute(_context, _stack); Assert.IsTrue(attribute == ((IEnumerable<IAttribute>)_stack.Pop()).Single()); Assert.IsFalse(_stack.Any()); }
public void TestAddModifierExpression() { var attribute = new Attribute(null,1, "test", true, true, 12); _self.AddAttributeRange(new[] {attribute}); var targetAttribute1 = new Attribute(null, 11, "test", true, true, 20); var targetAttribute2 = new Attribute(null, 12, "test", true, true, 22); var targetAttributes = new [] {targetAttribute1.AdditionAssociations, targetAttribute2.AdditionAssociations}; var e = new AddModifierExpression(new ConstantExpression(targetAttributes), new ConstantExpression(1)); e.Execute(_context, _stack); Assert.IsFalse(_stack.Any()); //TODO test kann nur implizit erfolgen //Assert.AreSame(attribute, targetAttribute1.AdditionAssociations.Single()); //Assert.AreSame(attribute, targetAttribute2.AdditionAssociations.Single()); }