| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | |
|
| | 4 | | public class FriendsController_Mock : IFriendsController |
| | 5 | | { |
| | 6 | | public event Action<string, FriendshipAction> OnUpdateFriendship; |
| | 7 | | public event Action<string, FriendsController.UserStatus> OnUpdateUserStatus; |
| | 8 | | public event Action<string> OnFriendNotFound; |
| | 9 | | public event Action OnInitialized; |
| | 10 | |
|
| 32 | 11 | | Dictionary<string, FriendsController.UserStatus> friends = new Dictionary<string, FriendsController.UserStatus>(); |
| | 12 | |
|
| 37 | 13 | | public int friendCount => friends.Count; |
| | 14 | |
|
| 30 | 15 | | public bool isInitialized => true; |
| | 16 | |
|
| 9 | 17 | | public Dictionary<string, FriendsController.UserStatus> GetFriends() { return friends; } |
| | 18 | |
|
| | 19 | | public void RaiseUpdateFriendship(string id, FriendshipAction action) |
| | 20 | | { |
| 18 | 21 | | if (action == FriendshipAction.NONE) |
| | 22 | | { |
| 0 | 23 | | if (friends.ContainsKey(id)) |
| 0 | 24 | | friends.Remove(id); |
| | 25 | | } |
| | 26 | |
|
| 18 | 27 | | if (action == FriendshipAction.APPROVED) |
| | 28 | | { |
| 11 | 29 | | if (!friends.ContainsKey(id)) |
| 11 | 30 | | friends.Add(id, new FriendsController.UserStatus()); |
| | 31 | | } |
| | 32 | |
|
| 18 | 33 | | OnUpdateFriendship?.Invoke(id, action); |
| 18 | 34 | | } |
| | 35 | |
|
| 16 | 36 | | public void RaiseUpdateUserStatus(string id, FriendsController.UserStatus userStatus) { OnUpdateUserStatus?.Invoke(i |
| | 37 | |
|
| 2 | 38 | | public void RaiseOnFriendNotFound(string id) { OnFriendNotFound?.Invoke(id); } |
| | 39 | |
|
| 30 | 40 | | public void AddFriend(FriendsController.UserStatus newFriend) { friends.Add(newFriend.userId, newFriend); } |
| | 41 | | } |