diff --git a/FullCalendarMVC/FullCalendar.Tests/FullCalendar.Tests.csproj b/FullCalendarMVC/FullCalendar.Tests/FullCalendar.Tests.csproj index 3220928..6d77cdb 100644 --- a/FullCalendarMVC/FullCalendar.Tests/FullCalendar.Tests.csproj +++ b/FullCalendarMVC/FullCalendar.Tests/FullCalendar.Tests.csproj @@ -42,12 +42,34 @@ ..\packages\FluentAssertions.4.19.4\lib\net40\FluentAssertions.Core.dll + + ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + ..\packages\NUnit.3.9.0\lib\net40\nunit.framework.dll + + + ..\packages\Microsoft.AspNet.WebPages.1.0.20105.408\lib\net40\System.Web.Helpers.dll + + + ..\packages\Microsoft.AspNet.Mvc.3.0.50813.1\lib\net40\System.Web.Mvc.dll + + + ..\packages\Microsoft.AspNet.Razor.1.0.20105.408\lib\net40\System.Web.Razor.dll + + + ..\packages\Microsoft.AspNet.WebPages.1.0.20105.408\lib\net40\System.Web.WebPages.dll + + + ..\packages\Microsoft.AspNet.WebPages.1.0.20105.408\lib\net40\System.Web.WebPages.Deployment.dll + + + ..\packages\Microsoft.AspNet.WebPages.1.0.20105.408\lib\net40\System.Web.WebPages.Razor.dll + @@ -74,6 +96,7 @@ + @@ -88,12 +111,19 @@ + + + + + + + diff --git a/FullCalendarMVC/FullCalendar.Tests/FullCalendarHelperTests.cs b/FullCalendarMVC/FullCalendar.Tests/FullCalendarHelperTests.cs new file mode 100644 index 0000000..0f99dac --- /dev/null +++ b/FullCalendarMVC/FullCalendar.Tests/FullCalendarHelperTests.cs @@ -0,0 +1,31 @@ +using FluentAssertions; +using NUnit.Framework; +using System.Web; +using System.Web.Mvc; + +namespace FullCalendar.Tests +{ + [TestFixture] + public class FullCalendarHelperTests + { + [Test] + public void FullCalendar_FullParametersNotSet_DefaultHtmlShouldBeCorrectlyBuilt() + { + HtmlHelper htmlHelper = null; + IHtmlString target = htmlHelper.FullCalendar(); + target.ToHtmlString().Should().Be("
"); + } + + [Test] + public void FullCalendar_NameIsSetInCalendarParameters_HtmlShouldContainIdAndName() + { + HtmlHelper htmlHelper = null; + IHtmlString target = htmlHelper.FullCalendar(settings => + { + settings.Name = "test"; + }); + target.ToHtmlString().Should().Contain("id='test'"); + target.ToHtmlString().Should().Contain("name='test'"); + } + } +} \ No newline at end of file diff --git a/FullCalendarMVC/FullCalendar.Tests/Infrastructure/PropertyParsers/EventCollectionPropertyParserTests.cs b/FullCalendarMVC/FullCalendar.Tests/Infrastructure/PropertyParsers/EventCollectionPropertyParserTests.cs new file mode 100644 index 0000000..b354d6f --- /dev/null +++ b/FullCalendarMVC/FullCalendar.Tests/Infrastructure/PropertyParsers/EventCollectionPropertyParserTests.cs @@ -0,0 +1,113 @@ +using FluentAssertions; +using NUnit.Framework; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Web.Script.Serialization; + +namespace FullCalendar.Infrastructure.PropertyParsers.Tests +{ + [TestFixture] + public class EventCollectionPropertyParserTests + { + [Test] + public void AddPropertyToDictionary_ValueIsNull_PropertyIsNotAdded() + { + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.Events)); + FullCalendarParameters parameters = new FullCalendarParameters(); + EventCollectionPropertyParser parser = new EventCollectionPropertyParser(property, null); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().BeEmpty(); + } + + [Test] + public void AddPropertyToDictionary_ValueIsInitializedAsNullArray_PropertyIsNotAdded() + { + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.Events)); + FullCalendarParameters parameters = new FullCalendarParameters + { + Events = Events.AsArray(null) + }; + EventCollectionPropertyParser parser = new EventCollectionPropertyParser(property, new JavaScriptSerializer()); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().BeEmpty(); + } + + [Test] + public void AddPropertyToDictionary_ValueIsInitializedAsEmptyArray_PropertyIsNotAdded() + { + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.Events)); + FullCalendarParameters parameters = new FullCalendarParameters + { + Events = Events.AsArray(new List()) + }; + EventCollectionPropertyParser parser = new EventCollectionPropertyParser(property, new JavaScriptSerializer()); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().BeEmpty(); + } + + [Test] + public void AddPropertyToDictionary_ValueIsInitializedAsNonEmptyArray_PropertyIsAddedAsSerializedObject() + { + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.Events)); + FullCalendarParameters parameters = new FullCalendarParameters + { + Events = Events.AsArray(new List + { + new Event() + }) + }; + EventCollectionPropertyParser parser = new EventCollectionPropertyParser(property, new JavaScriptSerializer()); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().Contain("data-fc-Events", "[{'id':0,'title':null,'allDay':null,'start':null,'end':null,'url':null,'className':null,'editable':false,'startEditable':true,'durationEditable':true,'rendering':null,'overlap':true,'constraint':null,'color':null,'backgroundColor':null,'borderColor':null,'textColor':null,'googleCalendarId':null,'additionalFields':null}]"); + } + + [Test] + public void AddPropertyToDictionary_ValueIsInitializedAsJsonFeed_UrlPropertyIsAdded() + { + string url = "/Home/GetData"; + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.Events)); + FullCalendarParameters parameters = new FullCalendarParameters + { + Events = Events.AsJsonFeed(url) + }; + EventCollectionPropertyParser parser = new EventCollectionPropertyParser(property, new JavaScriptSerializer()); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().Contain("data-fc-Events", url); + } + + [Test] + public void AddPropertyToDictionary_ValueIsInitializedAsFunction_FunctionPropertyIsAdded() + { + string function = "function() { alert(''); }"; + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.Events)); + FullCalendarParameters parameters = new FullCalendarParameters + { + Events = Events.AsFunction(function) + }; + EventCollectionPropertyParser parser = new EventCollectionPropertyParser(property, new JavaScriptSerializer()); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().Contain("data-fc-Events", function); + } + + [Test] + public void AddPropertyToDictionary_ValueIsInitializedAsGoogleCalendarFeed_GoogleCalendarPropertyIsSerialized() + { + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.Events)); + FullCalendarParameters parameters = new FullCalendarParameters + { + Events = Events.AsGoogleCalendarFeed("abcd1234@group.calendar.google.com") + }; + EventCollectionPropertyParser parser = new EventCollectionPropertyParser(property, new JavaScriptSerializer()); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().Contain("data-fc-Events", "{'googleCalendarId':'abcd1234@group.calendar.google.com'}"); + } + } +} \ No newline at end of file diff --git a/FullCalendarMVC/FullCalendar.Tests/Infrastructure/PropertyParsers/EventSourcesPropertyParserTests.cs b/FullCalendarMVC/FullCalendar.Tests/Infrastructure/PropertyParsers/EventSourcesPropertyParserTests.cs new file mode 100644 index 0000000..770d78a --- /dev/null +++ b/FullCalendarMVC/FullCalendar.Tests/Infrastructure/PropertyParsers/EventSourcesPropertyParserTests.cs @@ -0,0 +1,106 @@ +using FluentAssertions; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Reflection; +using System.Web.Script.Serialization; + +namespace FullCalendar.Infrastructure.PropertyParsers.Tests +{ + [TestFixture] + public class EventSourcesPropertyParserTests + { + [Test] + public void AddPropertyToDictionary_ValueIsNull_PropertyIsNotAdded() + { + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.EventSources)); + FullCalendarParameters parameters = new FullCalendarParameters(); + EventSourcesPropertyParser parser = new EventSourcesPropertyParser(property, null); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().BeEmpty(); + } + + [Test] + public void AddPropertyToDictionary_ListIsEmpty_PropertyIsNotAdded() + { + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.EventSources)); + FullCalendarParameters parameters = new FullCalendarParameters + { + EventSources = new List() + }; + EventSourcesPropertyParser parser = new EventSourcesPropertyParser(property, new JavaScriptSerializer()); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().BeEmpty(); + } + + [Test] + public void AddPropertyToDictionary_ListIsNotEmpty_ValuesIsAddedAsSerializedObject() + { + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.EventSources)); + FullCalendarParameters parameters = new FullCalendarParameters + { + EventSources = new List + { + new EventSource + { + Id = 1, + BackgroundColor = Color.DarkGray, + BorderColor = Color.Blue, + TextColor = Color.Gold, + ClassName = "test", + Rendering = Rendering.Background, + Constraint = new EventConstraint(new BusinessHour + { + Dow = new List { DayOfWeek.Thursday, DayOfWeek.Friday }, + Start = TimeSpan.FromHours(10), + End = TimeSpan.FromHours(15) + }), + AllDayDefault = true, + Url = "/Home/GetDiaryEvents" + }, + new EventSource + { + Id = 2, + Events = Events.AsArray(new List + { + new Event + { + Id = 1, + Title = "Title", + AllDay = false, + ClassName = "test-class", + Constraint = new EventConstraint(new BusinessHour + { + Dow = new List { DayOfWeek.Thursday, DayOfWeek.Friday }, + Start = TimeSpan.FromHours(10), + End = TimeSpan.FromHours(15) + }), + Color = Color.DarkRed, + AdditionalFields = new Dictionary + { + { "description", "this is the description" }, + { "other", "this is another additional field" } + } + } + }), + Type = "POST", + Error = "function() { }", + Data = new Dictionary + { + { "custom_param1", "something" }, + { "custom_param2", "somethingelse" } + } + } + } + }; + EventSourcesPropertyParser parser = new EventSourcesPropertyParser(property, new JavaScriptSerializer()); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().Contain("data-fc-EventSources", @"[{'id':1,'events':null,'color':null,'backgroundColor':'#A9A9A9','borderColor':'#0000FF','textColor':'#FFD700','className':'test','editable':false,'startEditable':true,'durationEditable':true,'rendering':'background','overlap':true,'constraint':{'dow':[4,5],'start':'10:00','end':'15:00'},'allDayDefault':true,'eventDataTransform':null,'url':'/Home/GetDiaryEvents','startParam':null,'endParam':null,'timezoneParam':null,'type':null,'success':null,'error':null,'cache':false,'data':null},{'id':2,'events':[{'id':1,'title':'Title','allDay':false,'start':null,'end':null,'url':null,'className':'test-class','editable':false,'startEditable':true,'durationEditable':true,'rendering':null,'overlap':true,'constraint':{'dow':[4,5],'start':'10:00','end':'15:00'},'color':'#8B0000','backgroundColor':null,'borderColor':null,'textColor':null,'googleCalendarId':null,'additionalFields':{'description':'this is the description','other':'this is another additional field'}}],'color':null,'backgroundColor':null,'borderColor':null,'textColor':null,'className':null,'editable':false,'startEditable':true,'durationEditable':true,'rendering':null,'overlap':true,'constraint':null,'allDayDefault':null,'eventDataTransform':null,'url':null,'startParam':null,'endParam':null,'timezoneParam':null,'type':'POST','success':null,'error':'function() { }','cache':false,'data':{'custom_param1':'something','custom_param2':'somethingelse'}}]"); + } + } +} \ No newline at end of file diff --git a/FullCalendarMVC/FullCalendar.Tests/Infrastructure/PropertyParsers/ObjectPropertyParserTests.cs b/FullCalendarMVC/FullCalendar.Tests/Infrastructure/PropertyParsers/ObjectPropertyParserTests.cs new file mode 100644 index 0000000..5d5418c --- /dev/null +++ b/FullCalendarMVC/FullCalendar.Tests/Infrastructure/PropertyParsers/ObjectPropertyParserTests.cs @@ -0,0 +1,58 @@ +using FluentAssertions; +using NUnit.Framework; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Web.Script.Serialization; + +namespace FullCalendar.Infrastructure.PropertyParsers.Tests +{ + [TestFixture] + public class ObjectPropertyParserTests + { + [Test] + public void AddPropertyToDictionary_ValueIsNull_PropertyIsNotAdded() + { + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.EventLimit)); + FullCalendarParameters parameters = new FullCalendarParameters(); + ObjectPropertyParser parser = new ObjectPropertyParser(property, null); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().BeEmpty(); + } + + [Test] + public void AddPropertyToDictionary_ValueIsNotISerializableObject_PropertyIsAddedAsString() + { + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.ButtonIcons)); + FullCalendarParameters parameters = new FullCalendarParameters + { + ButtonIcons = new + { + prev = "left-single-arrow" + } + }; + ObjectPropertyParser parser = new ObjectPropertyParser(property, new JavaScriptSerializer()); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().Contain("data-fc-ButtonIcons", "{ prev = left-single-arrow }"); + } + + [Test] + public void AddPropertyToDictionary_ValueIsISerializableObject_PropertyIsAddedAsSerializedObject() + { + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.DateIncrement)); + FullCalendarParameters parameters = new FullCalendarParameters + { + DateIncrement = new Duration + { + Days = 4 + } + }; + ObjectPropertyParser parser = new ObjectPropertyParser(property, new JavaScriptSerializer()); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().Contain("data-fc-DateIncrement", "{'days':4,'weeks':0,'months':0}"); + } + } +} \ No newline at end of file diff --git a/FullCalendarMVC/FullCalendar.Tests/Infrastructure/PropertyParsers/ThemeSystemPropertyParserTests.cs b/FullCalendarMVC/FullCalendar.Tests/Infrastructure/PropertyParsers/ThemeSystemPropertyParserTests.cs new file mode 100644 index 0000000..9304fa2 --- /dev/null +++ b/FullCalendarMVC/FullCalendar.Tests/Infrastructure/PropertyParsers/ThemeSystemPropertyParserTests.cs @@ -0,0 +1,40 @@ +using FluentAssertions; +using NUnit.Framework; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace FullCalendar.Infrastructure.PropertyParsers.Tests +{ + [TestFixture] + public class ThemeSystemPropertyParserTests + { + [Test] + public void AddPropertyToDictionary_ValueIsPassed_PropertyIsAdded() + { + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.ThemeSystem)); + FullCalendarParameters parameters = new FullCalendarParameters + { + ThemeSystem = ThemeSystem.Bootstrap3 + }; + ThemeSystemPropertyParser parser = new ThemeSystemPropertyParser(property); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().Contain("data-fc-ThemeSystem", "bootstrap3"); + } + + [Test] + public void AddPropertyToDictionary_ValueIsJqueryUI_PropertyIsCorrectlySet() + { + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.ThemeSystem)); + FullCalendarParameters parameters = new FullCalendarParameters + { + ThemeSystem = ThemeSystem.JqueryUI + }; + ThemeSystemPropertyParser parser = new ThemeSystemPropertyParser(property); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().Contain("data-fc-ThemeSystem", "jquery-ui"); + } + } +} \ No newline at end of file diff --git a/FullCalendarMVC/FullCalendar.Tests/Infrastructure/PropertyParsers/UnitPropertyParserTests.cs b/FullCalendarMVC/FullCalendar.Tests/Infrastructure/PropertyParsers/UnitPropertyParserTests.cs new file mode 100644 index 0000000..2bbedb8 --- /dev/null +++ b/FullCalendarMVC/FullCalendar.Tests/Infrastructure/PropertyParsers/UnitPropertyParserTests.cs @@ -0,0 +1,66 @@ +using FluentAssertions; +using NUnit.Framework; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace FullCalendar.Infrastructure.PropertyParsers.Tests +{ + [TestFixture] + public class UnitPropertyParserTests + { + [Test] + public void AddPropertyToDictionary_ValueIsNull_PropertyIsNotAdded() + { + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.Height)); + FullCalendarParameters parameters = new FullCalendarParameters(); + UnitPropertyParser parser = new UnitPropertyParser(property); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().BeEmpty(); + } + + [Test] + public void AddPropertyToDictionary_ValueIsSetAsPixels_PropertyIsFormattedAccordingly() + { + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.ContentHeight)); + FullCalendarParameters parameters = new FullCalendarParameters + { + ContentHeight = Unit.Pixel(300) + }; + UnitPropertyParser parser = new UnitPropertyParser(property); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().Contain("data-fc-ContentHeight", "300px"); + } + + [Test] + public void AddPropertyToDictionary_ValueIsSetFunction_PropertyIsAddedAsString() + { + string function = "function() { alert(''); }"; + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.ContentHeight)); + FullCalendarParameters parameters = new FullCalendarParameters + { + ContentHeight = Unit.Function(function) + }; + UnitPropertyParser parser = new UnitPropertyParser(property); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().Contain("data-fc-ContentHeight", function); + } + + [Test] + public void AddPropertyToDictionary_ValueIsSetAsAuto_PropertyIsFormattedAccordingly() + { + PropertyInfo property = typeof(FullCalendarParameters).GetProperties().Single(x => x.Name == nameof(FullCalendarParameters.ContentHeight)); + FullCalendarParameters parameters = new FullCalendarParameters + { + ContentHeight = Unit.Auto() + }; + UnitPropertyParser parser = new UnitPropertyParser(property); + Dictionary target = new Dictionary(); + parser.AddPropertyToDictionary(parameters, ref target); + target.Should().Contain("data-fc-ContentHeight", "auto"); + } + } +} \ No newline at end of file diff --git a/FullCalendarMVC/FullCalendar.Tests/Mocks/ScriptIgnoreAttributeMock.cs b/FullCalendarMVC/FullCalendar.Tests/Mocks/ScriptIgnoreAttributeMock.cs new file mode 100644 index 0000000..ae0979b --- /dev/null +++ b/FullCalendarMVC/FullCalendar.Tests/Mocks/ScriptIgnoreAttributeMock.cs @@ -0,0 +1,10 @@ +using System.Web.Script.Serialization; + +namespace FullCalendar.Tests.Mocks +{ + public class ScriptIgnoreAttributeMock + { + [ScriptIgnore] + public int Id { get; set; } + } +} diff --git a/FullCalendarMVC/FullCalendar.Tests/Serialization/NullPropertiesConverterTests.cs b/FullCalendarMVC/FullCalendar.Tests/Serialization/NullPropertiesConverterTests.cs new file mode 100644 index 0000000..491cd6e --- /dev/null +++ b/FullCalendarMVC/FullCalendar.Tests/Serialization/NullPropertiesConverterTests.cs @@ -0,0 +1,78 @@ +using FluentAssertions; +using FullCalendar.Serialization.SerializableObjects; +using FullCalendar.Tests.Mocks; +using NUnit.Framework; +using System; +using System.Collections.Generic; + +namespace FullCalendar.Serialization.Tests +{ + [TestFixture] + public class NullPropertiesConverterTests + { + [Test] + public void Deserialize_UsedOnAJavaScriptSerializer_NotImplementedExceptionShouldBeThrown() + { + NullPropertiesConverter nullPropertiesConverter = new NullPropertiesConverter(); + Action target = () => + { + nullPropertiesConverter.Deserialize(null, typeof(int), null); + }; + target.ShouldThrow(); + } + + [Test] + public void Serialize_When_IntegerPropertyIsZero_PropertyIsNotAddedToSerialization() + { + NullPropertiesConverter nullPropertiesConverter = new NullPropertiesConverter(); + Duration duration = new Duration + { + Days = 1, + Weeks = 0, + Months = 2 + }; + IDictionary target = nullPropertiesConverter.Serialize(duration, null); + target.Should().Contain("Days", 1); + target.Should().Contain("Months", 2); + target.Should().NotContainKey("Weeks"); + } + + [Test] + public void Serialize_When_PropertyDecoratedWithScriptIgnoreAttribute_PropertyIsNotAddedToSerialization() + { + NullPropertiesConverter nullPropertiesConverter = new NullPropertiesConverter(); + ScriptIgnoreAttributeMock scriptIgnoreAttributeMock = new ScriptIgnoreAttributeMock + { + Id = 32 + }; + IDictionary target = nullPropertiesConverter.Serialize(scriptIgnoreAttributeMock, null); + target.Should().BeEmpty(); + } + + [Test] + public void Serialize_When_PropertyIsNull_PropertyIsNotAddedToSerialization() + { + NullPropertiesConverter nullPropertiesConverter = new NullPropertiesConverter(); + FullCalendarParameters parameters = new FullCalendarParameters + { + EventRenderWait = null + }; + IDictionary target = nullPropertiesConverter.Serialize(parameters, null); + target.Should().NotContainKey("EventRenderWait"); + } + + [Test] + public void Serialize_When_PropertiesAreNotNull_AllOfThemAreAddedToSerialization() + { + NullPropertiesConverter nullPropertiesConverter = new NullPropertiesConverter(); + SerializableValidRange validRange = new SerializableValidRange + { + start = "1:00", + end = "2:00" + }; + IDictionary target = nullPropertiesConverter.Serialize(validRange, null); + target.Should().Contain("start", "1:00"); + target.Should().Contain("end", "2:00"); + } + } +} \ No newline at end of file diff --git a/FullCalendarMVC/FullCalendar.Tests/packages.config b/FullCalendarMVC/FullCalendar.Tests/packages.config index 9d7081b..7cb6ec4 100644 --- a/FullCalendarMVC/FullCalendar.Tests/packages.config +++ b/FullCalendarMVC/FullCalendar.Tests/packages.config @@ -1,5 +1,9 @@  + + + + \ No newline at end of file diff --git a/FullCalendarMVC/FullCalendar/Infrastructure/ControlsBuilder.cs b/FullCalendarMVC/FullCalendar/Infrastructure/ControlsBuilder.cs index d3ac7d0..a69f31a 100644 --- a/FullCalendarMVC/FullCalendar/Infrastructure/ControlsBuilder.cs +++ b/FullCalendarMVC/FullCalendar/Infrastructure/ControlsBuilder.cs @@ -33,13 +33,12 @@ public ControlsBuilder AddSeparator(HeaderSeparator separator) { case HeaderSeparator.Adjacent: _buildedString += ","; - return this; + break; case HeaderSeparator.Gap: _buildedString += " "; - return this; - default: - return this; + break; } + return this; } ///