public void OperatorNotEqualsTest() { var chatLink = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 5, Upgrade1Id = 76, Upgrade2Id = 99 }; var chatLink2 = new ItemChatLink { ItemId = 12, Quantity = 2, SkinId = 5, Upgrade1Id = 76, Upgrade2Id = 99 }; var chatLink3 = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 7, Upgrade1Id = 76, Upgrade2Id = 99 }; var chatLink4 = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 5, Upgrade1Id = 99, Upgrade2Id = 99 }; var chatLink5 = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 5, Upgrade1Id = 76, Upgrade2Id = 10 }; Assert.True(chatLink != chatLink2); Assert.True(chatLink != chatLink3); Assert.True(chatLink != chatLink4); Assert.True(chatLink != chatLink5); Assert.True(chatLink2 != chatLink3); Assert.True(chatLink2 != chatLink4); Assert.True(chatLink2 != chatLink5); Assert.True(chatLink3 != chatLink4); Assert.True(chatLink3 != chatLink5); Assert.True(chatLink4 != chatLink5); }
public void NotEqualsTest() { var chatLink = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 5, Upgrade1Id = 76, Upgrade2Id = 99 }; var chatLink2 = new ItemChatLink { ItemId = 12, Quantity = 2, SkinId = 5, Upgrade1Id = 76, Upgrade2Id = 99 }; var chatLink3 = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 7, Upgrade1Id = 76, Upgrade2Id = 99 }; var chatLink4 = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 5, Upgrade1Id = 99, Upgrade2Id = 99 }; var chatLink5 = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 5, Upgrade1Id = 76, Upgrade2Id = 10 }; Assert.False(chatLink.Equals(chatLink2)); Assert.False(chatLink.Equals(chatLink3)); Assert.False(chatLink.Equals(chatLink4)); Assert.False(chatLink.Equals(chatLink5)); Assert.False(chatLink2.Equals(chatLink3)); Assert.False(chatLink2.Equals(chatLink4)); Assert.False(chatLink2.Equals(chatLink5)); Assert.False(chatLink3.Equals(chatLink4)); Assert.False(chatLink3.Equals(chatLink5)); Assert.False(chatLink4.Equals(chatLink5)); Assert.False(chatLink.Equals(null)); Assert.False(chatLink2.Equals(null)); Assert.False(chatLink3.Equals(null)); Assert.False(chatLink4.Equals(null)); Assert.False(chatLink5.Equals(null)); }
public void HashCodeNotEqualsTest() { var chatLink = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 5, Upgrade1Id = 76, Upgrade2Id = 99 }; var chatLink2 = new ItemChatLink { ItemId = 12, Quantity = 2, SkinId = 5, Upgrade1Id = 76, Upgrade2Id = 99 }; var chatLink3 = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 7, Upgrade1Id = 76, Upgrade2Id = 99 }; var chatLink4 = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 5, Upgrade1Id = 99, Upgrade2Id = 99 }; var chatLink5 = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 5, Upgrade1Id = 76, Upgrade2Id = 10 }; Assert.NotEqual(chatLink.GetHashCode(), chatLink2.GetHashCode()); Assert.NotEqual(chatLink.GetHashCode(), chatLink3.GetHashCode()); Assert.NotEqual(chatLink.GetHashCode(), chatLink4.GetHashCode()); Assert.NotEqual(chatLink.GetHashCode(), chatLink5.GetHashCode()); Assert.NotEqual(chatLink2.GetHashCode(), chatLink3.GetHashCode()); Assert.NotEqual(chatLink2.GetHashCode(), chatLink4.GetHashCode()); Assert.NotEqual(chatLink2.GetHashCode(), chatLink5.GetHashCode()); Assert.NotEqual(chatLink3.GetHashCode(), chatLink4.GetHashCode()); Assert.NotEqual(chatLink3.GetHashCode(), chatLink5.GetHashCode()); Assert.NotEqual(chatLink4.GetHashCode(), chatLink5.GetHashCode()); }
public void EqualsTest() { var chatLink = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 5, Upgrade1Id = 76, Upgrade2Id = 99 }; var chatLink2 = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 5, Upgrade1Id = 76, Upgrade2Id = 99 }; Assert.True(chatLink.Equals((object)chatLink2)); }
public void HashCodeEqualsTest() { var chatLink = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 5, Upgrade1Id = 76, Upgrade2Id = 99 }; var chatLink2 = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 5, Upgrade1Id = 76, Upgrade2Id = 99 }; Assert.Equal(chatLink.GetHashCode(), chatLink2.GetHashCode()); }
public void OperatorEqualsTest() { var chatLink = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 5, Upgrade1Id = 76, Upgrade2Id = 99 }; var chatLink2 = new ItemChatLink { ItemId = 12, Quantity = 1, SkinId = 5, Upgrade1Id = 76, Upgrade2Id = 99 }; Assert.True(chatLink == chatLink2); }
/// <summary>Gets an item chat link for this item.</summary> /// <returns>The <see cref="ChatLink"/>.</returns> public virtual ChatLink GetItemChatLink() { ItemChatLink chatLink; var item = this.Item; if (item == null) { chatLink = new ItemChatLink { ItemId = this.ItemId }; } else { chatLink = (ItemChatLink)item.GetItemChatLink(); } chatLink.Quantity = this.Count; return(chatLink); }
public void ItemChatLinkObjectTest(string chatLink, ItemChatLink expected) => this.AssertChatLinkObject(chatLink, expected);
public void ItemChatLinkStringTest(string expected, ItemChatLink chatLinkObject) => this.AssertChatLinkString(expected, chatLinkObject);
partial void Merge(Item entity, ItemDTO dto, object state) { ItemChatLink chatLink = new ItemChatLink { Quantity = 1 }; int itemId; if (int.TryParse(dto.ItemId, out itemId)) { entity.ItemId = itemId; } entity.Name = dto.Name; entity.Description = dto.Description; int level; if (int.TryParse(dto.Level, out level)) { entity.Level = level; } entity.Rarity = this.itemRarityConverter.Convert(dto.Rarity, dto); int vendorValue; if (int.TryParse(dto.VendorValue, out vendorValue)) { entity.VendorValue = vendorValue; } var gameTypes = dto.GameTypes; if (gameTypes != null) { entity.GameTypes = this.gameTypesConverter.Convert(gameTypes, dto); } var flags = dto.Flags; if (flags != null) { entity.Flags = this.itemFlagsConverter.Convert(flags, dto); } var restrictions = dto.Restrictions; if (restrictions != null) { entity.Restrictions = this.itemRestrictionsConverter.Convert(restrictions, dto); } int iconFileId; if (int.TryParse(dto.IconFileId, out iconFileId)) { entity.IconFileId = iconFileId; } // Set the icon file signature entity.IconFileSignature = dto.IconFileSignature; // Set the icon file URL const string IconUrlTemplate = @"https://render.guildwars2.com/file/{0}/{1}.{2}"; var iconUrl = string.Format(IconUrlTemplate, dto.IconFileSignature, dto.IconFileId, "png"); entity.IconFileUrl = new Uri(iconUrl, UriKind.Absolute); var skinnable = entity as ISkinnable; if (skinnable != null) { int defaultSkinId; if (int.TryParse(dto.DefaultSkin, out defaultSkinId)) { skinnable.DefaultSkinId = defaultSkinId; chatLink.SkinId = defaultSkinId; } } var upgrade = entity as IUpgradable; if (upgrade != null) { chatLink.SuffixItemId = upgrade.SuffixItemId; chatLink.SecondarySuffixItemId = upgrade.SecondarySuffixItemId; } entity.ChatLink = chatLink.ToString(); }
partial void Merge(Item entity, ItemDTO dto, object state) { ItemChatLink chatLink = new ItemChatLink { Quantity = 1 }; int itemId; if (int.TryParse(dto.ItemId, out itemId)) { entity.ItemId = itemId; } entity.Name = dto.Name; entity.Description = dto.Description; int level; if (int.TryParse(dto.Level, out level)) { entity.Level = level; } entity.Rarity = this.itemRarityConverter.Convert(dto.Rarity, dto); int vendorValue; if (int.TryParse(dto.VendorValue, out vendorValue)) { entity.VendorValue = vendorValue; } var gameTypes = dto.GameTypes; if (gameTypes != null) { entity.GameTypes = this.gameTypesConverter.Convert(gameTypes, dto); } var flags = dto.Flags; if (flags != null) { entity.Flags = this.itemFlagsConverter.Convert(flags, dto); } var restrictions = dto.Restrictions; if (restrictions != null) { entity.Restrictions = this.itemRestrictionsConverter.Convert(restrictions, dto); } int iconFileId; if (int.TryParse(dto.IconFileId, out iconFileId)) { entity.IconFileId = iconFileId; } // Set the icon file signature entity.IconFileSignature = dto.IconFileSignature; // Set the icon file URL const string IconUrlTemplate = @"https://render.guildwars2.com/file/{0}/{1}.{2}"; var iconUrl = string.Format(IconUrlTemplate, dto.IconFileSignature, dto.IconFileId, "png"); entity.IconFileUrl = new Uri(iconUrl, UriKind.Absolute); var skinnable = entity as ISkinnable; if (skinnable != null) { int defaultSkinId; if (int.TryParse(dto.DefaultSkin, out defaultSkinId)) { skinnable.DefaultSkinId = defaultSkinId; chatLink.SkinId = defaultSkinId; } } var upgrade = entity as IUpgradable; if (upgrade != null) { chatLink.SuffixItemId = upgrade.SuffixItemId; chatLink.SecondarySuffixItemId = upgrade.SecondarySuffixItemId; } entity.ChatLink = chatLink.ToString(); }