public void GetCameraVMTest() { var service = BuildInMemoryDBProvider(); using (var dbContext = service.GetService <DatabaseContext>()) { //Arrange var cameraiPhone12 = new Camera() { Id = 1, Zoom = 8, FrontResulution = 16, MainResulution = 32, AdditionalResulution = 16, VideoRecorderResolution = "4K", VideoFPS = 120, Functions = "Video Recorder;Autofokus;Flash", MobilePhoneId = 1 }; var iPhone12 = new MobilePhone() { Id = 1, Brand = "Apple", Name = "iPhone 12", Price = 3000, ShortDescription = "short", Description = "description", ActiveStatus = true, QuantityInStack = QuantityStatus.Full, MainImage = "/Apple/iPhone 12/Main.png", FirstImage = "/Apple/iPhone 12/First.png", SecondImage = "/Apple/iPhone 12/Second.png", Camera = cameraiPhone12, BestSeller = true }; var configuration = new MapperConfiguration(cfg => { cfg.CreateMap <Camera, CameraVM>(); }); var mapper = new Mapper(configuration); var mobilePhoneRepository = new MobilePhoneRepository(dbContext); var mobilePhoneService = new MobilePhoneService(mobilePhoneRepository, mapper); //Act var result = mobilePhoneService.GetCameraVM(iPhone12); //Assert result.Should().BeOfType <CameraVM>(); } }
public void GetCameraVMTest_Null() { var service = BuildInMemoryDBProvider(); using (var dbContext = service.GetService <DatabaseContext>()) { //Arrange var iPhone12 = new MobilePhone() { Id = 1, Brand = "Apple", Name = "iPhone 12", Price = 3000, ShortDescription = "short", Description = "description", ActiveStatus = true, QuantityInStack = QuantityStatus.Full, MainImage = "/Apple/iPhone 12/Main.png", FirstImage = "/Apple/iPhone 12/First.png", SecondImage = "/Apple/iPhone 12/Second.png", BestSeller = true }; var configuration = new MapperConfiguration(cfg => { cfg.CreateMap <Camera, CameraVM>(); }); var mapper = new Mapper(configuration); var mobilePhoneRepository = new MobilePhoneRepository(dbContext); var mobilePhoneService = new MobilePhoneService(mobilePhoneRepository, mapper); //Act var result = mobilePhoneService.GetCameraVM(iPhone12); //Assert result.Should().BeNull(); } }