private static ScheduleView CreateTestView()
        {
            var view = ScheduleView.CreateSchedule(Category.ByName("OST_GenericModel"), "KeySchedule_Test", ScheduleView.ScheduleType.KeySchedule.ToString());

            Assert.NotNull(view);

            return(view);
        }
        public void AddScheduleFilter_ValidArgs()
        {
            var view = ScheduleView.CreateSchedule(Category.ByName("OST_Walls"), "WallSchedule_Test", ScheduleView.ScheduleType.RegularSchedule.ToString());

            Assert.NotNull(view);

            // get a list of schedulable fields and add "Width" field to schedule
            var schedulableFields = view.SchedulableFields;

            Assert.Greater(schedulableFields.Count, 0);

            var fieldToAdd = schedulableFields
                             .FirstOrDefault(x => x.Name == "Width");

            Assert.NotNull(fieldToAdd);

            view.AddFields(new List <Revit.Schedules.SchedulableField> {
                fieldToAdd
            });
            Assert.Greater(view.Fields.Count, 0);

            // create new schedule filter and add it to schedule
            var field = view.Fields
                        .FirstOrDefault(x => x.Name == "Width");

            Assert.NotNull(field);

            var filter = Revit.Schedules.ScheduleFilter.ByFieldTypeAndValue(field, Autodesk.Revit.DB.ScheduleFilterType.Equal.ToString(), 0.1);

            Assert.NotNull(filter);

            view.AddFilters(new List <Revit.Schedules.ScheduleFilter> {
                filter
            });
            Assert.Greater(view.ScheduleFilters.Count, 0);
        }
 public void ByCategoryNameType_NullArgs()
 {
     Assert.Throws(typeof(ArgumentNullException), () => ScheduleView.CreateSchedule(null, "KeySchedule_Test", ScheduleView.ScheduleType.KeySchedule.ToString()));
     Assert.Throws(typeof(ArgumentNullException), () => ScheduleView.CreateSchedule(Category.ByName("OST_GenericModel"), null, ScheduleView.ScheduleType.KeySchedule.ToString()));
     Assert.Throws(typeof(ArgumentNullException), () => ScheduleView.CreateSchedule(Category.ByName("OST_GenericModel"), "KeySchedule_Test", null));
 }