• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang hsapi.NewHsAPI函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/eefret/hsapi.NewHsAPI函数的典型用法代码示例。如果您正苦于以下问题:Golang NewHsAPI函数的具体用法?Golang NewHsAPI怎么用?Golang NewHsAPI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewHsAPI函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestHs

func TestHs(t *testing.T) {
	api := hs.NewHsAPI("tntkXJyM7EmshBgQYsXtCHHEX8Izp1uHrN1jsnTpw7tNCxEZIN")
	api.Debug = true
	config := hs.NewInfo()
	resp := api.Info(config)
	assert.NotEmpty(t, resp, "Empty Response")
}
开发者ID:rmariuzzo,项目名称:hsapi,代码行数:7,代码来源:api_test.go


示例2: TestClass

func TestClass(t *testing.T) {
	api := hs.NewHsAPI("tntkXJyM7EmshBgQYsXtCHHEX8Izp1uHrN1jsnTpw7tNCxEZIN")
	api.Debug = true
	config := hs.NewCardsByClass(hs.Warlock)
	resp, err := api.CardsByClass(config)
	assert.NotEmpty(t, resp, "Empty Response")
	assert.NoError(t, err, "An error ocurred while testing Search")
	assert.NotEqual(t, 0, len(resp), "obtained no cards ")
	assert.Equal(t, resp[0].Type, hs.Enchantment.String(), "Wrong card fetched")
}
开发者ID:rmariuzzo,项目名称:hsapi,代码行数:10,代码来源:api_test.go


示例3: TestSet

func TestSet(t *testing.T) {
	api := hs.NewHsAPI("tntkXJyM7EmshBgQYsXtCHHEX8Izp1uHrN1jsnTpw7tNCxEZIN")
	api.Debug = true
	config := hs.NewCardsBySet(hs.TheGrandTournament)
	config.Collectible = true
	resp, err := api.CardsBySet(config)
	assert.NotEmpty(t, resp, "Empty Response")
	assert.NoError(t, err, "An error ocurred while testing Search")
	assert.NotEqual(t, 0, len(resp), "obtained no cards ")
	assert.Equal(t, resp[0].Type, hs.Spell.String(), "Wrong card fetched")
}
开发者ID:rmariuzzo,项目名称:hsapi,代码行数:11,代码来源:api_test.go


示例4: TestType

func TestType(t *testing.T) {
	api := hs.NewHsAPI("tntkXJyM7EmshBgQYsXtCHHEX8Izp1uHrN1jsnTpw7tNCxEZIN")
	api.Debug = true
	config := hs.NewCardsByType(hs.Weapon)
	config.Collectible = true
	resp, err := api.CardsByType(config)
	assert.NotEmpty(t, resp, "Empty Response")
	assert.NoError(t, err, "An error ocurred while testing Search")
	assert.NotEqual(t, 0, len(resp), "obtained no cards ")
	assert.Equal(t, resp[0].PlayerClass, hs.Paladin.String(), "Wrong card fetched")
}
开发者ID:rmariuzzo,项目名称:hsapi,代码行数:11,代码来源:api_test.go


示例5: TestRace

func TestRace(t *testing.T) {
	api := hs.NewHsAPI("tntkXJyM7EmshBgQYsXtCHHEX8Izp1uHrN1jsnTpw7tNCxEZIN")
	api.Debug = true
	config := hs.NewCardsByRace(hs.Dragon)
	config.Collectible = true
	resp, err := api.CardsByRace(config)
	assert.NotEmpty(t, resp, "Empty Response")
	assert.NoError(t, err, "An error ocurred while testing Search")
	assert.NotEqual(t, 0, len(resp), "obtained no cards ")
	assert.Equal(t, resp[0].CardID, "BRM_004", "Wrong card fetched")
}
开发者ID:rmariuzzo,项目名称:hsapi,代码行数:11,代码来源:api_test.go


示例6: TestQuality

func TestQuality(t *testing.T) {
	api := hs.NewHsAPI("tntkXJyM7EmshBgQYsXtCHHEX8Izp1uHrN1jsnTpw7tNCxEZIN")
	api.Debug = true
	config := hs.NewCardsByQuality(hs.Legendary)
	config.Collectible = true
	resp, err := api.CardsByQuality(config)
	assert.NotEmpty(t, resp, "Empty Response")
	assert.NoError(t, err, "An error ocurred while testing Search")
	assert.NotEqual(t, 0, len(resp), "obtained no cards ")
	assert.Equal(t, resp[0].Name, "Bloodmage Thalnos", "Wrong card fetched")
}
开发者ID:rmariuzzo,项目名称:hsapi,代码行数:11,代码来源:api_test.go


示例7: TestAllCards

