public void Factory_Method_Test()
        {
            var factory       = new Factory();
            var maisonFactory = new MaisonFactory();
            var officeFactory = new OfficeFactory();

            var door = factory.MakeDoor();
            var wall = factory.MakeWall();

            var maisonDoor = maisonFactory.MakeDoor();
            var maisonWall = maisonFactory.MakeWall();

            var officeDoor = officeFactory.MakeDoor();
            var officeWall = officeFactory.MakeWall();

            Assert.IsInstanceOfType(door, typeof(Door));
            Assert.IsInstanceOfType(wall, typeof(Wall));

            Assert.IsInstanceOfType(maisonDoor, typeof(MaisonDoor));
            Assert.IsTrue(maisonDoor.GetType().BaseType == typeof(Door));

            Assert.IsInstanceOfType(maisonWall, typeof(MaisonWall));
            Assert.IsTrue(maisonWall.GetType().BaseType == typeof(Wall));

            Assert.IsInstanceOfType(officeDoor, typeof(OfficeDoor));
            Assert.IsTrue(officeDoor.GetType().BaseType == typeof(Door));

            Assert.IsInstanceOfType(officeWall, typeof(OfficeWall));
            Assert.IsTrue(officeWall.GetType().BaseType == typeof(Wall));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            MouseFactory mouseFactory = null;

            Console.WriteLine("Enter the number corresponding to the type of mouse you want:\n 1 - Gamer\n 2 - Office");
            string typeMouseEnter = Console.ReadLine();

            switch (typeMouseEnter)
            {
            case "1":
                mouseFactory = new GamerFactory(8000, "USB");
                break;

            case "2":
                mouseFactory = new OfficeFactory(1000, "Wireless");
                break;

            default:
                Console.WriteLine("Enter a valid number.");
                break;
            }
            Mouse mouse = mouseFactory.SearchMouse();

            Console.WriteLine("\n These are the details of your mouse: ");
            Console.WriteLine($"Mouse Type: {mouse.MouseType}\nDPI: {mouse.Dpi}\nConnection: {mouse.Connection} ");
        }
Exemplo n.º 3
0
 public OfficeFactoryTests()
 {
     _mocker = new AutoMocker();
     _sut    = _mocker.CreateInstance <OfficeFactory>();
 }