Test Factory Method Source

Unit tests for the Factory Method Design Pattern implementation.

This file contains GoogleTest cases to validate the behavior of the Factory Method Design Pattern implementation. It tests different concrete creators and their respective products to ensure the correct functionality of the factory method.

Functions

TEST(FactoryMethodTest, ConcreteProductA)

Tests the creation and usage of ConcreteProductA through ConcreteCreatorA.

This test case verifies that the ConcreteCreatorA creates a product of type ConcreteProductA and that its use() method returns the expected string.

TEST(FactoryMethodTest, ConcreteProductB)

Tests the creation and usage of ConcreteProductB through ConcreteCreatorB.

This test case verifies that the ConcreteCreatorB creates a product of type ConcreteProductB and that its use() method returns the expected string.

TEST(FactoryMethodTest, FactoryWithBaseCreator)

Tests the Factory Method using base class references.

This test case demonstrates polymorphic behavior by using base class references for both creators and products. It ensures that ConcreteCreatorA and ConcreteCreatorB correctly create their respective products, and that the products behave as expected.