public void DialogService_LoadConversation_ShouldReturnPlayerDialog() { INWScript script = Substitute.For <INWScript>(); INWNXCreature nwnxCreature = Substitute.For <INWNXCreature>(); DialogService service = new DialogService( script, new AppState() ); NWPlayer player = Substitute.For <NWPlayer>(script, nwnxCreature); player.GlobalID.Returns(x => "123"); NWObject talkTo = Substitute.For <NWObject>(script); service.LoadConversation(player, talkTo, "ValidConversation", 1); PlayerDialog dialog = service.LoadPlayerDialog(player.GlobalID); Assert.IsNotNull(dialog); Assert.AreEqual("MainPage", dialog.CurrentPageName); Assert.AreEqual(1, dialog.DialogNumber); Assert.AreSame(talkTo, dialog.DialogTarget); Assert.AreEqual("ValidConversation", dialog.ActiveDialogName); }
public void DialogService_StartConversation_NoDialogsAvailable_ShouldThrowException() { INWScript script = Substitute.For <INWScript>(); INWNXCreature nwnxCreature = Substitute.For <INWNXCreature>(); DialogService service = new DialogService( script, new AppState() ); for (int number = 1; number <= 99; number++) { NWPlayer player = Substitute.For <NWPlayer>(script, nwnxCreature); string id = Convert.ToString(number); player.GlobalID.Returns(x => id); NWObject talkTo = Substitute.For <NWObject>(script); service.LoadConversation(player, talkTo, "ValidConversation", number); } NWPlayer refusedPlayer = Substitute.For <NWPlayer>(script, nwnxCreature); NWCreature refusedTalkTo = Substitute.For <NWCreature>(script, nwnxCreature); Assert.Throws(typeof(ArgumentOutOfRangeException), () => { service.StartConversation(refusedPlayer, refusedTalkTo, "ValidConversation"); }); }
public PlayerService( INWScript script, IDataService data, IColorTokenService color, INWNXCreature nwnxCreature, INWNXPlayer player, INWNXPlayerQuickBarSlot qbs, IDialogService dialog, INWNXEvents nwnxEvents, IBackgroundService background, IRaceService race, IDurabilityService durability, IPlayerStatService stat, ILanguageService language) { _ = script; _data = data; _color = color; _nwnxCreature = nwnxCreature; _player = player; _qbs = qbs; _dialog = dialog; _nwnxEvents = nwnxEvents; _background = background; _race = race; _durability = durability; _stat = stat; _language = language; }
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); }
public NWCreature(INWScript script, INWNXCreature creature, AppState state) : base(script, state) { _nwnxCreature = creature; }
public DualWielding(INWScript script, INWNXCreature nwnxCreature, IPerkService perk) { _ = script; _nwnxCreature = nwnxCreature; _perk = perk; }
public Opportunist(INWScript script, INWNXCreature nwnxCreature, IPerkService perk) { _ = script; _nwnxCreature = nwnxCreature; _perk = perk; }
public CalledShot(INWScript script, INWNXCreature nwnxCreature, IPerkService perk) { _ = script; _nwnxCreature = nwnxCreature; _perk = perk; }
public ImprovedCritical(INWScript script, INWNXCreature nwnxCreature, IPerkService perk) { _ = script; _nwnxCreature = nwnxCreature; _perk = perk; }
public Focus(INWScript script, INWNXCreature nwnxCreature, IPerkService perk) { _ = script; _nwnxCreature = nwnxCreature; _perk = perk; }
public WeaponFinesse(INWScript script, INWNXCreature nwnxCreature, IPerkService perk) { _ = script; _nwnxCreature = nwnxCreature; _perk = perk; }
public BluntPowerAttack(INWScript script, INWNXCreature nwnxCreature, IPerkService perk) { _ = script; _nwnxCreature = nwnxCreature; _perk = perk; }
public TwinBladeMastery(INWScript script, INWNXCreature nwnxCreature, IPerkService perk) { _ = script; _nwnxCreature = nwnxCreature; _perk = perk; }
public SaberstaffMastery( INWScript script, INWNXCreature nwnxCreature, IPerkService perk) { _ = script; _nwnxCreature = nwnxCreature; _perk = perk; }
public Provoke(INWNXCreature nwnxCreature, IPerkService perk, IEnmityService enmity, INWScript script) { _nwnxCreature = nwnxCreature; _perk = perk; _enmity = enmity; _ = script; }
public DurabilityService( INWScript script, IColorTokenService color, INWNXProfiler nwnxProfiler, INWNXCreature creature) { _ = script; _color = color; _nwnxProfiler = nwnxProfiler; _creature = creature; }
public NWPlayer(INWScript script, INWNXCreature nwnxCreature, AppState state, ICustomEffectService customEffect, ISkillService skill, IItemService item) : base(script, nwnxCreature, state) { _customEffect = customEffect; _skill = skill; _item = item; }
public void DurabilityService_SetDurability_InvalidArguments_ShouldThrowException() { INWScript script = Substitute.For <INWScript>(); IColorTokenService color = Substitute.For <IColorTokenService>(); INWNXProfiler nwnxProfiler = Substitute.For <INWNXProfiler>(); INWNXCreature creature = Substitute.For <INWNXCreature>(); DurabilityService service = new DurabilityService(script, color, nwnxProfiler, creature); Assert.Throws(typeof(ArgumentNullException), () => { service.SetMaxDurability(null, 0.0f); }); }
public void DialogService_StartConversation_InvalidArguments_ShouldThrowException() { INWScript script = Substitute.For <INWScript>(); INWNXCreature nwnxCreature = Substitute.For <INWNXCreature>(); DialogService service = new DialogService( script, new AppState() ); NWPlayer player = Substitute.For <NWPlayer>(script, nwnxCreature); player.GlobalID.Returns(x => "123"); NWObject talkTo = Substitute.For <NWObject>(script); Assert.Throws(typeof(ArgumentNullException), () => { service.StartConversation(null, talkTo, "ValidConversation"); }); Assert.Throws(typeof(ArgumentNullException), () => { player.Object.Returns(x => null); service.StartConversation(player, talkTo, "ValidConversation"); }); player = Substitute.For <NWPlayer>(script, nwnxCreature); Assert.Throws(typeof(ArgumentNullException), () => { service.StartConversation(player, null, "ValidConversation"); }); talkTo.Object.Returns(x => null); Assert.Throws(typeof(ArgumentNullException), () => { service.StartConversation(player, talkTo, "ValidConversation"); }); talkTo = Substitute.For <NWObject>(script); Assert.Throws(typeof(ArgumentException), () => { service.StartConversation(player, talkTo, null); }); Assert.Throws(typeof(ArgumentException), () => { service.StartConversation(player, talkTo, string.Empty); }); Assert.Throws(typeof(ArgumentException), () => { service.StartConversation(player, talkTo, " "); }); }
public PlayerService( INWScript script, IDataContext db, IDeathService death, IColorTokenService color, INWNXCreature nwnxCreature, ISkillService skill) { _ = script; _db = db; _death = death; _color = color; _nwnxCreature = nwnxCreature; _skill = skill; }
public void DurabilityService_GetMaxDurability_ShouldReturnDefault() { INWScript script = Substitute.For <INWScript>(); IColorTokenService color = Substitute.For <IColorTokenService>(); INWNXProfiler nwnxProfiler = Substitute.For <INWNXProfiler>(); INWNXCreature creature = Substitute.For <INWNXCreature>(); DurabilityService service = new DurabilityService(script, color, nwnxProfiler, creature); NWItem item = Substitute.For <NWItem>(script, service); item.BaseItemType.Returns(x => NWScript.BASE_ITEM_LONGSWORD); float result = service.GetMaxDurability(item); Assert.AreEqual(30.0f, result); }
public PlayerStatService( INWScript script, ICustomEffectService customEffect, INWNXCreature nwnxCreature, IItemService item, IDataService data, IPerkService perk) { _ = script; _customEffect = customEffect; _item = item; _data = data; _perk = perk; _nwnxCreature = nwnxCreature; }
public void DurabilityService_GetDurability_ShouldReturn6Point23() { INWScript script = Substitute.For <INWScript>(); IColorTokenService color = Substitute.For <IColorTokenService>(); INWNXProfiler nwnxProfiler = Substitute.For <INWNXProfiler>(); INWNXCreature creature = Substitute.For <INWNXCreature>(); DurabilityService service = new DurabilityService(script, color, nwnxProfiler, creature); NWItem item = Substitute.For <NWItem>(script, service); item.BaseItemType.Returns(x => NWScript.BASE_ITEM_LONGSWORD); item.GetLocalFloat(Arg.Any <string>()).Returns(6.23f); float result = service.GetDurability(item); Assert.AreEqual(6.23f, result); }
public PerkService(INWScript script, IColorTokenService color, IDataContext db, IBiowareXP2 biowareXP2, INWNXCreature nwnxCreature, INWNXPlayerQuickBarSlot nwnxQBS, INWNXPlayer nwnxPlayer) { _ = script; _color = color; _db = db; _biowareXP2 = biowareXP2; _nwnxCreature = nwnxCreature; _nwnxQBS = nwnxQBS; _nwnxPlayer = nwnxPlayer; }
public void DurabilityService_SetDurability_InvalidType_ShouldNotRunOnce() { INWScript script = Substitute.For <INWScript>(); IColorTokenService color = Substitute.For <IColorTokenService>(); INWNXProfiler nwnxProfiler = Substitute.For <INWNXProfiler>(); INWNXCreature creature = Substitute.For <INWNXCreature>(); DurabilityService service = new DurabilityService(script, color, nwnxProfiler, creature); bool ranOnce = false; NWItem item = Substitute.For <NWItem>(script, service); item.BaseItemType.Returns(x => NWScript.BASE_ITEM_BLANK_SCROLL); item.When(x => x.SetLocalFloat(Arg.Any <string>(), Arg.Any <float>())) .Do(x => ranOnce = true); service.SetDurability(item, 999.0f); Assert.AreEqual(false, ranOnce); }
public void DurabilityService_SetDurability_ShouldSetToSpecifiedValue() { INWScript script = Substitute.For <INWScript>(); IColorTokenService color = Substitute.For <IColorTokenService>(); INWNXProfiler nwnxProfiler = Substitute.For <INWNXProfiler>(); INWNXCreature creature = Substitute.For <INWNXCreature>(); DurabilityService service = new DurabilityService(script, color, nwnxProfiler, creature); float value = 0.0f; NWItem item = Substitute.For <NWItem>(script, service); item.BaseItemType.Returns(x => NWScript.BASE_ITEM_LONGSWORD); item.When(x => x.SetLocalFloat("DURABILITY_CURRENT", Arg.Any <float>())) .Do(x => value = x.ArgAt <float>(1)); service.SetDurability(item, 12.52f); Assert.AreEqual(12.52f, value); }
public void DialogService_LoadConversation_InvalidArguments_ShouldThrowExceptions() { INWScript script = Substitute.For <INWScript>(); INWNXCreature nwnxCreature = Substitute.For <INWNXCreature>(); DialogService service = new DialogService( script, new AppState() ); NWPlayer player = Substitute.For <NWPlayer>(script, nwnxCreature); NWObject talkTo = Substitute.For <NWObject>(script); Assert.Throws(typeof(ArgumentNullException), () => { service.LoadConversation(null, talkTo, "MyClass", 1); }); Assert.Throws(typeof(ArgumentNullException), () => { service.LoadConversation(player, null, "MyClass", 1); }); Assert.Throws(typeof(ArgumentException), () => { service.LoadConversation(player, talkTo, null, 1); }); Assert.Throws(typeof(ArgumentException), () => { service.LoadConversation(player, talkTo, string.Empty, 1); }); Assert.Throws(typeof(ArgumentException), () => { service.LoadConversation(player, talkTo, " ", 1); }); Assert.Throws(typeof(ArgumentOutOfRangeException), () => { service.LoadConversation(player, talkTo, "MyClass", -50); }); Assert.Throws(typeof(ArgumentOutOfRangeException), () => { service.LoadConversation(player, talkTo, "MyClass", 0); }); Assert.Throws(typeof(ArgumentOutOfRangeException), () => { service.LoadConversation(player, talkTo, "MyClass", 100); }); }
public void DurabilityService_SetMaxDurability_ShouldSetToDefaultValue() { INWScript script = Substitute.For <INWScript>(); IColorTokenService color = Substitute.For <IColorTokenService>(); INWNXProfiler nwnxProfiler = Substitute.For <INWNXProfiler>(); INWNXCreature creature = Substitute.For <INWNXCreature>(); DurabilityService service = new DurabilityService(script, color, nwnxProfiler, creature); float value = 0.0f; NWItem item = Substitute.For <NWItem>(script, service); item.BaseItemType.Returns(x => NWScript.BASE_ITEM_LONGSWORD); item.When(x => x.SetLocalFloat(Arg.Any <string>(), Arg.Any <float>())) .Do(x => value = x.ArgAt <float>(1)); service.SetMaxDurability(item, -50.0f); Assert.AreEqual(30.0f, value); }
public void SetUp() { IQueryable <Background> backgrounds = new List <Background> { new Background { BackgroundID = 1, Bonuses = "+1 STR", Description = "MyBackground1", IsActive = true, Name = "Background 1" }, new Background { BackgroundID = 2, Bonuses = "None", Description = "MyBackground2", IsActive = true, Name = "Background 2" }, new Background { BackgroundID = 3, Bonuses = "+1 DEX", Description = "MyBackground3", IsActive = true, Name = "Background 3" }, new Background { BackgroundID = 4, Bonuses = "+2 STR", Description = "MyBackground4", IsActive = false, Name = "Background 4" }, new Background { BackgroundID = 5, Bonuses = "+1 WIS", Description = "MyBackground5", IsActive = true, Name = "Background 5" }, new Background { BackgroundID = 6, Bonuses = "+1 CHA", Description = "MyBackground6", IsActive = false, Name = "Background 6" }, new Background { BackgroundID = 7, Bonuses = "+4 CON", Description = "MyBackground7", IsActive = true, Name = "Background 7" }, }.AsQueryable(); IDbSet <Background> backgroundDbSet = Substitute.For <IDbSet <Background> >(); backgroundDbSet.Provider.Returns(backgrounds.Provider); backgroundDbSet.Expression.Returns(backgrounds.Expression); backgroundDbSet.ElementType.Returns(backgrounds.ElementType); backgroundDbSet.GetEnumerator().Returns(backgrounds.GetEnumerator()); _db = Substitute.For <IDataContext>(); _db.Backgrounds.Returns(backgroundDbSet); _ = Substitute.For <INWScript>(); _perk = Substitute.For <IPerkService>(); _skill = Substitute.For <ISkillService>(); _nwnxCreature = Substitute.For <INWNXCreature>(); }
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); }); }