Exemplo n.º 1
0
        public void BackMappingTest()
        {
            // Check model to entity mapping is correct
            var model = new CarModel()
            {
                Id          = generator.Next(1, 10000),
                Name        = Guid.NewGuid().ToString("N"),
                Description = Guid.NewGuid().ToString("N")
            };

            var entity = mapper.Back(model);

            Assert.AreEqual(model.Id, entity.PublicId);
            Assert.AreEqual(model.Name, entity.Name);
            Assert.AreEqual(model.Description, entity.Description);

            // Set triggers on entity and model property list changed. Test must fail in this case
            Assert.AreEqual(4, GetPropertiesCount(entity), $"Property list at class '{ nameof(Car) }' changed. Test must be updated");
            Assert.AreEqual(3, GetPropertiesCount(model), $"Property list at class '{ model.GetType().Name }' changed. Test must be updated");
        }