Beispiel #1
0
        public void AddPropertyToDictionary_ValueIsNull_PropertyIsNotAdded()
        {
            PropertyInfo                property   = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.BusinessHours));
            FullCalendarParameters      parameters = new FullCalendarParameters();
            BusinessHoursPropertyParser parser     = new BusinessHoursPropertyParser(property, null);
            Dictionary <string, string> target     = new Dictionary <string, string>();

            parser.AddPropertyToDictionary(parameters, ref target);
            target.Should().BeEmpty();
        }
Beispiel #2
0
        public void AddPropertyToDictionary_ListIsEmpty_TrueIsAddedAsValue()
        {
            PropertyInfo           property   = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.BusinessHours));
            FullCalendarParameters parameters = new FullCalendarParameters
            {
                BusinessHours = new List <BusinessHour>()
            };
            BusinessHoursPropertyParser parser = new BusinessHoursPropertyParser(property, new JavaScriptSerializer());
            Dictionary <string, string> target = new Dictionary <string, string>();

            parser.AddPropertyToDictionary(parameters, ref target);
            target.Should().Contain("data-fc-BusinessHours", "true");
        }
Beispiel #3
0
        public void AddPropertyToDictionary_ListIsNotEmpty_ValuesIsAddedAsSerializedObject()
        {
            PropertyInfo           property   = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.BusinessHours));
            FullCalendarParameters parameters = new FullCalendarParameters
            {
                BusinessHours = new List <BusinessHour>
                {
                    new BusinessHour
                    {
                        Dow = new List <DayOfWeek> {
                            DayOfWeek.Thursday, DayOfWeek.Friday
                        },
                        Start = TimeSpan.FromHours(10),
                        End   = TimeSpan.FromHours(15)
                    }
                }
            };
            BusinessHoursPropertyParser parser = new BusinessHoursPropertyParser(property, new JavaScriptSerializer());
            Dictionary <string, string> target = new Dictionary <string, string>();

            parser.AddPropertyToDictionary(parameters, ref target);
            target.Should().Contain("data-fc-BusinessHours", "[{'dow':[4,5],'start':'10:00','end':'15:00'}]");
        }