public void Args_throw_exception_with_null_travel_direction() { // Arrange var departure = Mock.Of<IRoom>(); var arrival = Mock.Of<IRoom>(); var character = Mock.Of<ICharacter>(); // Act var eventArgs = new RoomOccupancyChangedEventArgs( character, null, departure, arrival); }
public void Args_throw_exception_with_null_character() { // Arrange var departure = Mock.Of<IRoom>(); var arrival = Mock.Of<IRoom>(); var travelDirection = Mock.Of<ITravelDirection>(); // Act var eventArgs = new RoomOccupancyChangedEventArgs( null, travelDirection, departure, arrival); }
public void Event_arg_is_instanced_with_valid_properties() { // Arrange var departure = Mock.Of<IRoom>(); var arrival = Mock.Of<IRoom>(); var character = Mock.Of<ICharacter>(); var travelDirection = Mock.Of<ITravelDirection>(); // Act var eventArgs = new RoomOccupancyChangedEventArgs( character, travelDirection, departure, arrival); // Assert Assert.IsNotNull(eventArgs.Occupant, "Occupant was null."); Assert.IsNotNull(eventArgs.TravelDirection, "TravelDirection was null."); Assert.IsNotNull(eventArgs.ArrivalRoom, "ArrivalRoom was null."); Assert.IsNotNull(eventArgs.DepartureRoom, "DepartureRoom was null."); }
/// <summary> /// Called when an occupant is leaving a room owned by this zone, and entering a room owned by a different zone. /// </summary> /// <param name="roomOccupancyChange">The <see cref="MudDesigner.MudEngine.Environment.RoomOccupancyChangedEventArgs" /> instance containing the event data.</param> void OnLeftZone(RoomOccupancyChangedEventArgs roomOccupancyChange) { EventHandler<ZoneOccupancyChangedEventArgs> handler = this.LeftZone; if (handler == null) { return; } handler(this, new ZoneOccupancyChangedEventArgs(this, roomOccupancyChange)); }
/// <summary> /// Called when an occupant has left one of the rooms that this zone owns. /// </summary> /// <para> /// This method will check if the occupant leaving the room is entering a room in a different zone other than this instance. /// If so, then the LeftZone event is raised. /// </para> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="MudDesigner.MudEngine.Environment.RoomOccupancyChangedEventArgs" /> instance containing the event data.</param> void OccupantLeftRoom(object sender, RoomOccupancyChangedEventArgs e) { // Not sure what happened during travel, but the occupant does not have an arrival room. // So we don't do anything or the occupant is just traveling around within our zone, so we ignore it. if (e.ArrivalRoom == null || e.ArrivalRoom.Owner == this) { return; } this.OnLeftZone(e); }
/// <summary> /// Called when an occupant has entered one of the rooms that this zone owns. /// </summary> /// <para> /// This method will check if the occupant entering the room is entering a room in this zone for the first time. /// If so, then the EnteredZone event is raised. /// </para> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="MudDesigner.MudEngine.Environment.RoomOccupancyChangedEventArgs" /> instance containing the event data.</param> void OccupantEnteredRoom(object sender, RoomOccupancyChangedEventArgs e) { // The occupant is entering our zone for the first time. if (e.DepartureRoom == null) { this.OnEnteredZone(e); return; } // The occupant is moving around within our zone already. if (e.DepartureRoom.Owner == this) { return; } this.OnEnteredZone(e); }