Ejemplo n.º 1
0
        public void ProxyInstalled_ReturnsTrue_WhenExecuteProxyOperationReturnsTrue()
        {
            SharePointEnvironment.Reset();
            MockApplicationContextProvider.Reset();
            MockApplicationContextProvider appContextProvider = new MockApplicationContextProvider();

            SharePointEnvironment.ApplicationContextProvider = appContextProvider;
            MockApplicationContextProvider.ExecuteRegisteredProxyOperationRetVal = true;

            Assert.IsTrue(SharePointEnvironment.ProxyInstalled("namespaceForProxy", "typeForProxy"));
        }
Ejemplo n.º 2
0
        public void ProxyInstalled_ReturnsFalse_WhenApplicationContextReturnsFalse()
        {
            SharePointEnvironment.Reset();
            MockApplicationContextProvider.Reset();
            MockApplicationContextProvider appContextProvider = new MockApplicationContextProvider();

            SharePointEnvironment.ApplicationContextProvider             = appContextProvider;
            MockApplicationContextProvider.IsProxyCheckerInstalledRetVal = false;

            Assert.IsFalse(SharePointEnvironment.ProxyInstalled("namespaceForProxy", "typeForProxy"));
        }
Ejemplo n.º 3
0
        public void ProxyInstalled_CachesRetVal_IfPreviouslyDeterminedFalse()
        {
            SharePointEnvironment.Reset();
            MockApplicationContextProvider.Reset();
            MockApplicationContextProvider appContextProvider = new MockApplicationContextProvider();

            SharePointEnvironment.ApplicationContextProvider             = appContextProvider;
            MockApplicationContextProvider.IsProxyCheckerInstalledRetVal = false;

            Assert.IsFalse(SharePointEnvironment.ProxyInstalled("namespaceForProxy", "typeForProxy"));

            MockApplicationContextProvider.IsProxyCheckerInstalledRetVal = true;
            Assert.IsFalse(SharePointEnvironment.ProxyInstalled("namespaceForProxy", "typeForProxy"));
        }
Ejemplo n.º 4
0
        protected virtual void WriteToOperationsLogSandbox(string message, int eventId, SandboxEventSeverity?severity, string category)
        {
            if (SharePointLogger.canAccessSandboxLogging == -1)
            {
                if (SharePointEnvironment.ProxyInstalled(TracingOperationArgs.OperationAssemblyName, TracingOperationArgs.OperationTypeName))
                {
                    SharePointLogger.canAccessSandboxTracing = 1;
                }
                else
                {
                    SharePointLogger.canAccessSandboxTracing = 0;
                }
            }

            if (SharePointLogger.canAccessSandboxTracing == 1)
            {
                var args = new LoggingOperationArgs();
                args.Message  = message;
                args.EventId  = eventId;
                args.Category = category;
                args.Severity = (int?)severity;

                if (SPContext.Current != null)
                {
                    args.SiteID = SPContext.Current.Site.ID;
                }
                else
                {
                    args.SiteID = null;
                }

                var result = SPUtility.ExecuteRegisteredProxyOperation(
                    LoggingOperationArgs.OperationAssemblyName,
                    LoggingOperationArgs.OperationTypeName,
                    args);

                if (result != null && result.GetType().IsSubclassOf(typeof(System.Exception)))
                {
                    var ex = new LoggingException(Resources.SandboxLoggingFailed, (Exception)result);
                    throw ex;
                }
            }
        }