コード例 #1
0
        public void DeathService_BindPlayerSoul_ShouldUpdateDatabaseAndNotCallFloatingTextStringOnCreature()
        {
            // Arrange
            int                   callCount     = -1;
            INWScript             script        = Substitute.For <INWScript>();
            INWNXCreature         nwnxCreature  = Substitute.For <INWNXCreature>();
            ISerializationService serialization = Substitute.For <ISerializationService>();
            IRandomService        random        = Substitute.For <IRandomService>();
            IColorTokenService    color         = Substitute.For <IColorTokenService>();

            script.When(x => x.FloatingTextStringOnCreature(Arg.Any <string>(), Arg.Any <Object>(), Arg.Any <int>())).Do(x => callCount++);

            DeathService service = new DeathService(_db, script, serialization, random, color);
            NWPlayer     player  = Substitute.For <NWPlayer>(script, nwnxCreature);

            player.Object.Returns(x => new Object());
            player.GlobalID.Returns("123");
            player.Position.Returns(x => new Vector(43.2f, 22.2f, 87.0f));
            player.Facing.Returns(x => 320.666f);
            player.Area.Returns(x => new NWArea(script));
            player.Area.Tag.Returns("a_fake_area_tag");

            // Act
            service.BindPlayerSoul(player, false);
            var result = _db.PlayerCharacters.Single(x => x.PlayerID == "123");

            // Assert
            Assert.AreEqual(43.2f, result.RespawnLocationX);
            Assert.AreEqual(22.2f, result.RespawnLocationY);
            Assert.AreEqual(87.0f, result.RespawnLocationZ);
            Assert.AreEqual(320.666f, result.RespawnLocationOrientation);
            Assert.AreEqual("a_fake_area_tag", result.RespawnAreaTag);
            Assert.AreEqual(-1, callCount);
        }
コード例 #2
0
ファイル: CloningTerminal.cs プロジェクト: Terallis/SWLOR_NWN
 public override void DoAction(NWPlayer player, string pageName, int responseID)
 {
     if (responseID == 1)
     {
         DeathService.SetRespawnLocation(player);
         EndConversation();
     }
 }
コード例 #3
0
        public void DeathService_BindPlayerSoul_ArgumentNullPlayer_ShouldThrowArgumentNullException()
        {
            // Arrange
            ISerializationService serialization = Substitute.For <ISerializationService>();
            IRandomService        random        = Substitute.For <IRandomService>();
            IColorTokenService    color         = Substitute.For <IColorTokenService>();
            DeathService          service       = new DeathService(_db, Substitute.For <INWScript>(), serialization, random, color);

            // Assert
            Assert.Throws(typeof(ArgumentNullException), () =>
            {
                // Act
                service.BindPlayerSoul(null, false);
            });
        }
コード例 #4
0
        public void DeathService_BindPlayerSoul_NoPlayers_ShouldThrowInvalidOperationException()
        {
            // Arrange
            INWScript             script        = Substitute.For <INWScript>();
            INWNXCreature         nwnxCreature  = Substitute.For <INWNXCreature>();
            ISerializationService serialization = Substitute.For <ISerializationService>();
            IRandomService        random        = Substitute.For <IRandomService>();
            IColorTokenService    color         = Substitute.For <IColorTokenService>();
            DeathService          service       = new DeathService(_db, script, serialization, random, color);
            NWPlayer player = Substitute.For <NWPlayer>(script, nwnxCreature);

            // Assert
            Assert.Throws(typeof(InvalidOperationException), () =>
            {
                // Act
                service.BindPlayerSoul(player, false);
            });
        }
コード例 #5
0
        public void DeathService_BindPlayerSoul_ArgumentNullPlayerObject_ShouldThrowArgumentNullException()
        {
            // Arrange
            INWScript             script        = Substitute.For <INWScript>();
            INWNXCreature         nwnxCreature  = Substitute.For <INWNXCreature>();
            ISerializationService serialization = Substitute.For <ISerializationService>();
            IRandomService        random        = Substitute.For <IRandomService>();
            IColorTokenService    color         = Substitute.For <IColorTokenService>();

            DeathService service = new DeathService(_db, script, serialization, random, color);
            NWPlayer     player  = Substitute.For <NWPlayer>(script, nwnxCreature);

            player.Object.Returns(x => null);

            // Assert
            Assert.Throws(typeof(ArgumentNullException), () =>
            {
                // Act
                service.BindPlayerSoul(player, false);
            });
        }
コード例 #6
0
 public YearModule(StewardContext stewardContext, DeathService deathService)
 {
     _stewardContext = stewardContext;
     _deathService   = deathService;
 }
コード例 #7
0
ファイル: AdminModule.cs プロジェクト: walkerofdubai/Steward
 public AdminModule(StewardContext stewardContext, DeathService deathService, DiscordSocketClient client)
 {
     _stewardContext = stewardContext;
     _deathService   = deathService;
     _client         = client;
 }