public void CreateMappings(IMapperConfigurationExpression configuration) { IEncryptingService encryptingService = new EncryptingService(); configuration.CreateMap <StudentEntity, StudentDomain>() .ForMember(domain => domain.Id, x => x.MapFrom(entity => encryptingService.EncodeId(entity.Id))) .ForMember(domain => domain.ClassId, x => x.MapFrom(entity => encryptingService.EncodeId(entity.ClassId))); configuration.CreateMap <StudentDomain, StudentEntity>() .ForMember(entity => entity.Id, x => x.MapFrom(domain => encryptingService.DecodeId(domain.Id))) .ForMember(entity => entity.ClassId, x => x.MapFrom(domain => encryptingService.DecodeId(domain.ClassId))); }
public void EncodeId_WithValidId_ReturnDecodedId() { var id = 1; IEncryptingService provider = new EncryptingService(); var encodedId = provider.EncodeId(id); Assert.AreEqual("MWFua1NhbGx0", encodedId); }