Skip to content

Commit

Permalink
Merge pull request #46 from rianjs/MinorTestTweaks
Browse files Browse the repository at this point in the history
Get rid of referential equality, because it's not guaranteed or desir…
  • Loading branch information
rianjs authored Jul 14, 2016
2 parents 1377e15 + 2404b2b commit 065c641
Show file tree
Hide file tree
Showing 7 changed files with 386 additions and 363 deletions.
2 changes: 2 additions & 0 deletions ical.NET.Collections/ical.NET.Collections/GroupedList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public class GroupedList<TGroup, TItem> :
protected virtual TGroup GroupModifier(TGroup group)
{
if (group == null)
{
throw new ArgumentNullException(nameof(group), "The item's group cannot be null.");
}

return group;
}
Expand Down
74 changes: 32 additions & 42 deletions ical.NET.UnitTests/AttendeeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace ical.NET.UnitTests
[TestFixture]
public class AttendeeTest
{
internal static Event EvtFactory()
internal static Event VEventFactory()
{
return new Event
{
Expand All @@ -21,61 +21,53 @@ internal static Event EvtFactory()
};
}

const string req = "REQ-PARTICIPANT"; //this string may be added to the api in the future
internal static IList<Attendee> AttendeesFactory()
private const string _requiredParticipant = "REQ-PARTICIPANT"; //this string may be added to the api in the future
private static readonly IList<Attendee> _attendees = new List<Attendee>
{

return new[] {
new Attendee("MAILTO:[email protected]")
{
CommonName = "James James",
Role = req,
Rsvp = true,
ParticipationStatus = ParticipationStatus.Tentative
},
new Attendee("MAILTO:[email protected]")
{
CommonName = "Mary Mary",
Role = req,
Rsvp = true,
ParticipationStatus = ParticipationStatus.Accepted
}
};
}
new Attendee("MAILTO:[email protected]")
{
CommonName = "James James",
Role = _requiredParticipant,
Rsvp = true,
ParticipationStatus = ParticipationStatus.Tentative
},
new Attendee("MAILTO:[email protected]")
{
CommonName = "Mary Mary",
Role = _requiredParticipant,
Rsvp = true,
ParticipationStatus = ParticipationStatus.Accepted
}
}.AsReadOnly();


/// <summary>
/// Ensures that attendees can be properly added to an event.
/// </summary>
[Test, Category("Attendee")]
public void Add1Attendee()
{
var evt = EvtFactory();
var evt = VEventFactory();
Assert.AreEqual(0, evt.Attendees.Count);

var at = AttendeesFactory();

evt.Attendees.Add(at[0]);
evt.Attendees.Add(_attendees[0]);
Assert.AreEqual(1, evt.Attendees.Count);
Assert.AreSame(at[0], evt.Attendees[0]);

//the properties below had been set to null during the Attendees.Add operation in NuGet version 2.1.4
Assert.AreEqual(req, evt.Attendees[0].Role);
Assert.AreEqual(_requiredParticipant, evt.Attendees[0].Role);
Assert.AreEqual(ParticipationStatus.Tentative, evt.Attendees[0].ParticipationStatus);
}

[Test, Category("Attendee")]
public void Add2Attendees()
{
var evt = EvtFactory();
var evt = VEventFactory();
Assert.AreEqual(0, evt.Attendees.Count);

var at = AttendeesFactory();

evt.Attendees.Add(at[0]);
evt.Attendees.Add(at[1]);
evt.Attendees.Add(_attendees[0]);
evt.Attendees.Add(_attendees[1]);
Assert.AreEqual(2, evt.Attendees.Count);
Assert.AreSame(at[1], evt.Attendees[1]);

Assert.AreEqual(req, evt.Attendees[1].Role);
Assert.AreEqual(_requiredParticipant, evt.Attendees[1].Role);

var cal = new Calendar();
cal.Events.Add(evt);
Expand All @@ -89,17 +81,15 @@ public void Add2Attendees()
[Test, Category("Attendee")]
public void Remove1Attendee()
{
var evt = EvtFactory();

var evt = VEventFactory();
Assert.AreEqual(0, evt.Attendees.Count);
var at = AttendeesFactory()[0];
evt.Attendees.Add(at);

var attendee = _attendees[0];
evt.Attendees.Add(attendee);
Assert.AreEqual(1, evt.Attendees.Count);
Assert.AreSame(at, evt.Attendees[0]);

evt.Attendees.Remove(at);
evt.Attendees.Remove(attendee);
Assert.AreEqual(0, evt.Attendees.Count);
}

}
}
2 changes: 1 addition & 1 deletion ical.NET.UnitTests/CopyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void CopyCalendarTest(string calendarString)
{
var iCal1 = Calendar.LoadFromStream(new StringReader(calendarString))[0];
var iCal2 = iCal1.Copy<ICalendar>();
SerializationTest.CompareCalendars(iCal1, iCal2);
SerializationTests.CompareCalendars(iCal1, iCal2);
}

public static IEnumerable<ITestCaseData> CopyCalendarTest_TestCases()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace ical.NET.UnitTests
{
[TestFixture]
public class DeSerializationTest
public class DeserializationTests
{

[Test, Category("Deserialization")]
Expand Down
Loading

0 comments on commit 065c641

Please sign in to comment.