public void EnsureBothDirections() { var dictionary = new TwoWayDictionary <int, int>(); dictionary.Add(1, 2); Assert.True(dictionary.ContainsKey(1)); Assert.True(dictionary.ContainsValue(2)); Assert.False(dictionary.ContainsKey(2)); Assert.False(dictionary.ContainsValue(1)); Assert.Equal(2, dictionary[1]); Assert.Equal(1, dictionary.Reverse[2]); }
/// <summary> /// Gets room description from a given room template. /// </summary> /// <remarks> /// Returns cached result if a given room template was already processed. /// </remarks> /// <param name="roomTemplate"></param> /// <returns></returns> protected RoomDescription GetRoomDescription(GameObject roomTemplate) { if (RoomDescriptionsToRoomTemplates.ContainsValue(roomTemplate)) { return((RoomDescription)RoomDescriptionsToRoomTemplates.GetByValue(roomTemplate)); } var roomDescription = RoomShapesLoader.GetRoomDescription(roomTemplate); RoomDescriptionsToRoomTemplates.Add(roomDescription, roomTemplate); return(roomDescription); }