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

            using (var dbContext = service.GetService <DatabaseContext>())
            {
                //Arrange
                var hardwareiPhone12 = new Hardware()
                {
                    Id                = 1,
                    ProcessorName     = "A14 Bionic",
                    OperationSystem   = "iOS",
                    GraphicsProcessor = "A14 Bionic",
                    OperationMemory   = 4,
                    MemorySpace       = 64,
                    SimCardType       = "Nano",
                    BatteryCapacity   = 2500,
                    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",
                    Hardware         = hardwareiPhone12,
                    BestSeller       = true
                };

                var configuration = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <Hardware, HardwareVM>();
                });
                var mapper = new Mapper(configuration);
                var mobilePhoneRepository = new MobilePhoneRepository(dbContext);
                var mobilePhoneService    = new MobilePhoneService(mobilePhoneRepository, mapper);
                //Act
                var result = mobilePhoneService.GetHardwareVM(iPhone12);
                //Assert
                result.Should().BeOfType <HardwareVM>();
            }
        }
Exemple #2
0
        public void GetHardwareVM_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 <Hardware, HardwareVM>();
                });
                var mapper = new Mapper(configuration);
                var mobilePhoneRepository = new MobilePhoneRepository(dbContext);
                var mobilePhoneService    = new MobilePhoneService(mobilePhoneRepository, mapper);
                //Act
                var result = mobilePhoneService.GetHardwareVM(iPhone12);
                //Assert
                result.Should().BeNull();
            }
        }