func TestAllCards(t *testing.T) {
	api := hs.NewHsAPI("tntkXJyM7EmshBgQYsXtCHHEX8Izp1uHrN1jsnTpw7tNCxEZIN")
	api.Debug = true
	config := hs.NewAllCards()
	config.Collectible = true
	config.Attack = 5
	config.Durability = 5
	config.Cost = 5
	resp, err := api.AllCards(config)
	assert.NotEmpty(t, resp, "Empty Response")
	assert.NoError(t, err, "An error ocurred while testing allcards")
}
开发者ID:rmariuzzo,项目名称:hsapi,代码行数:12,代码来源:api_test.go


示例8: TestCardBacks

func TestCardBacks(t *testing.T) {
	api := hs.NewHsAPI("tntkXJyM7EmshBgQYsXtCHHEX8Izp1uHrN1jsnTpw7tNCxEZIN")
	api.Debug = true
	config := hs.NewCardBacks()
	config.Locale = hs.EsES
	resp, err := api.CardBacks(config)
	assert.NotEmpty(t, resp, "Empty Response")
	assert.NoError(t, err, "An error ocurred while testing CardBack")
	config.Locale = hs.EsES
	resp, err = api.CardBacks(config)
	assert.NotEmpty(t, resp, "Empty Response")
	assert.NoError(t, err, "An error ocurred while testing CardBack")
}
开发者ID:rmariuzzo,项目名称:hsapi,代码行数:13,代码来源:api_test.go


示例9: TestGetCard

func TestGetCard(t *testing.T) {
	api := hs.NewHsAPI("tntkXJyM7EmshBgQYsXtCHHEX8Izp1uHrN1jsnTpw7tNCxEZIN")
	api.Debug = true
	config := hs.NewGetCard("EX1_572")
	config.Collectible = true
	resp, err := api.GetCard(config)
	assert.NotEmpty(t, resp, "Empty Response")
	assert.NoError(t, err, "An error ocurred while instantiating hearthstoneApi")
	config.Collectible = false
	config.Name = "Ysera"
	config.Locale = hs.EsES
	config.Collectible = true
	resp, err = api.GetCard(config)
	assert.NotEmpty(t, resp, "Empty Response")
	assert.NoError(t, err, "An error ocurred while testing GetCard")
}
开发者ID:rmariuzzo,项目名称:hsapi,代码行数:16,代码来源:api_test.go


示例10: TestSearch

func TestSearch(t *testing.T) {
	api := hs.NewHsAPI("tntkXJyM7EmshBgQYsXtCHHEX8Izp1uHrN1jsnTpw7tNCxEZIN")
	api.Debug = true
	config := hs.NewCardSearch("tirion fordring")
	config.Collectible = true
	resp, err := api.Search(config)
	assert.NotEmpty(t, resp, "Empty Response")
	assert.NoError(t, err, "An error ocurred while testing Search")
	assert.Equal(t, 1, len(resp), "obtained more cards than expected")
	assert.Equal(t, resp[0].Rarity, hs.Legendary.String(), "Wrong card fetched")
	config = hs.NewCardSearch("alexstrasza")
	config.Collectible = true
	resp, err = api.Search(config)
	assert.NotEmpty(t, resp, "Empty Response")
	assert.NoError(t, err, "An error ocurred while testing Search")
	assert.Equal(t, 2, len(resp), "obtained more cards than expected")
	assert.Equal(t, resp[0].CardID, "AT_071", "Wrong cards fetched")
	assert.Equal(t, resp[1].CardID, "EX1_561", "Wrong cards fetched")
}
开发者ID:rmariuzzo,项目名称:hsapi,代码行数:19,代码来源:api_test.go


示例11: TestImgCard

func TestImgCard(t *testing.T) {
	api := hs.NewHsAPI("tntkXJyM7EmshBgQYsXtCHHEX8Izp1uHrN1jsnTpw7tNCxEZIN")
	api.Debug = true
	config := hs.NewCardImage("EX1_383")
	config.Gold = true
	resp, err := api.CardImage(config)
	assert.Equal(t, hs.GIF.String(), resp.Extension.String(), "Wrong extension")
	assert.NoError(t, err, "An error ocurred while testing CardImage")

	if _, err := os.Stat("test_images"); os.IsNotExist(err) {
		os.Mkdir("."+string(filepath.Separator)+"test_images", 0777)
	}
	f, err := os.Create("test_images/Tirion_Fordring.gif")
	assert.NoError(t, err, "An error ocurred while testing CardImage")
	defer f.Close()
	f.Write(resp.Image)
	_, existsErr := os.Stat("test_images/Tirion_Fordring.gif")
	assert.True(t, !os.IsNotExist(existsErr), "File couldnt be created")
	assert.NoError(t, os.Remove("test_images/Tirion_Fordring.gif"), "couldn't remove the file")
}
开发者ID:rmariuzzo,项目名称:hsapi,代码行数:20,代码来源:api_test.go


示例12: TestSoundCard

