Пример #1
0
        public void AddCar()
        {
            Console.WriteLine("Podaj numer klienta :");
            string textOwnerId = Console.ReadLine();

            Console.WriteLine("Podaj markę :");
            string mark = Console.ReadLine();

            Console.WriteLine("Podaj numer model :");
            string model = Console.ReadLine();

            Console.WriteLine("Podaj numer numer rejestracyjny :");
            string registration = Console.ReadLine();

            try
            {
                int ownerId       = Int32.Parse(textOwnerId);
                var carController = new CarController();
                carController.Add(ownerId, mark, model, registration);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
        }
        public async Task Add_WhenACarIsAddedWithAllRequiredData_ReturnsCreatedStatusCode()
        {
            CarDto newCar = new CarDto
            {
                Make          = "Toyota",
                Model         = "Yaris",
                BodyType      = "Hatchback",
                Engine        = "500CC",
                Wheels        = 4,
                Doors         = 3,
                VehicleTypeID = _vehicleType.VehicleTypeID
            };
            Car expectedResult = new Car
            {
                Make          = "Toyota",
                Model         = "Yaris",
                BodyType      = "Hatchback",
                Engine        = "500CC",
                Wheels        = 4,
                Doors         = 3,
                VehicleTypeID = _vehicleType.VehicleTypeID
            };

            _carService.Setup(cs => cs.AddCar(newCar)).Returns(Task.FromResult(expectedResult));
            CarController controller = new CarController(_carService.Object, _vehicleTypeService.Object);

            ActionResult result        = (await controller.Add(newCar)).Result;
            var          createdResult = result as ObjectResult;

            Assert.IsNotNull(createdResult);
            Assert.AreEqual(201, createdResult.StatusCode);
            Assert.That(createdResult.Value, Is.EqualTo(expectedResult));
        }
Пример #3
0
        static void Main(string[] args)
        {
            var carController          = new CarController();
            var detailController       = new DetailController();
            var manufacturerController = new ManufacturerCollection();
            var manufacturerService    = new ManufacturerService();

            //var allDetailsController = detailController.GetAll();
            //detailController.Add(null);
            //detailController.Delete(24);
            //var fifthDetail = detailController.GetById(9);
            //detailController.Update(null);

            //var allCarViewModels = carController.GetAll();
            carController.Add(null);
            //carController.Delete(6);
            //var secondCar = carController.GetCarById(1);
            //carController.Update(null);

            //var allManuf =  manufacturerController.GetAll();

            //var mostExpensiveCar = manufacturerService.GetMostExpensive();

            Console.ReadKey();
        }
        public async Task Add_CarAddedWithoutAllRequiredData_ReturnsBadRequestStatusCode()
        {
            CarDto incompleteNewCar = new CarDto
            {
                Model         = "Yaris",
                BodyType      = "Hatchback",
                Engine        = "500CC",
                Wheels        = 4,
                Doors         = 3,
                VehicleTypeID = _vehicleType.VehicleTypeID
            };
            CarController controller = new CarController(_carService.Object, _vehicleTypeService.Object);

            var result = await controller.Add(incompleteNewCar);

            var code = result.Result as StatusCodeResult;

            Assert.IsNotNull(code);
            Assert.That(code.StatusCode, Is.EqualTo(500));
        }
Пример #5
0
        public void Can_Add_Car()
        {
            CarAddApiModel car1AddApiModel = new CarAddApiModel
            {
                Author         = "Author",
                ApiUser        = "******",
                Brand          = "Ford",
                Model          = "Galaxy",
                MobileNumber   = "+375337654321",
                CarDescription = new CarDescription
                {
                    Color             = "blue",
                    FuelType          = "gasoline",
                    EngineСapacity    = 2.0,
                    YearOfManufacture = 2005
                },
                Price = 7000
            };
            Car resultCar = null;

            _mockRepository.Setup(r => r.AddCarAsync(It.IsAny <Car>())).Callback <Car>(c => resultCar = c);

            IActionResult result = _carController.Add(car1AddApiModel).Result;

            Assert.IsType <CreatedAtRouteResult>(result);
            Assert.Equal(car1AddApiModel.Author, resultCar.Author);
            Assert.Equal(_testUser, resultCar.ApiUser);
            Assert.Equal(car1AddApiModel.Brand, resultCar.Brand);
            Assert.Equal(car1AddApiModel.Model, resultCar.Model);
            Assert.Equal(car1AddApiModel.MobileNumber, resultCar.MobileNumber);
            Assert.Equal(car1AddApiModel.Price, resultCar.Price);
            Assert.Equal(car1AddApiModel.CarDescription.Color, resultCar.CarDescription.Color);
            Assert.Equal(car1AddApiModel.CarDescription.FuelType, resultCar.CarDescription.FuelType);
            Assert.Equal(car1AddApiModel.CarDescription.EngineСapacity, resultCar.CarDescription.EngineСapacity);
            Assert.Equal(car1AddApiModel.CarDescription.YearOfManufacture, resultCar.CarDescription.YearOfManufacture);
        }
Пример #6
0
        static void Main(string[] args)
        {
            var carController    = new CarController();
            var detailController = new DetailController();


            var allDetailsController = detailController.GetAll();

            detailController.Add(null);
            detailController.Delete(24);
            var fifthDetail = detailController.GetById(9);

            detailController.Update(null);

            var allCarViewModels = carController.GetAll();

            carController.Add(null);
            carController.Delete(6);
            var secondCar = carController.GetCarById(1);

            carController.Update(null);

            Console.ReadKey();
        }
Пример #7
0
        public void Main()
        {
            try
            {
                while (true)
                {
                    var messageType = (MessageType)_BinaryFormatter.Deserialize(_NetworkStream);

                    if (messageType == MessageType.Action)
                    {
                        var actionType = (ActionType)_BinaryFormatter.Deserialize(_NetworkStream);

                        switch (actionType)
                        {
                        case ActionType.Authorize:
                            UserController.Authorize();
                            break;

                        case ActionType.Register:
                            UserController.Register();
                            break;

                        case ActionType.GetAutodealers:
                            AutodealerController.GetAutodealers();
                            break;

                        case ActionType.SetCurrentAutodealer:
                            AutodealerController.SetCurrentAutodealer();
                            break;

                        case ActionType.GetCars:
                            CarController.GetCars();
                            break;

                        case ActionType.GetCurrentUser:
                            UserController.GetCurrentUser();
                            break;

                        case ActionType.GetCurrentAutodealer:
                            AutodealerController.GetCurrentAutodealer();
                            break;

                        case ActionType.AddCar:
                            CarController.Add();
                            break;

                        case ActionType.DeleteCar:
                            CarController.Delete();
                            break;

                        case ActionType.EditCar:
                            CarController.Edit();
                            break;

                        case ActionType.SetCarFilter:
                            CarController.SetCarFilter();
                            break;

                        case ActionType.ResetCarFilter:
                            CarController.ResetCarFilter();
                            break;

                        case ActionType.GetUsers:
                            UserController.GetUsers();
                            break;

                        case ActionType.AddUser:
                            UserController.Add();
                            break;

                        case ActionType.BanUnbanUser:
                            UserController.BanUnbanUser();
                            break;

                        case ActionType.DeleteUser:
                            UserController.Delete();
                            break;

                        case ActionType.SetUserSearchData:
                            UserController.SetUserSearchData();
                            break;

                        case ActionType.EditUser:
                            UserController.Edit();
                            break;

                        case ActionType.GetDeals:
                            DealsController.GetDeals();
                            break;

                        case ActionType.ConfirmDeal:
                            DealsController.ConfirmDeal();
                            break;

                        case ActionType.DeleteDeal:
                            DealsController.Delete();
                            break;

                        case ActionType.AddDeal:
                            DealsController.Add();
                            break;

                        case ActionType.EditDeal:
                            DealsController.Edit();
                            break;

                        case ActionType.SetDealSearchData:
                            DealsController.SetDealSearchData();
                            break;

                        case ActionType.DeleteAutodealer:
                            AutodealerController.Delete();
                            break;

                        case ActionType.AddAutodealer:
                            AutodealerController.Add();
                            break;

                        case ActionType.EditAutodealer:
                            AutodealerController.Edit();
                            break;

                        case ActionType.SetAutodealerSearchData:
                            AutodealerController.SetAutodealerSearchData();
                            break;

                        case ActionType.GetCurrentAutodealerStatistics:
                            StatisticsController.GetCurrentAutodealerStatistics();
                            break;

                        case ActionType.GetNotSoldCars:
                            CarController.GetNotSoldCars();
                            break;

                        case ActionType.EditCurrentUserUsername:
                            UserController.EditCurrentUserUsername();
                            break;

                        case ActionType.EditCurrentUserPassword:
                            UserController.EditCurrentUserPassword();
                            break;

                        case ActionType.EditCurrentUserFirstname:
                            UserController.EditCurrentUserFirstname();
                            break;

                        case ActionType.EditCurrentUserSurname:
                            UserController.EditCurrentUserSurname();
                            break;

                        case ActionType.EditCurrentUserTelephone:
                            UserController.EditCurrentUserTelephone();
                            break;

                        case ActionType.BuyCar:
                            CarController.BuyCar();
                            break;

                        case ActionType.GetCurrentUserStatistics:
                            DealsController.GetCurrentUserStatistics();
                            break;

                        case ActionType.GetCurrentUserCars:
                            CarController.GetCurrentUserCars();
                            break;

                        case ActionType.GetUsersNotSuperUsers:
                            UserController.GetUsersNotSuperUsers();
                            break;
                        }
                    }
                }
            }
            catch (Exception) {}
            finally
            {
                if (_NetworkStream != null)
                {
                    _NetworkStream.Close();
                }
                if (Client != null)
                {
                    Client.Close();
                }
            }
        }