예제 #1
0
        public void MapListOfIntEntitiesToIntEntityViewModelsWithPredefinedMapShouldMapAllProperties()
        {
            Init();
            IntEntity entityA = new IntEntity() { Id = 1, Name = "Test A", Number = 10, IsRequired = true, StartDate = new DateTime(2012, 5, 16) };
            IntEntity entityB = new IntEntity() { Id = 2, Name = "Test B", Number = 11, IsRequired = true, StartDate = new DateTime(2012, 5, 16) };
            IntEntity entityC = new IntEntity() { Id = 3, Name = "Test C", Number = 12, IsRequired = true, StartDate = new DateTime(2012, 5, 16) };

            var list = new List<IntEntity>() { entityA, entityB, entityC };
            var modelList = list.Map(typeof(IntEntityViewModel));
            Assert.AreEqual(3, modelList.Cast<IntEntityViewModel>().Length());
        }
예제 #2
0
 public void MapIntEntityToIntEntityViewModelWithPredefinedMapShouldMapAllProperties()
 {
     Init();
     IntEntity entity = new IntEntity() { Id = 1, Name = "Test", Number = 10, IsRequired = true, StartDate = new DateTime(2012, 5, 16) };
     IntEntityViewModel model = entity.Map<IntEntityViewModel>();
     bool result = entity.Id == model.Id
                     && entity.Name == model.EntityName
                     && entity.Number == model.Order
                     && entity.IsRequired == model.Required
                     && entity.StartDate == model.Date;
     Assert.IsTrue(result);
 }
예제 #3
0
 public void MapIntEntityToIntEntityViewModelWithPredefinedMapAndExistingModelShouldMapAllPropertiesButKeepValuesOfPropertiesThatDoNotExistInTheSource()
 {
     Init();
     IntEntity entity = new IntEntity() { Name = "Test", IsRequired = false, StartDate = new DateTime(2012, 5, 16) };
     IntEntityViewModel model = new IntEntityViewModel() { Id = 1, EntityName = "Test", Order = 10, Required = true, ViewModelOnly = "Test" };
     entity.Map<IntEntityViewModel>(model);
     bool result = entity.Id == model.Id
                     && entity.Name == model.EntityName
                     && entity.Number == model.Order
                     && entity.IsRequired == model.Required
                     && entity.StartDate == model.Date
                     && model.ViewModelOnly == "Test";
     Assert.IsTrue(result);
 }