public void Automapper_Contact_Details_Json_Can_Be_Mapped()
        {
            // Setup
            EntityMapLoader.LoadEntityMappings();
            DateTime testDate = DateTime.Now;

            var json = new ContactDetailsJson
            {
                CompanyName = "company",
                ContactId   = "12345",
                FirstName   = "first",
                LastName    = "last",
                Owned       = true,
                Title       = "title",
                UpdatedDate = testDate
            };

            // Act
            var result = Mapper.Map <ContactDetailsJson, ExternalContactSearchResultsViewModel.ContactResultViewModel>(json);

            // Verify
            Assert.IsNotNull(result, "result was null");
            Assert.AreEqual("company", result.Company);
            Assert.AreEqual("12345", result.ContactId);
            Assert.AreEqual("first", result.FirstName);
            Assert.AreEqual("last", result.LastName);
            Assert.AreEqual(true, result.HasAccess);
            Assert.AreEqual("title", result.Headline);
            Assert.AreEqual(testDate, result.LastUpdatedDate);
        }
        public void Automapper_Configurations_Are_Valid()
        {
            // Act
            EntityMapLoader.LoadEntityMappings();

            // Validate
            Mapper.AssertConfigurationIsValid();
        }
        public void Loader_Loads_All_Configurations_In_Assembly()
        {
            // Setup
            UnitTestEntity entity = new UnitTestEntity {
                Id = 2, Text = "Test 1234"
            };

            // Act
            EntityMapLoader.LoadEntityMappings();

            // Verify
            UnitTestEntityViewModel result = Mapper.Map <UnitTestEntity, UnitTestEntityViewModel>(entity);

            Assert.AreEqual(entity.Id, result.Id, "View model's ID value did not match");
            Assert.AreEqual(entity.Text, result.Text2, "View model's text value did not match");
        }
Beispiel #4
0
        public void Setup()
        {
            // Configure entity mappings
            EntityMapLoader.LoadEntityMappings();

            // Initialize the database connection
            Database.SetInitializer <MyJobLeadsDbContext>(new DropCreateDatabaseAlways <MyJobLeadsDbContext>());
            _unitOfWork = new EFUnitOfWork();
            _unitOfWork.UnitTestEntities.Fetch().Count(); // Required to make sure database is created outside of transaction scope
            _context = (_unitOfWork as EFUnitOfWork).DbContext;

            _transaction = new TransactionScope();

            // Create service factory mock
            _serviceFactory = new Mock <IServiceFactory>();
            _serviceFactory.Setup(x => x.GetService <IUnitOfWork>()).Returns(_unitOfWork);
        }
Beispiel #5
0
        public static void Wire()
        {
            // Set the Entity Framework database initializer
            if (ConfigurationManager.AppSettings[UpdateDbAppSettingName] == "true")
            {
                Database.SetInitializer <MyJobLeadsDbContext>(new MyJobLeadsDbInitializer());
            }
            else
            {
                Database.SetInitializer <MyJobLeadsDbContext>(null);
            }

            container.Install(FromAssembly.This());
            var controllerFactory = new WindsorControllerFactory(container.Kernel);

            ControllerBuilder.Current.SetControllerFactory(controllerFactory);

            // Load all entity mapping configurations
            EntityMapLoader.LoadEntityMappings();
        }