示例#1
0
        public void Initialize()
        {
            CargoDAO cargoDao = new CargoDAO();

            cargo1      = CreateCargo();
            cargo2      = CreateCargo();
            cargo2.Type = "newtype";
            cargoDao.InsertCargo(cargo1);
            cargoDao.InsertCargo(cargo2);

            BaseDAO bas = new BaseDAO();

            newBase        = new Base();
            newBase.Planet = "Země";
            bas.InsertBase(newBase);

            PlayerDAO playerDao = new PlayerDAO();

            player = CreatePlayer();
            playerDao.InsertPlayer(player);

            SpaceShipDAO shipDao = new SpaceShipDAO();

            ship = CreateSpaceShip();
            shipDao.InsertSpaceShip(ship);
        }
示例#2
0
        public void GetCargosTest()
        {
            CargoDAO target = new CargoDAO();

            cargo = CreateCargo();
            target.InsertCargo(cargo);
            oldId      = cargo.CargoId;
            cargo.Type = "newType";
            target.InsertCargo(cargo);
            List <Cargo> cargos = target.GetCargos();

            Assert.IsNotNull(cargos);
        }
示例#3
0
        public void GetCargosByTypeTest()
        {
            CargoDAO target = new CargoDAO();

            cargo = CreateCargo();
            target.InsertCargo(cargo);
            oldId = cargo.CargoId;
            string type = RandomString(6);

            cargo.Type = type;
            target.InsertCargo(cargo);
            List <Cargo> cargos = target.GetCargosByType(type);

            Assert.IsTrue(cargos.Count == 1);
        }
示例#4
0
        public void InsertCargoTest()
        {
            CargoDAO target = new CargoDAO();

            cargo = CreateCargo();
            bool insert = target.InsertCargo(cargo);

            Assert.IsTrue(insert);
        }
示例#5
0
        public void TestInitialize()
        {
            cargo       = new Cargo();
            cargo.Price = 200;
            cargo.Type  = "nářadí";
            CargoDAO dao = new CargoDAO();

            dao.InsertCargo(cargo);
        }
示例#6
0
        public void RemoveCargoByIdTest()
        {
            CargoDAO target = new CargoDAO();

            cargo = CreateCargo();
            target.InsertCargo(cargo);
            bool remove = target.RemoveCargoById(cargo.CargoId);

            Assert.IsTrue(remove);
            cargo = null;
        }
示例#7
0
        public void GetCargoByIdTest()
        {
            CargoDAO target = new CargoDAO();

            cargo = CreateCargo();
            target.InsertCargo(cargo);
            Cargo newCargo = target.GetCargoById(cargo.CargoId);

            Assert.IsTrue(newCargo.CargoId == cargo.CargoId && newCargo.Type == cargo.Type &&
                          cargo.Price == cargo.Price);
        }
示例#8
0
        public JsonResult JsInsert(Cargo cargo)
        {
            var cargoDAO = new CargoDAO();

            cargoDAO.InsertCargo(cargo);
            var result = new
            {
                type    = "success",
                field   = "",
                message = "Registro adicionado com sucesso!",
                model   = cargo
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
示例#9
0
        public void UpdateCargoByIdTest()
        {
            CargoDAO target = new CargoDAO();

            cargo = CreateCargo();
            target.InsertCargo(cargo);
            cargo.Price = 500;
            string type = RandomString(6);

            cargo.Type = type;
            target.UpdateCargoById(cargo);
            Cargo newCargo = target.GetCargoById(cargo.CargoId);

            Assert.IsTrue(newCargo.CargoId == cargo.CargoId && newCargo.Type == type &&
                          cargo.Price == 500);
        }
示例#10
0
        public ActionResult Create(Cargo cargo)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var cargoDAO = new CargoDAO();

                    cargoDAO.InsertCargo(cargo);

                    return(RedirectToAction("Index"));
                }
                return(View());
            }
            catch
            {
                return(View());
            }
        }