Exemple #1
0
        public void CanAccessFarm_ReturnsFalse_WhenSPFarmLocalNull()
        {
            SharePointEnvironment.Reset();
            MockApplicationContextProvider.Reset();
            MockApplicationContextProvider appContextProvider = new MockApplicationContextProvider();

            SharePointEnvironment.ApplicationContextProvider = appContextProvider;
            MockApplicationContextProvider.SPFarmLocal       = null;

            Assert.IsFalse(SharePointEnvironment.CanAccessFarm);
        }
Exemple #2
0
        public void CanAccessSharePoint_ReturnsTrue_WithSandBoxInAppDomainName()
        {
            SharePointEnvironment.Reset();
            MockApplicationContextProvider.Reset();
            MockApplicationContextProvider appContextProvider = new MockApplicationContextProvider();

            SharePointEnvironment.ApplicationContextProvider     = appContextProvider;
            MockApplicationContextProvider.AppDomainFriendlyName = "MySandboxAppDomain";

            Assert.IsTrue(SharePointEnvironment.CanAccessSharePoint);
        }
Exemple #3
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"));
        }
Exemple #4
0
        public void InSandBox_ReturnsFalse_WithoutSandBoxInAppDomainName()
        {
            SharePointEnvironment.Reset();
            MockApplicationContextProvider.Reset();
            MockApplicationContextProvider appContextProvider = new MockApplicationContextProvider();

            SharePointEnvironment.ApplicationContextProvider     = appContextProvider;
            MockApplicationContextProvider.AppDomainFriendlyName = "MyAppDomain";

            Assert.IsFalse(SharePointEnvironment.InSandbox);
        }
Exemple #5
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"));
        }
Exemple #6
0
        public void CanAccessSharePoint_ReturnsFalse_WhenNotInSandboxAndSPFarmLocalNull()
        {
            SharePointEnvironment.Reset();
            MockApplicationContextProvider.Reset();
            MockApplicationContextProvider appContextProvider = new MockApplicationContextProvider();

            SharePointEnvironment.ApplicationContextProvider     = appContextProvider;
            MockApplicationContextProvider.AppDomainFriendlyName = "MyAppDomain";
            MockApplicationContextProvider.SPFarmLocal           = null;

            Assert.IsFalse(SharePointEnvironment.CanAccessSharePoint);
        }
Exemple #7
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"));
        }
Exemple #8
0
        public void WriteSandboxLog_LogsMessage()
        {
            //Arrange
            SharePointEnvironment.Reset();
            var context = new SIApplicationContextProvider()
            {
                GetCurrentAppDomainFriendlyName = () => "SandboxDomain",
                IsProxyCheckerInstalled         = () => true,
                IsProxyInstalledStringString    = (a, t) => true,
            };

            SharePointEnvironment.ApplicationContextProvider = context;
            string testMessage = testMessageString;
            int    testEventId = 99;
            LoggingOperationArgs loggingArgs = null;
            BSPSite site = new BSPSite();
            MSPSite s    = new MSPSite(site)
            {
                IDGet = () => TestsConstants.TestGuid
            };

            BSPContext.SetCurrent();
            MSPContext c = new MSPContext(BSPContext.Current)
            {
                SiteGet = () => site
            };

            MSPUtility.ExecuteRegisteredProxyOperationStringStringSPProxyOperationArgs = (a, t, args) =>
            {
                loggingArgs =
                    args as
                    LoggingOperationArgs;
                return(null);
            };


            //Act
            var target = new SharePointLogger();

            target.LogToOperations(testMessage, testEventId, SandboxEventSeverity.Error, TestsConstants.AreasCategories);

            // Assert
            Assert.IsNotNull(loggingArgs);
            Assert.AreEqual(loggingArgs.Message, testMessage);
            Assert.AreEqual(loggingArgs.Category, TestsConstants.AreasCategories);
            Assert.AreEqual(loggingArgs.EventId, testEventId);
            Assert.AreEqual((SandboxEventSeverity)loggingArgs.Severity, SandboxEventSeverity.Error);
        }
Exemple #9
0
        public void WriteSandboxTrace_NoContext_TracesMessage()
        {
            //Arrange
            SharePointEnvironment.Reset();
            string testMessage = testMessageString;
            int    testEventId = 99;
            TracingOperationArgs tracingArgs = null;
            BSPSite site = new BSPSite();
            MSPSite s    = new MSPSite(site)
            {
                IDGet = () => TestsConstants.TestGuid
            };

            MSPContext.CurrentGet = () => null;
            MSPUtility.ExecuteRegisteredProxyOperationStringStringSPProxyOperationArgs = (a, t, args) =>
            {
                tracingArgs =
                    args as
                    TracingOperationArgs;
                return(null);
            };

            var context = new SIApplicationContextProvider()
            {
                GetCurrentAppDomainFriendlyName = () => "SandboxDomain",
                IsProxyCheckerInstalled         = () => true,
                IsProxyInstalledStringString    = (a, t) => true,
            };

            SharePointEnvironment.ApplicationContextProvider = context;

            //Act
            var target = new SharePointLogger();

            target.TraceToDeveloper(testMessage, testEventId, SandboxTraceSeverity.High, TestsConstants.AreasCategories);

            // Assert
            Assert.IsNotNull(tracingArgs);
            Assert.AreEqual(tracingArgs.Message, testMessage);
            Assert.AreEqual(tracingArgs.Category, TestsConstants.AreasCategories);
            Assert.AreEqual(tracingArgs.EventId, testEventId);
            Assert.AreEqual((SandboxTraceSeverity)tracingArgs.Severity, SandboxTraceSeverity.High);
        }
Exemple #10
0
 public void Teardown()
 {
     SharePointEnvironment.Reset();
 }
 public void Cleanup()
 {
     SharePointServiceLocator.Reset();
     SharePointEnvironment.Reset();
 }
Exemple #12
0
 public void Teardown()
 {
     SharePointServiceLocator.Reset();
     SharePointEnvironment.Reset();
 }
Exemple #13
0
 public void Cleanup()
 {
     SharePointEnvironment.Reset();
 }