Ejemplo n.º 1
0
        public void Type_Delete()
        {
            TypeController controller = new TypeController();
            var            result     = controller.Delete(TestId) as JsonResult;

            Assert.IsNotNull(result);
            Assert.AreEqual("ListItem deleted successfully", result.Data);
        }
Ejemplo n.º 2
0
        public void DeleteCaseExistsType()
        {
            var typeLogicMock = new Mock <ITypeLogic>(MockBehavior.Strict);

            typeLogicMock.Setup(m => m.Remove(oneType));
            typeLogicMock.Setup(m => m.Get(oneType.Id)).Returns(oneType);
            var typeController = new TypeController(typeLogicMock.Object);

            var result   = typeController.Delete(oneType.Id);
            var okResult = result as ObjectResult;

            typeLogicMock.VerifyAll();

            Assert.AreEqual(okResult.StatusCode, 200);
        }
        public void Delete()
        {
            //Arrange
            Type model = new Type()
            {
                Description = "test",
                Status      = "test"
            };

            //Act
            var result = (RedirectToRouteResult)controllerWEB.Delete(model);

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("Index", result.RouteValues["action"]);
        }
Ejemplo n.º 4
0
        public void DeleteCaseErrorInDB()
        {
            var typeLogicMock = new Mock <ITypeLogic>(MockBehavior.Strict);

            typeLogicMock.Setup(m => m.Remove(oneType)).Throws(
                new DataAccessException("Error: Entity could not be removed from DB"));
            typeLogicMock.Setup(m => m.Get(oneType.Id)).Returns(oneType);
            var typeController = new TypeController(typeLogicMock.Object);

            var result   = typeController.Delete(oneType.Id);
            var okResult = result as ObjectResult;
            var value    = okResult.Value;

            typeLogicMock.VerifyAll();

            Assert.AreEqual(value, "Error: Entity could not be removed from DB");
            Assert.AreEqual(okResult.StatusCode, 500);
        }
Ejemplo n.º 5
0
        public void DeleteCaseNotExistsType()
        {
            var typeLogicMock = new Mock <ITypeLogic>(MockBehavior.Strict);

            typeLogicMock.Setup(m => m.Remove(oneType)).Throws(
                new BusinessLogicException("Error: Type to delete doesn't exist"));
            typeLogicMock.Setup(m => m.Get(oneType.Id)).Returns(oneType);
            var typeController = new TypeController(typeLogicMock.Object);

            var result   = typeController.Delete(oneType.Id);
            var okResult = result as ObjectResult;
            var value    = okResult.Value;

            typeLogicMock.VerifyAll();

            Assert.AreEqual(value, "Error: Type to delete doesn't exist");
            Assert.AreEqual(okResult.StatusCode, 404);
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            string connectionString = "Host=localhost;Username=postgres;Password=p;Database=CityTransport";

            int table  = 0;
            int action = 0;

            do
            {
                table = FirstMenu();
                if (table == 0)
                {
                    return;
                }

                BaseController controller = null;

                switch (table)
                {
                case 1:
                    action     = SecondMenu("Garage");
                    controller = new GarageController(connectionString);
                    break;

                case 2:
                    action     = SecondMenu("Route");
                    controller = new RouteController(connectionString);
                    break;

                case 3:
                    action     = SecondMenu("Stop");
                    controller = new StopController(connectionString);
                    break;

                case 4:
                    action     = SecondMenu("Transport");
                    controller = new TransportController(connectionString);
                    break;

                case 5:
                    action     = SecondMenu("Type");
                    controller = new TypeController(connectionString);
                    break;
                }


                switch (action)
                {
                case 1:
                    controller.Create();
                    break;

                case 2:
                    controller.Read();
                    break;

                case 3:
                    controller.Update();
                    break;

                case 4:
                    controller.Delete();
                    break;

                case 5:
                    controller.Find();
                    break;

                case 6:
                    controller.Generate();
                    break;
                }
            } while (true);
        }