Ejemplo n.º 1
0
        public void NodeSearchElementComparerSortsBasedOnTypeDistance_NonExact()
        {
            var core = Model.LibraryServices.LibraryManagementCore;
            //we'll compare Rect to PolyCurve and expect the result to be 1 for PolyCurve closer to our input type.
            var inputType = "Autodesk.DesignScript.Geometry.Curve";
            var type1 = Model.SearchModel.SearchEntries.Where(x => x.FullName.Contains("Rectangle.ByWidthLength")).FirstOrDefault(); //returns a Rect.
            var type2 = Model.SearchModel.SearchEntries.Where(x => x.FullName.Contains("PolyCurve.ByJoinedCurves")).FirstOrDefault(); //returns a polycurve.

            var comparer = new NodeAutoCompleteSearchViewModel.NodeSearchElementComparer(inputType, core);
            Assert.AreEqual(1, comparer.Compare(type1, type2));
        }
Ejemplo n.º 2
0
        public void NodeSearchElementComparerSortsBasedOnTypeDistance_MultiReturnNodeModelEqual()
        {
            var core = Model.LibraryServices.LibraryManagementCore;
            //inject our mock node into search model.
            Model.SearchModel.Add(new NodeModelSearchElement(new TypeLoadData(typeof(MultReturnTypeNode))));

            //we'll compare curve to our mock node and expect the result to be 0 since they both match exactly.
            var inputType = "Autodesk.DesignScript.Geometry.Curve";
            var type1 = Model.SearchModel.SearchEntries.Where(x => x.FullName.Contains("MultReturnTypeNode")).FirstOrDefault(); //returns a Curve, and String.
            var type2 = Model.SearchModel.SearchEntries.Where(x => x.FullName.Contains("Curve.Offset")).FirstOrDefault(); //returns a Curve.

            var comparer = new NodeAutoCompleteSearchViewModel.NodeSearchElementComparer(inputType, core);
            Assert.AreEqual(0, comparer.Compare(type1, type2));
        }