public void Execute_LogsMessage()
        {
            //Arrange
            var  args       = new LoggingOperationArgs();
            Guid createGuid = Guid.Empty;

            args.Message  = TestsConstants.TestGuidName;
            args.EventId  = -99;
            args.Category = TestsConstants.AreasCategories;
            args.Severity = (int)SandboxEventSeverity.Error;
            args.SiteID   = TestsConstants.TestGuid;

            SharePointServiceLocator.ReplaceCurrentServiceLocator(new ActivatingServiceLocator());
            ((ActivatingServiceLocator)SharePointServiceLocator.GetCurrent())
            .RegisterTypeMapping <ILogger, TestLogger>(InstantiationType.AsSingleton);

            var operation = new LoggingOperation();

            BSPFarm.SetLocal();
            MSPSite site;
            BSPWeb  bweb = new BSPWeb();
            var     mweb = new MSPWeb(bweb)
            {
                NameGet = () => "foo.bar",
            };


            MSPSite.ConstructorGuid = (instance, g) =>
            {
                site = new MSPSite(instance)
                {
                    Dispose    = () => { },
                    IDGet      = () => TestsConstants.TestGuid,
                    RootWebGet = () => mweb
                };

                createGuid = g;
            };


            //Act
            object target = operation.Execute(args);

            //Assert
            var logger = SharePointServiceLocator.GetCurrent().GetInstance <ILogger>() as TestLogger;

            Assert.AreEqual(TestsConstants.TestGuid, createGuid);
            Assert.IsTrue(logger.Message.Contains(args.Message));
            Assert.AreEqual(logger.Category, TestsConstants.AreasCategories);
            Assert.AreEqual(logger.EventId, args.EventId);
            Assert.AreEqual(logger.Severity, SandboxEventSeverity.Error);
        }
        public void Execute_WithWrongProxyArgsType_ReturnsArgumentException()
        {
            //Arrange
            var args = new TracingOperationArgs();

            args.Message  = "foobar";
            args.EventId  = -1;
            args.Category = "foobar";
            args.Severity = (int)EventSeverity.Error;
            var operation = new LoggingOperation();

            BSPFarm.SetLocal();

            //Act
            object target = operation.Execute(args);

            //Assert
            Assert.IsInstanceOfType(target, typeof(ArgumentException));
        }
        public void Execute_WithNullArguments_ThrowsArgumentNullException()
        {
            //Arrange
            var  operation = new LoggingOperation();
            bool expectedExceptionThrown = false;


            //Act
            try
            {
                operation.Execute(null);
            }
            catch (ArgumentNullException)
            {
                expectedExceptionThrown = true;
            }

            Assert.IsTrue(expectedExceptionThrown);
        }