public async Task PlayerModel_AddItem_Default_Replace_Should_Pass() { // Arrange var data = new PlayerModel <BaseCharacter>(); await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 1, Id = "head" }); await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 20, Id = "necklass" }); var itemOld = ItemIndexViewModel.Instance.Dataset.FirstOrDefault(); var itemNew = ItemIndexViewModel.Instance.Dataset.LastOrDefault(); // Add the first item data.AddItem(ItemLocationEnum.Head, itemOld.Id); // Act // Add the second item, this will return the first item as the one replaced var result = data.AddItem(ItemLocationEnum.Head, itemNew.Id); // Reset // Assert Assert.AreEqual(itemOld.Id, result.Id); }
public async Task PlayerModel_GetDamageTotalString_Default_Speed_Should_Pass() { // Arrange // Add each model here to warm up and load it. DataSetsHelper.WarmUp(); await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 300, Id = "PrimaryHand", Damage = 1 }); var data = new PlayerModel <BaseCharacter>(); data.Level = 1; // Add the first item data.AddItem(ItemLocationEnum.PrimaryHand, (await ItemIndexViewModel.Instance.ReadAsync("PrimaryHand")).Id); DiceHelper.EnableForcedRolls(); DiceHelper.SetForcedRollValue(1); // Act // Add the second item, this will return the first item as the one replaced var result = data.GetDamageTotalString; // Reset DiceHelper.DisableForcedRolls(); // Assert Assert.AreEqual("1 + 1D 1", result); }
public void PlayerModel_AddItem_Unknown_Should_Fail() { // Arrange var data = new PlayerModel <BaseCharacter>(); // Act var result = data.AddItem(ItemLocationEnum.Unknown, "bogus"); // Reset // Assert Assert.AreEqual(null, result); }
public async Task PlayerModel_GetDamageRollValue_Default_Speed_Should_Pass() { // Arrange // Add each model here to warm up and load it. Game.Helpers.DataSetsHelper.WarmUp(); await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 1, Id = "head" }); await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 20, Id = "necklass" }); await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 300, Id = "PrimaryHand" }); await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 4000, Id = "OffHand" }); await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 50000, Id = "RightFinger" }); await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 600000, Id = "LeftFinger" }); await ItemIndexViewModel.Instance.CreateAsync(new ItemModel { Attribute = AttributeEnum.Attack, Value = 7000000, Id = "feet" }); var data = new PlayerModel <BaseCharacter>(); data.Level = 1; // Add the first item data.AddItem(ItemLocationEnum.Head, (await ItemIndexViewModel.Instance.ReadAsync("head")).Id); data.AddItem(ItemLocationEnum.Necklass, (await ItemIndexViewModel.Instance.ReadAsync("necklass")).Id); data.AddItem(ItemLocationEnum.PrimaryHand, (await ItemIndexViewModel.Instance.ReadAsync("PrimaryHand")).Id); data.AddItem(ItemLocationEnum.OffHand, (await ItemIndexViewModel.Instance.ReadAsync("OffHand")).Id); data.AddItem(ItemLocationEnum.RightFinger, (await ItemIndexViewModel.Instance.ReadAsync("RightFinger")).Id); data.AddItem(ItemLocationEnum.LeftFinger, (await ItemIndexViewModel.Instance.ReadAsync("LeftFinger")).Id); data.AddItem(ItemLocationEnum.Feet, (await ItemIndexViewModel.Instance.ReadAsync("feet")).Id); Game.Helpers.DiceHelper.EnableForcedRolls(); Game.Helpers.DiceHelper.SetForcedRollValue(1); // Act // Add the second item, this will return the first item as the one replaced var result = data.GetDamageRollValue(); // Reset Game.Helpers.DiceHelper.DisableForcedRolls(); // Assert Assert.AreEqual(2, result); }