static void Main(string[] args) { MotorcycleService service = new MotorcycleService(); MyConsoleMotorcycle myConsoleMotorcycle = new MyConsoleMotorcycle("Honda"); //Let's Drive myConsoleMotorcycle.StartEngine(); myConsoleMotorcycle.Move(1_000); myConsoleMotorcycle.Move(5_000); myConsoleMotorcycle.StopEngine(); myConsoleMotorcycle = null; service = null; //Let's Drive one more time service = new MotorcycleService(); myConsoleMotorcycle = new MyConsoleMotorcycle("Honda"); myConsoleMotorcycle.StartEngine(); myConsoleMotorcycle.Move(1_000); myConsoleMotorcycle.Move(5_000); myConsoleMotorcycle.StopEngine(); myConsoleMotorcycle = null; service = null; //Let's Drive one more time service = new MotorcycleService(); myConsoleMotorcycle = new MyConsoleMotorcycle("Honda"); myConsoleMotorcycle.StartEngine(); }
public async Task EditShouldEdit() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Edit").Options; var dbContext = new ApplicationDbContext(options); var imageService = new ImageService(dbContext); var motorcycleService = new MotorcycleService(dbContext, imageService); AutoMapperConfig.RegisterMappings(typeof(EditMotorcycleViewModel).Assembly, typeof(Motorcycle).Assembly); var addModel = new AddMotorcycleViewModel() { Type = MotorcycleType.Cross, Made = "Honda", Transmission = TransmissionType.Automatic, PriceForHour = 2.00M, Description = "Test", }; var addedScooter = await motorcycleService.AddVehicle <AddMotorcycleViewModel>(addModel); var editModel = new EditMotorcycleViewModel() { Type = MotorcycleType.Cross, Made = "Edited", Transmission = TransmissionType.Automatic, PriceForHour = 2.00M, Description = "Test", }; await motorcycleService.DoEdit <EditMotorcycleViewModel>(editModel); var editedModel = motorcycleService.EditDetails <EditMotorcycleViewModel>(addedScooter); Assert.Equal("Edited", editModel.Made); }
public async Task AddImage() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("add_image").Options; var dbContext = new ApplicationDbContext(options); var imageService = new ImageService(dbContext); var motorcycleService = new MotorcycleService(dbContext, imageService); AutoMapperConfig.RegisterMappings(typeof(MotorcycleViewModel).Assembly, typeof(Motorcycle).Assembly); AutoMapperConfig.RegisterMappings(typeof(EditMotorcycleViewModel).Assembly, typeof(Motorcycle).Assembly); var scooter1 = new AddMotorcycleViewModel() { Type = MotorcycleType.Cross, Made = "Honda", Transmission = TransmissionType.Automatic, PriceForHour = 2.00M, Description = "Test", }; var imagePath = "Test"; var scooter = await motorcycleService.AddVehicle <AddMotorcycleViewModel>(scooter1); await motorcycleService.AddImageUrls(scooter, imagePath); var result = motorcycleService.EditDetails <MotorcycleViewModel>(scooter); Assert.Equal(imagePath, result.ImageUrl); }
public async Task Delete() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("delete_bicycle").Options; var dbContext = new ApplicationDbContext(options); var imageService = new ImageService(dbContext); var motorcycleService = new MotorcycleService(dbContext, imageService); AutoMapperConfig.RegisterMappings(typeof(AddMotorcycleViewModel).Assembly, typeof(Motorcycle).Assembly); var scooter1 = new AddMotorcycleViewModel() { Type = MotorcycleType.Cross, Made = "Honda", Transmission = TransmissionType.Automatic, PriceForHour = 2.00M, Description = "Test", }; var scooter = await motorcycleService.AddVehicle <AddMotorcycleViewModel>(scooter1); await motorcycleService.Delete(scooter); var bycicles = motorcycleService.GetAll <MotorcycleViewModel>(false); Assert.Empty(bycicles.ToList()); }
static void Main(string[] args) { var getPRice = new CalcPrice(); IMotorcycleBuilder motorcycleBuilder = new MotorcycleHarley(getPRice); var motorcycleService = new MotorcycleService(); motorcycleService.PrepareMotorcycleHarley(motorcycleBuilder, ChassiSize.Large, ColorType.Black, MotorcycleType.Softail, "Fat bob"); var harley = motorcycleBuilder.GetMotorcycle(); Console.WriteLine($"{harley.Name} - {harley.Price} - {harley.ColorType.ToString() }, {harley.MotorcycleType.ToString()}"); }
public async Task AddTests() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Add").Options; var dbContext = new ApplicationDbContext(options); var imageService = new ImageService(dbContext); var motorcycleService = new MotorcycleService(dbContext, imageService); var model = new AddMotorcycleViewModel() { Type = MotorcycleType.Cross, Made = "Honda", Transmission = TransmissionType.Automatic, PriceForHour = 2.00M, Description = "Test", }; var motorcycle = await motorcycleService.AddVehicle <AddMotorcycleViewModel>(model); Assert.Equal(1, motorcycle); }
public async Task GetAllByType() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("get_all_by_type").Options; var dbContext = new ApplicationDbContext(options); var imageService = new ImageService(dbContext); var motorcycleService = new MotorcycleService(dbContext, imageService); AutoMapperConfig.RegisterMappings(typeof(EditMotorcycleViewModel).Assembly, typeof(Motorcycle).Assembly); var scooter1 = new AddMotorcycleViewModel() { Type = MotorcycleType.Cross, Made = "Honda", Transmission = TransmissionType.Automatic, PriceForHour = 2.00M, Description = "Test", }; var addedMotorcycle = await motorcycleService.AddVehicle <AddMotorcycleViewModel>(scooter1); var scooter = motorcycleService.GetAllByType <MotorcycleViewModel>(MotorcycleType.Cross.ToString(), false); Assert.Single(scooter.ToList()); }
public MotorcyclesController(IKTMData data) : base(data) { this.service = new MotorcycleService(); }