當前位置: 首頁>>代碼示例>>Golang>>正文


Golang rtb.BidRequest類代碼示例

本文整理匯總了Golang中github.com/evandigby/rtb.BidRequest的典型用法代碼示例。如果您正苦於以下問題:Golang BidRequest類的具體用法?Golang BidRequest怎麽用?Golang BidRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了BidRequest類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestBiddingPacerFalse

// TestBiddingPacerFalse tests that the bidder will not bid when the pacer replys false to CanBid
// Expected result is nil
func TestBiddingPacerFalse(t *testing.T) {
	r := new(rtb.BidRequest)
	r.Imp = make([]rtb.Imp, 1)
	r.Imp[0] = rtb.Imp{}

	pacer := mocks.NewMockPacer(map[int64]bool{100: false})

	campaign := mocks.NewMockCampaign(100, rtb.CpmToMicroCents(0.25), rtb.DollarsToMicroCents(1), nil)

	campaignsReturnedByTargeting := []rtb.Campaign{campaign}

	cp := mocks.NewMockCampaignProvider(campaignsReturnedByTargeting, map[int64]int64{100: rtb.DollarsToMicroCents(1)}, map[int64]error{100: nil}, nil)

	b := NewBidRequestBidder(r, cp, pacer, time.Now().UTC())

	response, _, err := b.Bid()

	if err != nil {
		t.Fail()
	}

	if response != nil {
		t.FailNow()
	}
}
開發者ID:mdominoni,項目名稱:rtb,代碼行數:27,代碼來源:bidrequestbidder_test.go

示例2: TestBiddingMatchedTargetCorrectAmount

// TestBiddingMatchedTargetCorrectAmount tests that the bidder bids the correct amount
// Expected result is a bid response that is populated by a single bid with the correct bid amount
func TestBiddingMatchedTargetCorrectAmount(t *testing.T) {
	r := new(rtb.BidRequest)
	r.Imp = make([]rtb.Imp, 1)
	r.Imp[0] = rtb.Imp{}

	pacer := mocks.NewMockPacer(map[int64]bool{100: true})

	campaign := mocks.NewMockCampaign(100, rtb.CpmToMicroCents(0.32), rtb.DollarsToMicroCents(1), nil)

	campaignsReturnedByTargeting := []rtb.Campaign{campaign}

	cp := mocks.NewMockCampaignProvider(campaignsReturnedByTargeting, map[int64]int64{100: rtb.DollarsToMicroCents(1)}, map[int64]error{100: nil}, nil)

	b := NewBidRequestBidder(r, cp, pacer, time.Now().UTC())

	expectedBidAmount := float64(0.32)

	response, _, err := b.Bid()

	if err != nil {
		t.Fail()
	}

	if response == nil {
		t.FailNow()
	}

	if response.Seatbid == nil {
		t.FailNow()
	}

	if len(response.Seatbid) != 1 {
		t.Fail()
	}

	if response.Seatbid[0].Bid == nil {
		t.FailNow()
	}

	if len(response.Seatbid[0].Bid) != 1 {
		t.FailNow()
	}

	if response.Seatbid[0].Bid[0].Cid != strconv.FormatInt(campaignsReturnedByTargeting[0].Id(), 10) {
		t.Fail()
	}

	if response.Seatbid[0].Bid[0].Price != expectedBidAmount {
		t.Fail()
	}
}
開發者ID:mdominoni,項目名稱:rtb,代碼行數:53,代碼來源:bidrequestbidder_test.go

示例3: TestBiddingFirstCampaignOutOfFunds

// TestBiddingMatchedTarget tests that the bidder will bid on the first campaign returned by the bidder that has a remaining daily budget
// Expected result is a bid response that is populated by a single bid with a campaign ID matching the first campaigned returned by the provider
func TestBiddingFirstCampaignOutOfFunds(t *testing.T) {
	r := new(rtb.BidRequest)
	r.Imp = make([]rtb.Imp, 1)
	r.Imp[0] = rtb.Imp{}

	pacer := mocks.NewMockPacer(map[int64]bool{100: true, 101: true})

	campaign1 := mocks.NewMockCampaign(100, rtb.CpmToMicroCents(0.25), rtb.DollarsToMicroCents(1), nil)
	campaign2 := mocks.NewMockCampaign(101, rtb.CpmToMicroCents(0.25), rtb.DollarsToMicroCents(1), nil)

	campaignsReturnedByTargeting := []rtb.Campaign{campaign1, campaign2}

	cp := mocks.NewMockCampaignProvider(campaignsReturnedByTargeting, map[int64]int64{100: rtb.DollarsToMicroCents(1), 101: rtb.DollarsToMicroCents(1)}, map[int64]error{100: rtb.NewTransactionError("test", true), 101: nil}, nil)

	b := NewBidRequestBidder(r, cp, pacer, time.Now().UTC())

	response, _, err := b.Bid()

	if err != nil {
		t.Fail()
	}

	if response == nil {
		t.FailNow()
	}

	if response.Seatbid == nil {
		t.FailNow()
	}

	if len(response.Seatbid) != 1 {
		t.Fail()
	}

	if response.Seatbid[0].Bid == nil {
		t.FailNow()
	}

	if len(response.Seatbid[0].Bid) != 1 {
		t.FailNow()
	}

	if response.Seatbid[0].Bid[0].Cid != strconv.FormatInt(campaignsReturnedByTargeting[1].Id(), 10) {
		t.Fail()
	}
}
開發者ID:mdominoni,項目名稱:rtb,代碼行數:48,代碼來源:bidrequestbidder_test.go


注:本文中的github.com/evandigby/rtb.BidRequest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。