public async Task CreateAndDeleteFollower_ByHandle()
        {
            var acct          = "myhandle";
            var host          = "domain.ext";
            var following     = new[] { 12, 19, 23 };
            var followingSync = new Dictionary <int, long>()
            {
                { 12, 165L },
                { 19, 166L },
                { 23, 167L }
            };
            var inboxRoute       = "/myhandle/inbox";
            var sharedInboxRoute = "/inbox";

            var dal = new FollowersPostgresDal(_settings);
            await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, following, followingSync);

            var result = await dal.GetFollowerAsync(acct, host);

            Assert.IsNotNull(result);

            await dal.DeleteFollowerAsync(acct, host);

            result = await dal.GetFollowerAsync(acct, host);

            Assert.IsNull(result);
        }
        public async Task CreateAndGetFollower()
        {
            var acct          = "myhandle";
            var host          = "domain.ext";
            var following     = new[] { 12, 19, 23 };
            var followingSync = new Dictionary <int, long>()
            {
                { 12, 165L },
                { 19, 166L },
                { 23, 167L }
            };
            var inboxRoute       = "/myhandle/inbox";
            var sharedInboxRoute = "/inbox";
            var actorId          = $"https://{host}/{acct}";

            var dal = new FollowersPostgresDal(_settings);
            await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, following, followingSync);

            var result = await dal.GetFollowerAsync(acct, host);

            Assert.IsNotNull(result);
            Assert.AreEqual(acct, result.Acct);
            Assert.AreEqual(host, result.Host);
            Assert.AreEqual(inboxRoute, result.InboxRoute);
            Assert.AreEqual(sharedInboxRoute, result.SharedInboxRoute);
            Assert.AreEqual(actorId, result.ActorId);
            Assert.AreEqual(following.Length, result.Followings.Count);
            Assert.AreEqual(following[0], result.Followings[0]);
            Assert.AreEqual(followingSync.Count, result.FollowingsSyncStatus.Count);
            Assert.AreEqual(followingSync.First().Key, result.FollowingsSyncStatus.First().Key);
            Assert.AreEqual(followingSync.First().Value, result.FollowingsSyncStatus.First().Value);
        }
        public async Task CreateUpdateAndGetFollower_Add()
        {
            var acct          = "myhandle";
            var host          = "domain.ext";
            var following     = new[] { 12, 19, 23 };
            var followingSync = new Dictionary <int, long>()
            {
                { 12, 165L },
                { 19, 166L },
                { 23, 167L }
            };
            var inboxRoute       = "/myhandle/inbox";
            var sharedInboxRoute = "/inbox";

            var dal = new FollowersPostgresDal(_settings);
            await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, following, followingSync);

            var result = await dal.GetFollowerAsync(acct, host);

            var updatedFollowing = new List <int> {
                12, 19, 23, 24
            };
            var updatedFollowingSync = new Dictionary <int, long>()
            {
                { 12, 170L },
                { 19, 171L },
                { 23, 172L },
                { 24, 173L }
            };

            result.Followings           = updatedFollowing.ToList();
            result.FollowingsSyncStatus = updatedFollowingSync;


            await dal.UpdateFollowerAsync(result);

            result = await dal.GetFollowerAsync(acct, host);

            Assert.AreEqual(updatedFollowing.Count, result.Followings.Count);
            Assert.AreEqual(updatedFollowing[0], result.Followings[0]);
            Assert.AreEqual(updatedFollowingSync.Count, result.FollowingsSyncStatus.Count);
            Assert.AreEqual(updatedFollowingSync.First().Key, result.FollowingsSyncStatus.First().Key);
            Assert.AreEqual(updatedFollowingSync.First().Value, result.FollowingsSyncStatus.First().Value);
        }
        public async Task CreateAndGetFollower_NoFollowings()
        {
            var acct             = "myhandle";
            var host             = "domain.ext";
            var inboxRoute       = "/myhandle/inbox";
            var sharedInboxRoute = "/inbox";
            var actorId          = $"https://{host}/{acct}";

            var dal = new FollowersPostgresDal(_settings);
            await dal.CreateFollowerAsync(acct, host, inboxRoute, sharedInboxRoute, actorId, null, null);

            var result = await dal.GetFollowerAsync(acct, host);

            Assert.IsNotNull(result);
            Assert.AreEqual(acct, result.Acct);
            Assert.AreEqual(host, result.Host);
            Assert.AreEqual(actorId, result.ActorId);
            Assert.AreEqual(inboxRoute, result.InboxRoute);
            Assert.AreEqual(sharedInboxRoute, result.SharedInboxRoute);
            Assert.AreEqual(0, result.Followings.Count);
            Assert.AreEqual(0, result.FollowingsSyncStatus.Count);
        }