示例#1
0
        public void PerfmonContainer_Ctor_WrappedMethods()
        {
            var cont = new Cont();

            //------------Setup for test--------------------------
            var perfmonContainer = new PerfmonExecutionContainer(cont);

            //------------Execute Test---------------------------
            perfmonContainer.Execute(out ErrorResultTO err, 3);
            //------------Assert Results-------------------------
            Assert.AreEqual(1, cont.CallCount);
            Assert.AreEqual(perfmonContainer.InstanceInputDefinition, "bob");
            Assert.AreEqual(perfmonContainer.InstanceOutputDefinition, "dave");
            var counter = CustomContainer.Get <IWarewolfPerformanceCounterLocater>().GetCounter(WarewolfPerfCounterType.RequestsPerSecond).FromSafe();;

            var po = new PrivateObject(counter);

            po.Invoke("Setup", new object[0]);
            var innerCounter = po.GetField("_counter") as PerformanceCounter;

            Assert.IsNotNull(innerCounter);
            Assert.AreNotEqual(0, innerCounter.RawValue);

            counter = CustomContainer.Get <IWarewolfPerformanceCounterLocater>().GetCounter(WarewolfPerfCounterType.AverageExecutionTime).FromSafe();

            po = new PrivateObject(counter);
            po.Invoke("Setup", new object[0]);
            innerCounter = po.GetField("_counter") as PerformanceCounter;
            Assert.IsNotNull(innerCounter);
            Assert.AreNotEqual(0, innerCounter.RawValue);
        }
示例#2
0
        private IEsbExecutionContainer GenerateContainer(ServiceAction serviceAction, IDSFDataObject dataObj, IWorkspace theWorkspace)
        {
            // set the ID for later use ;)
            dataObj.WorkspaceID = _workspace.ID;

            IEsbExecutionContainer result = null;

            if (dataObj.IsServiceTestExecution)
            {
                result = new ServiceTestExecutionContainer(serviceAction, dataObj, _workspace, _esbChannel, _request);
            }
            else
            {
                switch (serviceAction.ActionType)
                {
                case enActionType.InvokeManagementDynamicService:
                    result = new InternalServiceContainer(serviceAction, dataObj, theWorkspace, _esbChannel, _request);
                    break;

                case enActionType.InvokeWebService:
                    result = new WebServiceContainer(serviceAction, dataObj, theWorkspace, _esbChannel);
                    break;

                case enActionType.Workflow:
                    result = new PerfmonExecutionContainer(new WfExecutionContainer(serviceAction, dataObj, theWorkspace, _esbChannel));
                    break;

                case enActionType.RemoteService:
                    result = new RemoteWorkflowExecutionContainer(serviceAction, dataObj, null, _esbChannel);
                    break;
                }
            }
            return(result);
        }
示例#3
0
        public void PerfmonContainer_Ctor_ValidArg_No_Error()
        {
            var cont = new Mock <IEsbExecutionContainer>();
            //------------Setup for test--------------------------
            var perfmonContainer = new PerfmonExecutionContainer(cont.Object);

            //------------Execute Test---------------------------

            //------------Assert Results-------------------------
            Assert.AreEqual(perfmonContainer.Container, cont.Object);
        }
示例#4
0
        public void PerfmonContainer_Ctor_WrappedMethods()
        {
            var cont = new Cont();
            var mockPerformanceCounter  = new Mock <IWarewolfPerformanceCounter>();
            var mockPerformanceCounter2 = new Mock <IWarewolfPerformanceCounter>();
            var mockPerformanceCounter3 = new Mock <IWarewolfPerformanceCounter>();
            var mockPerformanceCounter4 = new Mock <IWarewolfPerformanceCounter>();

            _mockPerformanceCounterFactory.Setup(o => o.New(GlobalConstants.Warewolf, It.IsAny <string>(), GlobalConstants.GlobalCounterName)).Throws(new Exception("no other counters expected to be created"));
            _mockPerformanceCounterFactory.Setup(o => o.New(GlobalConstants.Warewolf, "Request Per Second", GlobalConstants.GlobalCounterName)).Returns(mockPerformanceCounter.Object);
            _mockPerformanceCounterFactory.Setup(o => o.New(GlobalConstants.Warewolf, "Concurrent requests currently executing", GlobalConstants.GlobalCounterName)).Returns(mockPerformanceCounter2.Object);
            _mockPerformanceCounterFactory.Setup(o => o.New(GlobalConstants.Warewolf, "Average workflow execution time", GlobalConstants.GlobalCounterName)).Returns(mockPerformanceCounter3.Object);
            _mockPerformanceCounterFactory.Setup(o => o.New(GlobalConstants.Warewolf, "average time per operation base", GlobalConstants.GlobalCounterName)).Returns(mockPerformanceCounter4.Object);

            //------------Setup for test--------------------------
            var perfmonContainer = new PerfmonExecutionContainer(cont);

            //------------Execute Test---------------------------
            perfmonContainer.Execute(out ErrorResultTO err, 3);
            //------------Assert Results-------------------------
            Assert.AreEqual(1, cont.CallCount);
            Assert.AreEqual(perfmonContainer.InstanceInputDefinition, "bob");
            Assert.AreEqual(perfmonContainer.InstanceOutputDefinition, "dave");
            var counter = _performanceCounterLocater.GetCounter(WarewolfPerfCounterType.RequestsPerSecond).FromSafe();

            _mockPerformanceCounterFactory.Verify(o => o.New(GlobalConstants.Warewolf, "Request Per Second", GlobalConstants.GlobalCounterName), Times.Once);
            _mockPerformanceCounterFactory.Verify(o => o.New(GlobalConstants.Warewolf, "Concurrent requests currently executing", GlobalConstants.GlobalCounterName), Times.Once);
            _mockPerformanceCounterFactory.Verify(o => o.New(GlobalConstants.Warewolf, "Average workflow execution time", GlobalConstants.GlobalCounterName), Times.Once);
            _mockPerformanceCounterFactory.Verify(o => o.New(GlobalConstants.Warewolf, "average time per operation base", GlobalConstants.GlobalCounterName), Times.Once);
            mockPerformanceCounter.Verify(o => o.Increment(), Times.Once);
            mockPerformanceCounter2.Verify(o => o.Increment(), Times.Once);
            mockPerformanceCounter3.Verify(o => o.IncrementBy(It.IsAny <long>()), Times.Once);
            mockPerformanceCounter4.Verify(o => o.Increment(), Times.Once);

            counter = _performanceCounterLocater.GetCounter(WarewolfPerfCounterType.AverageExecutionTime).FromSafe();
        }
示例#5
0
 public void PerfmonContainer_Ctor_InValidArg_Has_Error()
 {
     var cont = new Mock <IEsbExecutionContainer>();
     //------------Setup for test--------------------------
     var perfmonContainer = new PerfmonExecutionContainer(null);
 }