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 DecodeId_WithNullId_ThrowsArgumentNullException() { IEncryptingService provider = new EncryptingService(); Assert.That(() => provider.DecodeId(null), Throws.TypeOf <ArgumentNullException>() .With.Message.Contain("The argument is null.")); }
public void DecodeId_WithValidId_ReturnDecodedId() { var id = "MWFua1NhbGx0"; IEncryptingService provider = new EncryptingService(); var decodedId = provider.DecodeId(id); Assert.AreEqual(1, decodedId); }