-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from rianjs/MinorTestTweaks
Get rid of referential equality, because it's not guaranteed or desir…
- Loading branch information
Showing
7 changed files
with
386 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ namespace ical.NET.UnitTests | |
[TestFixture] | ||
public class AttendeeTest | ||
{ | ||
internal static Event EvtFactory() | ||
internal static Event VEventFactory() | ||
{ | ||
return new Event | ||
{ | ||
|
@@ -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); | ||
|
@@ -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); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.