コード例 #1
0
        public DateTime AdvetisementDay(CarShopEntity account)
        {
            var advertisementDay = DateTime.UtcNow.AddHours(2);

            account.AdvertisementDay = advertisementDay;
            return(advertisementDay);
        }
コード例 #2
0
        public void CanCreateNewAdvertisement()
        {
            CarShopEntity carShopEntity = new CarShopEntity
            {
                AdvertisementId   = 555,
                City              = "Helsingborg",
                CarModel          = "Sedan",
                Fuel              = "Diesel",
                GearBox           = "Manuell",
                Mileage           = 24525,
                ModelYear         = "2018-04-08",
                ManufacturingYear = DateTime.Today,
                Price             = 24000,
                Description       = "Wonderful car",
                Title             = "Volvo",
                PostalNumber      = "2545",
                AdvertisementDay  = DateTime.Today
            };

            carShopSystem.CreateNewCar(carShopEntity);

            Assert.True(carShopEntity != null);
            Assert.AreSame("Sedan", carShopEntity.CarModel);

            //var result = carShopSystem.AdvertismentInformation(carShopEntity.AdvertisementId);
            //Assert.AreEqual(carShopEntity.AdvertisementId, 555);
        }
コード例 #3
0
        public static CarShopEntity EntityToModel(CarShopModel carEntity)
        {
            var model = new CarShopEntity();

            model.AdvertisementId   = carEntity.AdvertisementId;
            model.CarModel          = carEntity.CarModel;
            model.City              = carEntity.City;
            model.Description       = carEntity.Description;
            model.Fuel              = carEntity.Fuel;
            model.GearBox           = carEntity.GearBox;
            model.ManufacturingYear = DateTime.Now;
            model.Mileage           = carEntity.Mileage;
            model.ModelYear         = carEntity.ModelYear;
            model.PostalNumber      = carEntity.PostalNumber;
            model.Price             = carEntity.Price;
            model.Title             = carEntity.Title;
            model.AdvertisementDay  = carEntity.AdvertisementDay;
            model.ChildCategory     = carEntity.ChildCategoryName;
            return(model);
        }
コード例 #4
0
        public void CreateNewCar(CarShopEntity createCarEntity)
        {
            if (createCarEntity.Title == null)
            {
                throw new ArgumentNullException("Some Parameters in the Advertisment cant be null", "Title");
            }
            using (var transaction = new TransactionScope())
            {
                AdvetisementDay(createCarEntity);
                _carRepository.CreateNewCar(createCarEntity);

                if (createCarEntity.Files != null)
                {
                    foreach (var picture in createCarEntity.Files)
                    {
                        picture.AdvertisementId = createCarEntity.AdvertisementId;
                        _carRepository.UploadePictures(picture);
                    }
                }
                transaction.Complete();
            }
        }
コード例 #5
0
        public void CanCreateCar_WillFailIfEmpty(string title, string param)
        {
            CarShopEntity carShopEntity = new CarShopEntity()
            {
                AdvertisementId   = 0,
                City              = "",
                CarModel          = "",
                Fuel              = "",
                GearBox           = "",
                Mileage           = 24525,
                ModelYear         = "",
                ManufacturingYear = DateTime.Today,
                Price             = 24000,
                Description       = "",
                Title             = title,
                PostalNumber      = "",
                AdvertisementDay  = DateTime.Today
            };

            carShopSystem.CreateNewCar(carShopEntity);
            //Assert.Throws<ArgumentNullException>(() =>  carShopSystem.CreateNewCar(carShopEntity));
            //Assert.That(ex.Message, Is.EqualTo("Some Parameters in the Advertisment cant be null"));
        }
コード例 #6
0
        public static CarShopModel ModelToEntity(CarShopEntity carEntity)
        {
            var model = new CarShopModel();

            model.AdvertisementId   = carEntity.AdvertisementId;
            model.CarModel          = carEntity.CarModel;
            model.City              = carEntity.City;
            model.Description       = carEntity.Description;
            model.Fuel              = carEntity.Fuel;
            model.GearBox           = carEntity.GearBox;
            model.ManufacturingYear = DateTime.Now;
            model.Mileage           = carEntity.Mileage;
            model.ModelYear         = carEntity.ModelYear;
            model.PostalNumber      = carEntity.PostalNumber;
            model.Price             = carEntity.Price;
            model.Title             = carEntity.Title;
            model.AdvertisementDay  = carEntity.AdvertisementDay;
            model.ChildCategoryName = carEntity.ChildCategory;
            model.Fileings          = carEntity.Files?.Select(p => p.PictureGuidName).ToList();


            return(model);
        }
コード例 #7
0
 public void EditCar(CarShopEntity carShopEntity)
 {
     _carRepository.EditCar(carShopEntity);
 }
コード例 #8
0
 public void Setup()
 {
     carShopSystem = Substitute.For <ICarShopSystem>();
     carShopEntity = new CarShopEntity();
 }