예제 #1
0
        /// <summary>
        /// Registers the EcaContext.
        /// </summary>
        /// <param name="container">The unity container.</param>
        public static void RegisterContexts(IUnityContainer container)
        {
            var appSettings      = new AppSettings();
            var connectionString = appSettings.EcaContextConnectionString.ConnectionString;

            container.RegisterType <EcaContext>(new HierarchicalLifetimeManager(), new InjectionConstructor(connectionString));
            container.RegisterType <DbContext, EcaContext>(new HierarchicalLifetimeManager(), new InjectionConstructor(connectionString));
            container.RegisterType <List <ISaveAction> >(new InjectionFactory((c) =>
            {
                var list = new List <ISaveAction>();
                list.Add(new PermissableSaveAction(c.Resolve <IPermissableService>(), (addedEntityResults) =>
                {
                    if (addedEntityResults.Count > 0 &&
                        addedEntityResults.SelectMany(x => x.AffectedRolesById).Count() > 0)
                    {
                        CamRoleChangeMonitor.Changed();
                    }
                }));
                list.Add(new GenericDocumentSaveAction <Program>(new AppSettings(), ProgramDTODocumentConfiguration.PROGRAM_DTO_DOCUMENT_TYPE_ID, x => x.ProgramId));
                list.Add(new GenericDocumentSaveAction <Project>(new AppSettings(), ProjectDTODocumentConfiguration.PROJECT_DTO_DOCUMENT_TYPE_ID, x => x.ProjectId));
                list.Add(new OfficeDocumentSaveAction(new AppSettings()));
                list.Add(new OrganizationDocumentSaveAction(new AppSettings()));
                list.Add(new AddressToEntityDocumentSaveAction(new AppSettings()));
                list.Add(new ExchangeVisitorSaveAction(c.Resolve <IExchangeVisitorValidationService>()));
                return(list);
            }));
        }
예제 #2
0
        public void TestUniqueId()
        {
            var monitor1 = new CamRoleChangeMonitor();
            var monitor2 = new CamRoleChangeMonitor();

            Assert.AreNotEqual(Guid.Empty, monitor1.UniqueId);
            Assert.AreNotEqual(Guid.Empty, monitor2.UniqueId);
            Assert.AreNotEqual(monitor1.UniqueId, monitor2.UniqueId);
        }
예제 #3
0
        public void TestChanged_HasDelegate()
        {
            var monitor     = new CamRoleChangeMonitor();
            var eventRaised = false;

            CamRoleChangeMonitor.RoleChanged += delegate(object sender, CamRoleChangeMonitorEventArgs args)
            {
                eventRaised = true;
                Assert.IsNull(sender);
                Assert.IsNotNull(args);
            };

            Assert.IsFalse(eventRaised);
            CamRoleChangeMonitor.Changed();
            Assert.IsTrue(eventRaised);
        }
예제 #4
0
        public void TestChanged_DoesNotHaveDelegate()
        {
            Action a = () => CamRoleChangeMonitor.Changed();

            a.ShouldNotThrow();
        }