Esempio n. 1
0
 public void TestCastingToFloat()
 {
     var tag = new ParseNumber();
     tag.Value = new MockAttribute(new StringConstant("1,345.67"));
     tag.Var = new MockAttribute(new StringConstant("TheFloat"));
     tag.Scope = new MockAttribute(new StringConstant(VariableScope.Model.ToString()));
     Assert.That(tag.Evaluate(_model), Is.EqualTo(String.Empty));
     Assert.That(_model.Model["TheFloat"], Is.EqualTo(1345.67f));
 }
Esempio n. 2
0
 public void CheckRequired()
 {
     var tag = new ParseNumber();
     RequiredAttribute.Check(tag);
     //no exceptions
 }
Esempio n. 3
0
 public void TestFromValueOnNoInput()
 {
     var tag = new ParseNumber();
     Assert.That(tag.Evaluate(_model), Is.EqualTo(String.Empty));
 }
Esempio n. 4
0
 public void TestFromValueToVar()
 {
     var tag = new ParseNumber();
     tag.Value = new MockAttribute(new StringConstant("4"));
     tag.Var = new MockAttribute(new StringConstant("Number"));
     Assert.That(tag.Evaluate(_model), Is.EqualTo(String.Empty));
     Assert.That(_model["Number"], Is.EqualTo(4m));
 }
Esempio n. 5
0
 public void TestFromValueOnEmptyString()
 {
     var tag = new ParseNumber();
     tag.Value = new MockAttribute(new StringConstant(""));
     Assert.That(tag.Evaluate(_model), Is.EqualTo(String.Empty));
 }
Esempio n. 6
0
 public void TestFromValueDecimalToVarWithDecimalSeperatorWithStyles()
 {
     var tag = new ParseNumber();
     tag.Value = new MockAttribute(new StringConstant("1,345.67"));
     tag.Var = new MockAttribute(new StringConstant("Decimal"));
     tag.Styles =
         new MockAttribute(new StringConstant(NumberStyles.AllowDecimalPoint + "," + NumberStyles.AllowThousands));
     Assert.That(tag.Evaluate(_model), Is.EqualTo(String.Empty));
     Assert.That(_model["Decimal"], Is.EqualTo(1345.67m));
 }
Esempio n. 7
0
 public void TestFromValueDecimalToVarWithDecimalSeperatorNotAllowedInStyle()
 {
     var tag = new ParseNumber();
     tag.Value = new MockAttribute(new StringConstant("1,345.67"));
     tag.Var = new MockAttribute(new StringConstant("Number"));
     tag.Styles = new MockAttribute(new StringConstant(NumberStyles.AllowDecimalPoint.ToString()));
     try
     {
         tag.Evaluate(_model);
         Assert.Fail("Should be in incorrect format");
     }
     catch (TagException Te)
     {
         Assert.That(Te.Message,
             Is.EqualTo(TagException.ParseException("1,345.67", "Number").Message));
     }
 }
Esempio n. 8
0
 public void TestFromValueDecimalToVarWithDecimalSeperator()
 {
     var tag = new ParseNumber();
     tag.Value = new MockAttribute(new StringConstant("1,345.67"));
     tag.Var = new MockAttribute(new StringConstant("Number"));
     tag.IntegerOnly = new MockAttribute(new StringConstant("False"));
     Assert.That(tag.Evaluate(_model), Is.EqualTo(String.Empty));
     Assert.That(_model["Number"], Is.EqualTo(1345.67m));
 }
Esempio n. 9
0
 public void TestFromValueDecimal()
 {
     var tag = new ParseNumber();
     tag.Value = new MockAttribute(new StringConstant("4.5"));
     Assert.That(tag.Evaluate(_model), Is.EqualTo(4.5m.ToString()));
 }