func TestSoundCard(t *testing.T) {
	api := hs.NewHsAPI("tntkXJyM7EmshBgQYsXtCHHEX8Izp1uHrN1jsnTpw7tNCxEZIN")
	api.Debug = true
	config := hs.NewCardSound("EX1_383", hs.PLAY)
	config.Locale = hs.EsES
	config.Extension = hs.MP3
	resp, err := api.CardSound(config)
	assert.Equal(t, hs.MP3.String(), resp.Extension.String(), "Wrong extension")
	assert.NoError(t, err, "An error ocurred while testing CardImage")
	fmt.Printf("%q\n", resp)
	if _, err := os.Stat("test_sounds"); os.IsNotExist(err) {
		os.Mkdir("."+string(filepath.Separator)+"test_sounds", 0777)
	}
	f, err := os.Create("test_sounds/Tirion_Fordring_Play.mp3")
	assert.NoError(t, err, "An error ocurred while testing CardImage")
	defer f.Close()
	f.Write(resp.Sound)
	_, existsErr := os.Stat("test_sounds/Tirion_Fordring_Play.mp3")
	assert.True(t, !os.IsNotExist(existsErr), "File couldnt be created")
	assert.NoError(t, os.Remove("test_sounds/Tirion_Fordring_Play.mp3"), "couldn't remove the file")
}
开发者ID:eefret,项目名称:hsapi,代码行数:21,代码来源:api_test.go


示例13: TestErrors

func TestErrors(t *testing.T) {
	api := hs.NewHsAPI("tntkXJyM7EmshBgQYsXtCHHIzp1jsnTpw7tNCxEZIN")
	api.Debug = true

	//Type
	config := hs.NewCardsByType(hs.Weapon)
	config.Collectible = true
	resp, err := api.CardsByType(config)
	assert.Empty(t, resp, "Empty Response")
	assert.Error(t, err, "An error ocurred while testing Errors")

	//Race
	config1 := hs.NewCardsByRace(hs.Dragon)
	config1.Collectible = true
	resp1, err1 := api.CardsByRace(config1)
	assert.Empty(t, resp1, "Empty Response")
	assert.Error(t, err1, "An error ocurred while testing Errors")

	//Quality
	config2 := hs.NewCardsByQuality(hs.Legendary)
	config2.Collectible = true
	resp2, err2 := api.CardsByQuality(config2)
	assert.Empty(t, resp2, "Empty Response")
	assert.Error(t, err2, "An error ocurred while testing Errors")

	//Ifo
	config3 := hs.NewInfo()
	config3.Locale = hs.EsES
	resp3 := api.Info(config3)
	assert.NotEmpty(t, resp3, "Empty Response")

	//GetCard
	config4 := hs.NewGetCard("EX1_572")
	config4.Collectible = true
	resp4, err4 := api.GetCard(config4)
	assert.Empty(t, resp4, "Empty Response")
	assert.Error(t, err4, "An error ocurred while testing Errors")

	//AllCards
	config5 := hs.NewAllCards()
	config5.Collectible = true
	config5.Attack = 5
	config5.Durability = 5
	config5.Cost = 5
	resp5, err5 := api.AllCards(config5)
	assert.NotEmpty(t, resp5, "Empty Response")
	assert.Error(t, err5, "An error ocurred while testing Errors")

	//Cardbacks
	config6 := hs.NewCardBacks()
	config6.Locale = hs.EsES
	resp6, err6 := api.CardBacks(config6)
	assert.Empty(t, resp6, "Empty Response")
	assert.Error(t, err6, "An error ocurred while testing Errors")

	//CardSearch
	config7 := hs.NewCardSearch("tirion fordring")
	config7.Collectible = true
	resp7, err7 := api.Search(config7)
	assert.Empty(t, resp7, "Empty Response")
	assert.Error(t, err7, "An error ocurred while testing Errors")

	//By Set
	config8 := hs.NewCardsBySet(hs.TheGrandTournament)
	config8.Collectible = true
	resp8, err8 := api.CardsBySet(config8)
	assert.Empty(t, resp8, "Empty Response")
	assert.Error(t, err8, "An error ocurred while testing Errors")

	//By Class
	config9 := hs.NewCardsByClass(hs.Warlock)
	resp9, err9 := api.CardsByClass(config9)
	assert.Empty(t, resp9, "Empty Response")
	assert.Error(t, err9, "An error ocurred while testing Errors")

	//By Faction
	config10 := hs.NewCardsByFaction(hs.Horde)
	config10.Collectible = true
	resp10, err10 := api.CardsByFaction(config10)
	assert.Empty(t, resp10, "Empty Response")
	assert.Error(t, err10, "An error ocurred while testing Errors")

	//CardImg
	config11 := hs.NewCardImage("EX1383")
	config11.Gold = true
	_, err11 := api.CardImage(config11)
	assert.Error(t, err11, "An error ocurred while testing Errors")
}
开发者ID:rmariuzzo,项目名称:hsapi,代码行数:88,代码来源:api_test.go



注:本文中的github.com/eefret/hsapi.NewHsAPI函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang audit.Audit类代码示例发布时间:2022-05-23
下一篇:
Golang finder.SbpBfsFinder类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap