< Summary

Class:DCL.Interface.WebInterfaceFriendsController
Assembly:WebInterface
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WebInterface/WebInterfaceFriendsController.cs
Covered lines:10
Uncovered lines:23
Coverable lines:33
Total lines:103
Line coverage:30.3% (10 of 33)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
add_OnInitialized(...)0%110100%
remove_OnInitialized(...)0%110100%
add_OnUpdateFriendship(...)0%110100%
remove_OnUpdateFriendship(...)0%110100%
add_OnUpdateUserStatus(...)0%110100%
remove_OnUpdateUserStatus(...)0%110100%
add_OnFriendNotFound(...)0%110100%
remove_OnFriendNotFound(...)0%2100%
WebInterfaceFriendsController(...)0%2100%
GetFriends()0%2100%
GetUserStatus(...)0%2100%
ContainsStatus(...)0%2100%
RequestFriendship(...)0%2100%
CancelRequest(...)0%2100%
AcceptFriendship(...)0%2100%
RejectFriendship(...)0%2100%
IsFriend(...)0%2100%
RemoveFriend(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WebInterface/WebInterfaceFriendsController.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3
 4namespace DCL.Interface
 5{
 6    // TODO: remove this class when WebInterface assmebly removes the FriendController dependency
 7    public class WebInterfaceFriendsController : IFriendsController
 8    {
 9        private readonly IFriendsController friendsController;
 10
 11        public event Action OnInitialized
 12        {
 213            add => friendsController.OnInitialized += value;
 314            remove => friendsController.OnInitialized -= value;
 15        }
 16
 17        public event Action<string, FriendshipAction> OnUpdateFriendship
 18        {
 119            add => friendsController.OnUpdateFriendship += value;
 120            remove => friendsController.OnUpdateFriendship -= value;
 21        }
 22
 23        public event Action<string, FriendsController.UserStatus> OnUpdateUserStatus
 24        {
 225            add => friendsController.OnUpdateUserStatus += value;
 226            remove => friendsController.OnUpdateUserStatus -= value;
 27        }
 28
 29        public event Action<string> OnFriendNotFound
 30        {
 131            add => friendsController.OnFriendNotFound += value;
 032            remove => friendsController.OnFriendNotFound -= value;
 33        }
 34
 135        public int friendCount => friendsController.friendCount;
 236        public bool isInitialized => friendsController.isInitialized;
 137        public int ReceivedRequestCount => friendsController.ReceivedRequestCount;
 38
 039        public WebInterfaceFriendsController(IFriendsController friendsController)
 40        {
 041            this.friendsController = friendsController;
 042        }
 43
 044        public Dictionary<string, FriendsController.UserStatus> GetFriends() => friendsController.GetFriends();
 45
 046        public FriendsController.UserStatus GetUserStatus(string userId) => friendsController.GetUserStatus(userId);
 47
 48        public bool ContainsStatus(string friendId, FriendshipStatus status) =>
 049            friendsController.ContainsStatus(friendId, status);
 50
 51        public void RequestFriendship(string friendUserId)
 52        {
 053            friendsController.RequestFriendship(friendUserId);
 054            WebInterface.UpdateFriendshipStatus(new FriendsController.FriendshipUpdateStatusMessage
 55            {
 56                userId = friendUserId,
 57                action = FriendshipAction.REQUESTED_TO
 58            });
 059        }
 60
 61        public void CancelRequest(string friendUserId)
 62        {
 063            friendsController.CancelRequest(friendUserId);
 064            WebInterface.UpdateFriendshipStatus(new FriendsController.FriendshipUpdateStatusMessage
 65            {
 66                userId = friendUserId,
 67                action = FriendshipAction.CANCELLED
 68            });
 069        }
 70
 71        public void AcceptFriendship(string friendUserId)
 72        {
 073            friendsController.AcceptFriendship(friendUserId);
 074            WebInterface.UpdateFriendshipStatus(new FriendsController.FriendshipUpdateStatusMessage
 75            {
 76                userId = friendUserId,
 77                action = FriendshipAction.APPROVED
 78            });
 079        }
 80
 81        public void RejectFriendship(string friendUserId)
 82        {
 083            friendsController.RejectFriendship(friendUserId);
 084            WebInterface.UpdateFriendshipStatus(new FriendsController.FriendshipUpdateStatusMessage
 85            {
 86                userId = friendUserId,
 87                action = FriendshipAction.REJECTED
 88            });
 089        }
 90
 091        public bool IsFriend(string userId) => friendsController.IsFriend(userId);
 92
 93        public void RemoveFriend(string friendId)
 94        {
 095            friendsController.RemoveFriend(friendId);
 096            WebInterface.UpdateFriendshipStatus(new FriendsController.FriendshipUpdateStatusMessage
 97            {
 98                userId = friendId,
 99                action = FriendshipAction.DELETED
 100            });
 0101        }
 102    }
 103}