コード例 #1
0
        public void CreateRow()
        {
            var playerFeed = new PlayerFeed {
                Url = "a"
            };
            var playerFeedRow = PlayerFeedRow.CreateRow(playerFeed, DateTime.UtcNow);

            Assert.AreEqual("0", playerFeedRow.PartitionKey);
            Assert.AreEqual("a", playerFeedRow.Url);
            Assert.IsNull(playerFeedRow.LastSyncTimeUtc);
            Assert.IsNull(playerFeedRow.LastSyncWithChangesTimeUtc);
        }
コード例 #2
0
        public void CopyTo()
        {
            var playerFeed1 = new PlayerFeed {
                Url = "1"
            };
            var playerFeed2 = new PlayerFeed {
                Url = "2"
            };

            Assert.IsFalse(playerFeed1.Matches(playerFeed2));

            playerFeed1.CopyTo(playerFeed2);

            Assert.IsTrue(playerFeed1.Matches(playerFeed2));
        }
コード例 #3
0
        public void Matches()
        {
            var playerFeed1 = new PlayerFeed {
                Url = "1"
            };
            var playerFeed2 = new PlayerFeed {
                Url = "2"
            };

            Assert.IsTrue(playerFeed1.Matches(playerFeed1));
            Assert.IsFalse(playerFeed1.Matches(playerFeed2));
            Assert.IsFalse(playerFeed2.Matches(playerFeed1));

            playerFeed2.Url = "1";

            Assert.IsTrue(playerFeed1.Matches(playerFeed2));
            Assert.IsTrue(playerFeed2.Matches(playerFeed1));
        }
コード例 #4
0
        public void CreateRequeuedRow()
        {
            var rowKeyTimeUtc         = DateTime.UtcNow;
            var requeuedRowKeyTimeUtc = DateTime.UtcNow.AddTicks(1);
            var playerFeed            = new PlayerFeed {
                Url = "a"
            };
            var playerFeedRow         = PlayerFeedRow.CreateRow(playerFeed, rowKeyTimeUtc);
            var requeuedPlayerFeedRow = playerFeedRow.CreateRequeuedRow(
                syncTimeUtc: requeuedRowKeyTimeUtc,
                syncFoundChanges: true);

            Assert.AreEqual(requeuedRowKeyTimeUtc, requeuedPlayerFeedRow.LastSyncTimeUtc);
            Assert.AreEqual(requeuedRowKeyTimeUtc, requeuedPlayerFeedRow.LastSyncWithChangesTimeUtc);

            var reRequeuedRowKeyTimeUtc = DateTime.UtcNow.AddTicks(2);
            var reRequeuedPlayerFeedRow = requeuedPlayerFeedRow.CreateRequeuedRow(
                syncTimeUtc: reRequeuedRowKeyTimeUtc,
                syncFoundChanges: false);

            Assert.AreEqual(reRequeuedRowKeyTimeUtc, reRequeuedPlayerFeedRow.LastSyncTimeUtc);
            Assert.AreEqual(requeuedRowKeyTimeUtc, reRequeuedPlayerFeedRow.LastSyncWithChangesTimeUtc);
        }
