Ejemplo n.º 1
0
        public void CreateSmartPhoneWithMissingOSThrowsException()
        {
            var smartPhoneRepo         = new Mock <ISmartPhoneRepository>();
            ISmartPhoneService service = new SmartPhoneService(smartPhoneRepo.Object);

            var phone = new SmartPhone
            {
                Camera  = "10 mega pixels",
                CpuType = "SnapDragon",
                Memory  = 124,
                Name    = "Xiao mi mix 2",
                Screen  = 6.0,
                Stock   = 10,
                Price   = 1234
            };
            Exception ex = Assert.Throws <InvalidDataException>(() => service.CreateSmartPhone(phone));

            Assert.Equal("Must have a OS", ex.Message);
        }
Ejemplo n.º 2
0
        public void CreateSmartPhone()
        {
            var phone = new SmartPhone
            {
                Camera  = "10 mega pixels",
                CpuType = "SnapDragon",
                Memory  = 124,
                OS      = "Android coffee",
                Name    = "Xiao mi mix 2",
                Stock   = 10,
                Price   = 1234,
                Screen  = 6.0
            };

            var smartPhoneRepo = new Mock <ISmartPhoneRepository>();

            smartPhoneRepo.Setup(x => x.CreateSmartPhone(phone)).Returns(phone);
            ISmartPhoneService service = new SmartPhoneService(smartPhoneRepo.Object);

            var result = service.CreateSmartPhone(phone);

            Assert.Equal(phone, result);
        }