Exemple #1
0
        public void GetMultimediaVM()
        {
            var service = BuildInMemoryDBProvider();

            using (var dbContext = service.GetService <DatabaseContext>())
            {
                //Arrange
                var multimediaApple = new Multimedia()
                {
                    Id                = 1,
                    USBType           = "Lighting",
                    Bluetooth         = true,
                    NFC               = true,
                    FingerPrintReader = true,
                    LTE               = true,
                    GPS               = true,
                    WiFiCalling       = false
                };
                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",
                    Multimedia       = multimediaApple,
                    BestSeller       = true
                };

                var configuration = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <Multimedia, MultimediaVM>();
                });
                var mapper = new Mapper(configuration);
                var mobilePhoneRepository = new MobilePhoneRepository(dbContext);
                var mobilePhoneService    = new MobilePhoneService(mobilePhoneRepository, mapper);
                //Act
                var result = mobilePhoneService.GetMultimediaVM(iPhone12);
                //Assert
                result.Should().BeOfType <MultimediaVM>();
            }
        }