This repository has been archived on 2021-09-07. You can view files and clone it, but cannot push or open issues or pull requests.

41 lines
662 B
Go
Raw Normal View History

2019-03-09 23:38:10 +03:00
package abstract_factory
import (
"testing"
)
func TestCarFactory(t *testing.T) {
carFactory, err := CreateVehicleFactory(CAR)
if err != nil {
t.Fatal(err)
}
sportCarVehicle, err := carFactory.NewVehicle(SPORT_CAR)
if err != nil {
t.Fatal(err)
}
sc, ok := sportCarVehicle.(Car)
if !ok {
t.Fatal("Struct assertion failed.")
}
}
func TestBusFactory(t *testing.T) {
busFactory, err := CreateVehicleFactory(BUS)
if err != nil {
t.Fatal(err)
}
cistyTourBusVehicle, err := busFactory.NewVehicle(CITY_TOUR_BUS)
if err != nil {
t.Fatal(err)
}
_, ok := cistyTourBusVehicle.(Bus)
if !ok {
t.Fatal("Struct assertion failed.")
}
}