Exemple #1
0
        public void LearnerDTOtoLearnerModel_ShouldMapLearnerDTOtoLearnerModel()
        {
            //Arrange
            LearnerDTO dto = new LearnerDTO {
                LearnerId = 123, LearnerCode = "TestCode", Forename = "Jon", Surname = "Armstrong"
            };
            LearnerModel model = new LearnerModel();

            var services = new ServiceCollection();

            services.AddAutoMapper(typeof(AutoMapping));
            services.AddTransient <IMappers, Mappers>();

            IServiceProvider serviceProvider = services.BuildServiceProvider();
            IMappers         mappers         = serviceProvider.GetRequiredService <IMappers>();

            //Act
            model = mappers.LearnerDTOtoLearnerModel(dto);

            //Assert
            Assert.NotNull(model);
            Assert.Equal(dto.LearnerId, model.LearnerId);
            Assert.Equal(dto.LearnerCode, model.LearnerCode);
            Assert.Equal(dto.Forename, model.Forename);
            Assert.Equal(dto.Surname, model.Surname);
        }
Exemple #2
0
        /// <summary>
        /// Gets Json from Resources and Transforms it into the Output format
        /// </summary>
        /// <returns>string</returns>
        public string GetLearner()
        {
            LearnerDTO   learnerDTO   = JsonFactory.LoadJson();
            LearnerModel learnerModel = mappers.LearnerDTOtoLearnerModel(learnerDTO);
            OutputModel  outputModel  = mappers.LearnerModeltoOutputModel(learnerModel);
            OutputDTO    outputDTO    = mappers.OutputModeltoOutputDTO(outputModel);

            return(JsonFactory.JsonSerialize(outputDTO));
        }