public void TestCriarBarroco()
        {
            MovelAbstractFactory factory = MovelAbstractFactory.CriarInstancia(EstiloEnum.Barroco);
            Movel mesa = factory.CriarMovel(MovelEnum.Mesa);

            Assert.IsType <MesaBarroca>(mesa);
        }
        public void TestCriarFuturista()
        {
            MovelAbstractFactory factory = MovelAbstractFactory.CriarInstancia(EstiloEnum.Futurista);
            Movel cadeira = factory.CriarMovel(MovelEnum.Cadeira);

            Assert.IsType(typeof(Cadeira), cadeira);
            Movel mesa = factory.CriarMovel(MovelEnum.Mesa);

            Assert.IsType(typeof(MesaFuturista), mesa);
        }
        public void TestCriarSteampunk()
        {
            MovelAbstractFactory factory = MovelAbstractFactory.CriarInstancia(EstiloEnum.Steampunk);
            Movel cadeira = factory.CriarMovel(MovelEnum.Cadeira);

            Assert.IsType <CadeiraSteampunk>(cadeira);
            Movel mesa = factory.CriarMovel(MovelEnum.Mesa);

            Assert.IsType <MesaSteampunk>(mesa);
        }
示例#4
0
        public IActionResult CriarMovel(int CasaId)
        {
            Casa   casa     = context.Casas.Find(CasaId);
            string MovelStr = Request.Form["CasaCriarId"].ToString();
            int    MovelID  = 0;

            if (int.TryParse(MovelStr, out MovelID))
            {
                MovelEnum movelEnum
                    = (MovelEnum)Enum.ToObject(typeof(MovelEnum), MovelID);
                var   factory = MovelAbstractFactory.CriarInstancia(casa.Estilo);
                Movel movel   = factory.CriarMovel(movelEnum);
                casa.Moveis.Add(movel);
                context.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }