Exemplo n.º 1
0
        public void RemoveTribesman_ShouldSupportMultipleRemoves(ITribesman tribesman1, ITribesman tribesman2, Tribe tribe)
        {
            tribesman1.Player.PlayerId.Returns <uint>(1234);
            tribesman2.Player.PlayerId.Returns <uint>(1235);

            SystemClock.SetClock(new DateTime(2000, 1, 1, 1, 1, 1));
            tribe.AddTribesman(tribesman1);
            tribe.AddTribesman(tribesman2);
            tribe.RemoveTribesman(1234, false, false);
            tribe.RemoveTribesman(1235, false, false);
            tribe.LeavingTribesmates.Should().HaveCount(2)
            .And.Contain(p => p.PlayerId == 1234)
            .And.Contain(p => p.PlayerId == 1235);
        }
Exemplo n.º 2
0
        public void RemoveTribesman_ShouldRemoveDuplicateEntriesForSamePlayer(ITribesman tribesman, Tribe tribe)
        {
            tribesman.Player.PlayerId.Returns <uint>(1234);

            SystemClock.SetClock(new DateTime(2000, 1, 1, 1, 1, 1));
            tribe.AddTribesman(tribesman);
            tribe.RemoveTribesman(1234, false, false);

            SystemClock.SetClock(new DateTime(2001, 1, 1, 1, 1, 2));
            tribe.AddTribesman(tribesman);
            tribe.RemoveTribesman(1234, false, false);

            tribe.LeavingTribesmates.Should().OnlyContain(p => p.PlayerId == 1234 && p.TimeLeft == SystemClock.Now);
        }
Exemplo n.º 3
0
        public void RemoveTribesman_ShouldRemoveOlderRecords(ITribesman tribesman1, ITribesman tribesman2, Tribe tribe)
        {
            tribesman1.Player.PlayerId.Returns <uint>(1234);
            tribesman2.Player.PlayerId.Returns <uint>(1235);

            SystemClock.SetClock(new DateTime(2000, 1, 1, 1, 1, 1));
            tribe.AddTribesman(tribesman1);
            tribe.AddTribesman(tribesman2);
            tribe.RemoveTribesman(1234, false, false);
            tribe.LeavingTribesmates.Should().OnlyContain(p => p.PlayerId == 1234);

            SystemClock.SetClock(SystemClock.Now.AddDays(Tribe.DAYS_BEFORE_REJOIN_ALLOWED).AddSeconds(1));
            tribe.RemoveTribesman(1235, false, false);

            tribe.LeavingTribesmates.Should().OnlyContain(p => p.PlayerId == 1235);
        }
Exemplo n.º 4
0
        public void AddTribesman_ShouldAllowTribesmanWhoLeftToRejoinAfterXHours(ITribesman tribesman, Tribe tribe)
        {
            SystemClock.SetClock(new DateTime(2000, 1, 1, 1, 1, 1));

            tribesman.Player.PlayerId.Returns((uint)1234);

            tribe.AddTribesman(tribesman);
            tribe.RemoveTribesman(1234, false, false);

            SystemClock.SetClock(SystemClock.Now.AddDays(Tribe.DAYS_BEFORE_REJOIN_ALLOWED));
            tribe.AddTribesman(tribesman).Should().Be(Error.Ok);
        }
Exemplo n.º 5
0
        public void AddTribesman_ShouldNotAllowTribesmanWhoLeftToRejoinWithinXDays(ITribesman tribesman, Tribe tribe)
        {
            SystemClock.SetClock(new DateTime(2000, 1, 1, 1, 1, 1));

            tribesman.Player.PlayerId.Returns((uint)1234);

            tribe.AddTribesman(tribesman);
            tribe.RemoveTribesman(1234, false, false);

            SystemClock.SetClock(SystemClock.Now.AddDays(Tribe.DAYS_BEFORE_REJOIN_ALLOWED).AddMinutes(-1));
            tribe.AddTribesman(tribesman).Should().Be(Error.TribeCannotRejoinYet);
        }
Exemplo n.º 6
0
        public void RemoveTribesman_ShouldDeleteTribesman([Frozen] IDbManager dbManager, IPlayer player, ITribesman tribesman, Tribe tribe)
        {
            player.PlayerId.Returns <uint>(1234);
            tribesman.Player.Returns(player);

            tribe.AddTribesman(tribesman);
            tribe.RemoveTribesman(1234, false, false);

            player.Tribesman.Should().BeNull();
            dbManager.Received(1).Delete(tribesman);
            tribe.Tribesmen.Should().BeEmpty();
        }
Exemplo n.º 7
0
 public void RemoveTribesman_ShouldNotBeAbleToRemoveNonExistingTribesmate(Tribe tribe)
 {
     tribe.RemoveTribesman(1234, false, false).Should().Be(Error.TribesmanNotFound);
 }