예제 #1
0
        public void SaveDto_InsertTest()
        {
            // --================================================================== Arrangement
            SmartPhoneDto dto = new SmartPhoneDto
            {
                Make  = "Apple",
                Model = "IPhone X",
                Year  = 2018
            };

            // --================================================================== Action
            _entityId = SmartPhoneEntityDtoService.SaveDto(dto).Id;

            // --================================================================== Assertion
            SmartPhoneEntity entity;

            using (DataConnection context = new DataConnection("Core"))
            {
                entity = context.GetTable <SmartPhoneEntity>().First(smartPhone => smartPhone.Id == _entityId);
            }

            Assert.AreEqual("Apple", entity.Make);
            Assert.AreEqual("IPhone X", entity.Model);
            Assert.AreEqual(2018, entity.Year);
        }
예제 #2
0
        public void SaveDto_UpdateTest()
        {
            // --================================================================== Arrangement
            SmartPhoneDto dto = SmartPhoneEntityDtoService.LoadDtoOrNull(_entityId);

            dto.Year = 2019;

            // --================================================================== Action
            _entityId = SmartPhoneEntityDtoService.SaveDto(dto).Id;

            // --================================================================== Assertion
            SmartPhoneEntity entity;

            using (DataConnection context = new DataConnection("Core"))
            {
                entity = context.GetTable <SmartPhoneEntity>().First(smartPhone => smartPhone.Id == _entityId);
            }

            Assert.AreEqual("Apple", entity.Make);
            Assert.AreEqual("IPhone X", entity.Model);
            Assert.AreEqual(2019, entity.Year);
        }