Added Cube binding constructor, test, corrected Sizes.InchesToMillimeters

This commit is contained in:
Michael Smith 2016-03-03 21:59:58 -08:00
parent 421694559f
commit 5726b63dec
3 changed files with 33 additions and 2 deletions

View File

@ -158,5 +158,21 @@ namespace OSCADSharp.UnitTests
Assert.AreEqual(centerVal.Value, obj.Center);
Assert.IsTrue(script.Contains("center = isCentered"));
}
[TestMethod]
public void Cube_ConstructorBindingsAppearInOutput()
{
var length = new Variable("deckBoxLength", Sizes.SixteenthInch * 32);
var width = new Variable("deckBoxWidth", Sizes.SixteenthInch * 32);
var height = new Variable("deckboxHeight", Sizes.InchesToMillimeters(2.5));
var centered = new Variable("isCentered", true);
var cube = new Cube(length, width, height, centered);
string script = cube.ToString();
Assert.IsTrue(script.Contains("size = [deckBoxLength, deckBoxWidth, deckboxHeight]"));
Assert.IsTrue(script.Contains("center = isCentered"));
}
}
}

View File

@ -41,9 +41,9 @@ namespace OSCADSharp
/// </summary>
/// <param name="inches">Number of inches</param>
/// <returns>Equivalent value in milimeters</returns>
public double InchesToMillimeters(double inches)
public static double InchesToMillimeters(double inches)
{
return inches * 0.03937008;
return inches * OneInch;
}
}
}

View File

@ -78,6 +78,21 @@ namespace OSCADSharp.Solids
this.Center = center;
}
/// <summary>
/// Creates a new Cube object with variable bindings
/// </summary>
/// <param name="length">Size on the X axis</param>
/// <param name="width">Size on the Y axis</param>
/// <param name="height">Size on the Z axis</param>
/// <param name="center">Indicates whether the cube should be centered on the origin</param>
public Cube(Variable length = null, Variable width = null, Variable height = null, Variable center = null)
{
this.BindIfVariableNotNull("length", length);
this.BindIfVariableNotNull("width", width);
this.BindIfVariableNotNull("height", height);
this.BindIfVariableNotNull("center", center);
}
#endregion
#region Overrides