コード例 #5
0
        public async Task RequeuePlayerRow()
        {
            var playerFeed = new PlayerFeed {
                Url = "1"
            };
            var players = Enumerable.Range(1, 3)
                          .Select(i => new Player
            {
                ID          = i.ToString(),
                FeedUrl     = playerFeed.Url,
                FirstSeason = DateTime.UtcNow.Year - 5,
                LastSeason  = DateTime.UtcNow.Year,
                BirthDate   = DateTime.UtcNow.AddYears(-25)
            })
                          .ToArray();
            var syncResult = new PlayersSyncResult(Enumerable.Empty <PlayerRow>(), players);
            await _tableService.UpdatePlayersTable(syncResult);

            var nextPlayerRow = (await _tableService.GetNextPlayerRows(1, TimeSpan.Zero)).Single();

            Assert.AreEqual("1", nextPlayerRow.ID);
            Assert.IsNull(nextPlayerRow.LastSyncSeason);
            Assert.IsNull(nextPlayerRow.LastSyncTimeUtc);
            Assert.IsNull(nextPlayerRow.LastSyncWithChangesTimeUtc);
            Assert.AreEqual(nextPlayerRow.FirstSeason, nextPlayerRow.GetNextSyncSeason());

            await _tableService.RequeuePlayerRow(nextPlayerRow, nextPlayerRow.GetNextSyncSeason(), syncFoundChanges : false);

            nextPlayerRow = (await _tableService.GetNextPlayerRows(1, TimeSpan.Zero)).Single();
            Assert.AreEqual("2", nextPlayerRow.ID);
            Assert.IsNull(nextPlayerRow.LastSyncSeason);
            Assert.IsNull(nextPlayerRow.LastSyncTimeUtc);
            Assert.IsNull(nextPlayerRow.LastSyncWithChangesTimeUtc);
            Assert.AreEqual(nextPlayerRow.FirstSeason, nextPlayerRow.GetNextSyncSeason());

            await _tableService.RequeuePlayerRow(nextPlayerRow, nextPlayerRow.GetNextSyncSeason(), syncFoundChanges : true);

            nextPlayerRow = (await _tableService.GetNextPlayerRows(1, TimeSpan.Zero)).Single();
            Assert.AreEqual("3", nextPlayerRow.ID);
            Assert.IsNull(nextPlayerRow.LastSyncSeason);
            Assert.IsNull(nextPlayerRow.LastSyncTimeUtc);
            Assert.IsNull(nextPlayerRow.LastSyncWithChangesTimeUtc);
            Assert.AreEqual(nextPlayerRow.FirstSeason, nextPlayerRow.GetNextSyncSeason());

            await _tableService.RequeuePlayerRow(nextPlayerRow, nextPlayerRow.GetNextSyncSeason(), syncFoundChanges : true);

            nextPlayerRow = (await _tableService.GetNextPlayerRows(1, TimeSpan.Zero)).Single();
            Assert.AreEqual("1", nextPlayerRow.ID);
            Assert.AreEqual(nextPlayerRow.FirstSeason, nextPlayerRow.LastSyncSeason);
            Assert.IsNotNull(nextPlayerRow.LastSyncTimeUtc);
            Assert.IsNull(nextPlayerRow.LastSyncWithChangesTimeUtc);
            Assert.AreEqual(nextPlayerRow.FirstSeason + 1, nextPlayerRow.GetNextSyncSeason());

            await _tableService.RequeuePlayerRow(nextPlayerRow, nextPlayerRow.GetNextSyncSeason(), syncFoundChanges : true);

            nextPlayerRow = (await _tableService.GetNextPlayerRows(1, TimeSpan.Zero)).Single();
            Assert.AreEqual("2", nextPlayerRow.ID);
            Assert.AreEqual(nextPlayerRow.FirstSeason, nextPlayerRow.LastSyncSeason);
            Assert.IsNotNull(nextPlayerRow.LastSyncTimeUtc);
            Assert.IsNotNull(nextPlayerRow.LastSyncWithChangesTimeUtc);
            Assert.AreEqual(nextPlayerRow.FirstSeason + 1, nextPlayerRow.GetNextSyncSeason());

            await _tableService.RequeuePlayerRow(nextPlayerRow, nextPlayerRow.GetNextSyncSeason(), syncFoundChanges : true);

            var nextPlayerRows = await _tableService.GetNextPlayerRows(3, TimeSpan.Zero);

            CollectionAssert.AreEqual(
                new[] { "3", "1", "2" },
                nextPlayerRows.Select(r => r.ID).ToArray());

            nextPlayerRow = (await _tableService.GetNextPlayerRows(1, TimeSpan.Zero)).Single();
            Assert.AreEqual("3", nextPlayerRow.ID);

            nextPlayerRow.FirstSeason = 2000;
            nextPlayerRow.LastSeason  = 2010;
            await _tableService.RequeuePlayerRow(nextPlayerRow, 2010, syncFoundChanges : true);

            var playerRows = await _tableService.GetPlayerRows(playerFeed);

            Assert.AreEqual("1", playerRows[0].ID);
            Assert.AreEqual("2", playerRows[1].ID);
            Assert.AreEqual("3", playerRows[2].ID);
            Assert.AreEqual(playerRows[0].FirstSeason + 2, playerRows[0].GetNextSyncSeason());
            Assert.AreEqual(playerRows[1].FirstSeason + 2, playerRows[1].GetNextSyncSeason());
            Assert.AreEqual(playerRows[2].FirstSeason, playerRows[2].GetNextSyncSeason());

            nextPlayerRow = (await _tableService.GetNextPlayerRows(1, TimeSpan.Zero)).Single();
            Assert.AreEqual("1", nextPlayerRow.ID);

            await _tableService.RequeuePlayerRow(nextPlayerRow, nextPlayerRow.GetNextSyncSeason(), syncFoundChanges : true);

            nextPlayerRow = (await _tableService.GetNextPlayerRows(1, TimeSpan.Zero)).Single();
            Assert.AreEqual("2", nextPlayerRow.ID);

            await _tableService.RequeuePlayerRow(nextPlayerRow, nextPlayerRow.GetNextSyncSeason(), syncFoundChanges : true);

            nextPlayerRow = (await _tableService.GetNextPlayerRows(1, TimeSpan.Zero)).Single();
            Assert.AreEqual("1", nextPlayerRow.ID); // 3 has been deprioritized.
        }
コード例 #6
0
 public void ShowKillFeed(string[] data)
 {
     killText.text = PlayerFeed.GetKillFeed(data);
     StartCoroutine(DeleteAfter());
 }