public void LookupItemCategory_CategoryNotFound_ShouldReturnNull() { IConfiguration config = Mock.Of <IConfiguration>(m => m["Emissary:ManifestPath"] == "data/dummy.manifest"); uint nonexistentCategoryHash = 0; IDatabaseAccessor databaseAccessor = Mock.Of <IDatabaseAccessor>(); Mock.Get(databaseAccessor) .Setup(m => m.ExecuteCommand( It.Is <string>(s => s.Contains(((int)nonexistentCategoryHash).ToString())), It.IsRegex(@".*\.manifest$"))) .Returns(""); ManifestDao manifestDao = new ManifestDao(config, databaseAccessor); ManifestItemCategoryDefinition actual = manifestDao.GetItemCategoryDefinition(nonexistentCategoryHash); Assert.IsNull(actual); }
public void LookupItemCategory_KineticWeapon_ShouldReturnItemDefinitionWithCorrectValues() { IConfiguration config = Mock.Of <IConfiguration>(m => m["Emissary:ManifestPath"] == "data/dummy.manifest"); uint kineticWeaponCategoryHash = 2; string jsonResponse = TestUtils.ReadFile("category-kinetic-weapon.json"); IDatabaseAccessor databaseAccessor = Mock.Of <IDatabaseAccessor>(); Mock.Get(databaseAccessor) .Setup(m => m.ExecuteCommand( It.Is <string>(s => s.Contains(((int)kineticWeaponCategoryHash).ToString())), It.IsRegex(@".*\.manifest$"))) .Returns(jsonResponse); ManifestItemCategoryDefinition expected = new ManifestItemCategoryDefinition("Kinetic Weapon"); ManifestDao manifestDao = new ManifestDao(config, databaseAccessor); ManifestItemCategoryDefinition actual = manifestDao.GetItemCategoryDefinition(kineticWeaponCategoryHash); Assert.AreEqual(expected.CategoryName, actual.CategoryName); }