Пример #1
0
        public void CompareObjectProperties_Returns_4_Results()
        {
            var startIntId = 1;
            var endIntId   = 2;
            var bike       = new BikeEntity
            {
                BikeModelId = Guid.NewGuid(),
                BikeColorId = startIntId,
                WheelSizeId = startIntId,
            };

            var dto = new BikeDto
            {
                IsActive        = false,
                BikeModelId     = Guid.NewGuid(),
                BikeColorId     = endIntId,
                WheelSizeId     = endIntId,
                CurrentStatusId = endIntId
            };

            var excludedProperties = new List <string> {
                "id", "PurchaseDate", "RemovedFromInventoryDate"
            };
            var actual = objectInspectionService.GetDifferentPropertyValues(bike, dto, excludedProperties);

            var expectedCount = 5; // amount of properties in dto

            Assert.AreEqual(expectedCount, actual.Count());
        }
Пример #2
0
        public void UpdateBike(BikeDto bikeDto)
        {
            var bikeToUpdate  = _bikeRepository.GetById(bikeDto.Id);
            var historyItemId = CreateHistoryItemForBike(bikeToUpdate.Id, Status.Updated);

            var excludedProperties = new List <string> {
                "id"
            };
            var propertiesToUpdate = _inspectionService.GetDifferentPropertyValues(bikeToUpdate, bikeDto, excludedProperties);

            CreateHistoryNoteForBikeUpdate(propertiesToUpdate, historyItemId);

            bikeToUpdate.BikeColorId = bikeDto.BikeColorId;
            bikeToUpdate.BikeModelId = bikeDto.BikeModelId;
            bikeToUpdate.WheelSizeId = bikeDto.WheelSizeId;

            _bikeRepository.Update(bikeToUpdate);
        }