public void Given2InchAnd2Inch_WhenAddition_ShouldReturn4Inch()
        {
            Length inch1     = new Length(Length.Unit.INCH, 2.0);
            Length inch2     = new Length(Length.Unit.INCH, 2.0);
            double inchAdded = length.Add(inch1, inch2);

            Assert.AreEqual(4.0, inchAdded);
        }
Example #2
0
            public void Should_return_empty_given_MappedPropertyInfo_Type_is_not_Property()
            {
                MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmComponent(), null);

                _length.Add(mappedPropertyInfo);
                string result = _builder.ToString();

                result.ShouldBeEqualTo("");
            }
        public void Given1LitreAnd1000Ml_WhenAddition_ShouldReturn2Litres()
        {
            Length litre       = new Length(Length.Unit.LITRE, 1.0);
            Length ml          = new Length(Length.Unit.MILLIMETER, 1000.0);
            double addedResult = litre.Add(litre, ml);

            Assert.AreEqual(2.0, addedResult);
        }
        public void Given1GallonAnd3n78Litres_WhenAddition_ShouldReturnEqualResult()
        {
            Length gallon      = new Length(Length.Unit.GALLON, 1.0);
            Length litre       = new Length(Length.Unit.LITRE, 3.78);
            double addedResult = litre.Add(gallon, litre);

            Assert.AreEqual(8.0, addedResult);
        }
        //private readonly string _debugFilePath = mySettings.Default.debugFilePath;

        public WallData(string familyName, FamilyInstance Origo, Document doc)
        {
            //Get the relevant wall symbols
            FilteredElementCollector collector = new FilteredElementCollector(doc);

            WallSymbols = collector.WherePasses(fi.FamInstOfDetailComp())
                          .WherePasses(fi.ParameterValueFilter(familyName,
                                                               BuiltInParameter.SYMBOL_FAMILY_AND_TYPE_NAMES_PARAM))
                          .OrderBy(x => int.Parse(x.get_Parameter(BuiltInParameter.ALL_MODEL_MARK).AsString())) //Mark must be filled with integer numbers
                          .Cast <FamilyInstance>()
                          .ToList();

            //Analyze the geometry to get x and y values
            //Obtain the transform from the Origo family
            Transform trf = Origo.GetTransform();

            trf = trf.Inverse;

            //StringBuilder sb = new StringBuilder();

            foreach (FamilyInstance fi in WallSymbols)
            {
                //Get the location points of the wall symbols
                LocationCurve loc = fi.Location as LocationCurve;

                //Collect the length of the walls
                Length.Add(loc.Curve.Length.FtToMeters());

                //Get the end and start points
                Curve locCurve = loc.Curve;
                XYZ   start    = locCurve.GetEndPoint(0);
                XYZ   end      = locCurve.GetEndPoint(1);

                //Transform the points
                XYZ tStart = trf.OfPoint(start);
                XYZ tEnd   = trf.OfPoint(end);

                double sX = tStart.X.FtToMeters(), sY = tStart.Y.FtToMeters(), eX = tEnd.X.FtToMeters(), eY = tEnd.Y.FtToMeters();

                //sb.Append("Wall ("+ sX +","+ sY + ") <> ");
                //sb.Append("(" + eX + "," + eY + ") <> ");
                //sb.Append(loc.Curve.Length.FtToMeters());
                //sb.AppendLine();

                //Take advantage of the fact that X or Y is equal
                if (sX.Equals(eX))
                {
                    X.Add(sX);
                }
                else if (sY.Equals(eY))
                {
                    Y.Add(sY);
                }
                else
                {
                    throw new Exception("No equal coordinates found!!!\n");
                }

                //Collect the width of the wall from the wall symbol
                Thickness.Add(fi.LookupParameter("GS_Width").AsDouble().FtToMillimeters());
            }

            //op.WriteDebugFile(_debugFilePath, sb);
        }