public void DivideTest(string viewname, bool viewShouldBeFound)
        {
            var bestViewName = ViewFinderExtensions.BestViewName(
                (IViewFinder) new DummyViewFinder("FormFactory/Property." + viewname + ".cshtml"),
                typeof(SomeType),
                "FormFactory/Property.");

            Assert.AreEqual(viewShouldBeFound, (bestViewName != null));
        }
        public void FindsFullyQualifiedNameFirrst()
        {
            var fullyQualifiedViewName = "FormFactory/Property." + typeof(SomeType).FullName;
            var bestViewName           = ViewFinderExtensions.BestViewName(
                (IViewFinder) new DummyViewFinder("FormFactory/Property.Object.cshtml", fullyQualifiedViewName + ".cshtml"),
                typeof(SomeType),
                "FormFactory/Property.");

            Assert.AreEqual(fullyQualifiedViewName, bestViewName);
        }
        public void FindsInterface()
        {
            var fullyQualifiedViewName = "FormFactory/Property.IEnumerable." + typeof(SomeType).FullName;
            var viewFinder             = (IViewFinder) new DummyViewFinder("FormFactory/Property.IEnumerable.Object.cshtml", fullyQualifiedViewName + ".cshtml");

            var bestViewName = ViewFinderExtensions.BestViewName(
                viewFinder,
                typeof(IEnumerable <SomeType>),
                "FormFactory/Property.");

            Assert.AreEqual(fullyQualifiedViewName, bestViewName);
        }
 public RawString BestProperty(PropertyVm vm)
 {
     try
     {
         var viewname = ViewFinderExtensions.BestViewName(this.ViewFinder, vm.Type, "FormFactory/Property.");
         viewname = viewname ??
                    ViewFinderExtensions.BestViewName(ViewFinder, vm.Type.GetEnumerableType(), "FormFactory/Property.IEnumerable.");
         viewname = viewname ?? "FormFactory/Property.System.Object";
         //must be some unknown object exposed as an interface
         return(Partial(viewname, vm));
     }
     catch (Exception ex)
     {
         return(new RawString(ex.Message));
     }
 }