awesome-patterns/go_design_pattern_book/creational/builder/main_test.go

25 lines
608 B
Go
Raw Normal View History

2018-01-10 14:42:52 +03:00
package main
import (
"testing"
)
func TestBuilderPatter(t *testing.T) {
manufacturingComplex := ManufacturingDirector{}
carBuilder := &CarBuilder{}
manufacturingComplex.SetBuilder(carBuilder)
manufacturingComplex.Construct()
car := carBuilder.GetVehicle()
if car.Wheels != 4 {
t.Errorf("number of wheels in car should be 4, it is %d", car.Seats)
}
bikeBuilder := &BikeBuilder{}
manufacturingComplex.SetBuilder(bikeBuilder)
manufacturingComplex.Construct()
bike := bikeBuilder.GetVehicle()
if bike.Wheels != 2 {
t.Errorf("number of wheels on bike should be 2, it is %d", bike.Seats)
}
}