Example #1
0
        public async Task MapAsync()
        {
            await CreateMapsAsync();

            ClientModel model = ClientModel.Create();

            ClientEntity entity = await EntitiesMapper.MapAsync <ClientModel, ClientEntity>(model);

            ClientModel model2 = await EntitiesMapper.MapAsync <ClientEntity, ClientModel>(entity);

            Assert.AreEqual(model.Id, entity.Id);
            Assert.AreEqual(model.FirstName, entity.FirstName);
            Assert.AreEqual(model.LastName, entity.LastName);
            Assert.AreEqual(model.DateAdded, entity.DateAdded);
            Assert.AreEqual(model.Address.Id, entity.Address.Id);
            Assert.AreEqual(model.Address.Description, entity.Address.Description);
            Assert.AreEqual(model.Address.City.Id, entity.Address.City.Id);
            Assert.AreEqual(model.Address.City.Description, entity.Address.City.Description);

            Assert.AreEqual(entity.Id, model2.Id);
            Assert.AreEqual(entity.FirstName, model2.FirstName);
            Assert.AreEqual(entity.LastName, model2.LastName);
            Assert.AreEqual(entity.DateAdded, model2.DateAdded);
            Assert.AreEqual(entity.Address.Id, model2.Address.Id);
            Assert.AreEqual(entity.Address.Description, model2.Address.Description);
            Assert.AreEqual(entity.Address.City.Id, model2.Address.City.Id);
            Assert.AreEqual(entity.Address.City.Description, model2.Address.City.Description);
        }
Example #2
0
        internal ClientModel GetClientById(int id)
        {
            EntityContext context = EntityContextSingletone.Instance;
            var           client  = context.Client.First(c => c.Id.Equals(id));

            return(ClientModel.Create(client));
        }
Example #3
0
        public void Map()
        {
            CreateMaps();

            ClientModel model = ClientModel.Create();

            ClientEntity entity = EntitiesMapper.Map <ClientModel, ClientEntity>(model);
            ClientModel  model2 = EntitiesMapper.Map <ClientEntity, ClientModel>(entity);

            Assert.AreEqual(model.Id, entity.Id);
            Assert.AreEqual(model.FirstName, entity.FirstName);
            Assert.AreEqual(model.LastName, entity.LastName);
            Assert.AreEqual(model.DateAdded, entity.DateAdded);
            Assert.AreEqual(model.Address.Id, entity.Address.Id);
            Assert.AreEqual(model.Address.Description, entity.Address.Description);
            Assert.AreEqual(model.Address.City.Id, entity.Address.City.Id);
            Assert.AreEqual(model.Address.City.Description, entity.Address.City.Description);

            Assert.AreEqual(entity.Id, model2.Id);
            Assert.AreEqual(entity.FirstName, model2.FirstName);
            Assert.AreEqual(entity.LastName, model2.LastName);
            Assert.AreEqual(entity.DateAdded, model2.DateAdded);
            Assert.AreEqual(entity.Address.Id, model2.Address.Id);
            Assert.AreEqual(entity.Address.Description, model2.Address.Description);
            Assert.AreEqual(entity.Address.City.Id, model2.Address.City.Id);
            Assert.AreEqual(entity.Address.City.Description, model2.Address.City.Description);
        }