func TestStrategyRender(t *testing.T) {
	const ilimit = 255
	if testing.Short() {
		t.Skip("Skipping test in short mode")
	}

	expectedPic := image.NewNRGBA(image.ZR)
	context := draw.NewMockDrawingContext(ilimit)
	context.Pic = expectedPic
	numerics := &MockNumerics{}

	renderer := SequenceRenderStrategy{
		numerics: numerics,
		context:  context,
	}
	actualPic, err := renderer.Render()

	if err != nil {
		t.Error("Unexpected error in render")
	}

	if actualPic != expectedPic {
		t.Error("Expected a certain picture to be returned but was:", actualPic)
	}

	if !numerics.TSequence {
		t.Error("Expected methods not called on numerics:", numerics)
	}

	if !context.TPicture {
		t.Error("Expected methods not called on context:", context)
	}
}
Ejemplo n.º 2
0
func TestImageSequence(t *testing.T) {
	const iterateLimit = 10
	context := draw.NewMockDrawingContext(iterateLimit)
	numerics := &MockNumerics{}
	ImageSequence(numerics, context)

	if false {
		t.Error("Since the mock context does not have a real image attached",
			"all this test really does is prove that the mechanism works without crashing out")
	}
}
Ejemplo n.º 3
0
func TestRenderSequenceRegion(t *testing.T) {
	const iterateLimit = 40
	mockSequence := &MockProxySequence{}
	mockRegion := &MockNumerics{
		MockSequence: mockSequence,
	}
	// Not inspecting contract re DrawingContext
	context := draw.NewMockDrawingContext(iterateLimit)
	RenderSequenceRegion(mockRegion, context)

	if !mockRegion.TRegionSequence {
		t.Error("Expected methods not called on mockRegion:", mockRegion)
	}

	sequenceOkay := mockSequence.TExtrinsically && mockSequence.TSequence
	if !sequenceOkay {
		t.Error("Expected methods not called on mockSequence:", mockSequence)
	}
}