Used to fetch execution request payloads NEVER MAKE THE PROPERTIES GETTER PRIVATE AS PER SONAR THIS WILL CAUSE SIGNALR'S SERIALIZATION TO FREAK OUT AND PASS EMPTY REQUESTID VALUES THROUGH
        public void FutureReceipt_ToKey_WhenRequestIDNotSet_ExpectException()
        {
            //------------Setup for test--------------------------
            var futureReciept = new FutureReceipt { PartID = 1, User = "******" };

            //------------Execute Test---------------------------
            futureReciept.ToKey();
        }
        public void FutureReceipt_ToKey_WhenPartIDLessThenZero_ExpectException()
        {
            //------------Setup for test--------------------------
            var futureReciept = new FutureReceipt { PartID = -1, RequestID = RequestID, User = "******" };

            //------------Execute Test---------------------------
            futureReciept.ToKey();
        }
        public void FutureReceipt_ToKey_WhenValidKeyParts_ExpectKey()
        {
            //------------Setup for test--------------------------
            var futureReciept = new FutureReceipt { PartID = 1, RequestID = RequestID, User = "******" };

            //------------Execute Test---------------------------
            var result = futureReciept.ToKey();

            //------------Assert Results-------------------------
            StringAssert.Contains(result, RequestID+"-1-Bob!");
        }
Example #4
0
        public string FetchResult(FutureReceipt receipt)
        {
            if (receipt == null)
            {
                throw new ArgumentNullException("receipt");
            }

            if (!_resultCache.TryRemove(receipt.ToKey(), out string result))
            {
                result = string.Empty;
            }
            return(result);
        }
Example #5
0
        public bool AddResult(FutureReceipt receipt, string payload)
        {
            if (string.IsNullOrEmpty(payload))
            {
                throw new ArgumentNullException("payload");
            }

            if (receipt == null)
            {
                throw new ArgumentNullException("receipt");
            }

            return(_resultCache.TryAdd(receipt.ToKey(), payload));
        }
        public string FetchResult(FutureReceipt receipt)
        {
            if(receipt == null)
            {
                throw new ArgumentNullException("receipt");
            }

            string result;
            if(!_resultCache.TryRemove(receipt.ToKey(), out result))
            {
                result = string.Empty;
            }
            return result;
        }
        public bool AddResult(FutureReceipt receipt, string payload)
        {
            if(string.IsNullOrEmpty(payload))
            {
                throw new ArgumentNullException("payload");
            }

            if(receipt == null)
            {
                throw new ArgumentNullException("receipt");
            }

            return _resultCache.TryAdd(receipt.ToKey(), payload);
        }
 static FutureReceipt GenerateReciept()
 {
     var reciept = new FutureReceipt { PartID = 1, RequestID = Guid.NewGuid(), User = "******" };
     return reciept;
 }
        public void ServerAuthorizationService_IsAuthorized_RequestWhenNotAllowedButResultsPendingAndHubConnect_AuthorizationCalculatedAndNotCachedIsTrue()
        {
            //------------Setup for test--------------------------
            var securityService = new Mock<ISecurityService>();
            securityService.SetupGet(p => p.Permissions).Returns(new List<WindowsGroupPermission>());

            var authorizationService = new TestServerAuthorizationService(securityService.Object);
            var reciept = new FutureReceipt { PartID = 0, RequestID = Guid.NewGuid(), User = "******" };
            ResultsCache.Instance.AddResult(reciept, "<x>hello world</x>");

            var request = new Mock<IAuthorizationRequest>();
            request.Setup(r => r.User.Identity.Name).Returns("TestUser");

            request.Setup(r => r.User.IsInRole(It.IsAny<string>())).Returns(false);
            request.Setup(r => r.Key).Returns(new Tuple<string, string>("User", "Url"));
            request.Setup(r => r.RequestType).Returns(WebServerRequestType.HubConnect);
            request.Setup(r => r.QueryString[It.IsAny<string>()]).Returns(string.Empty);

            Assert.AreEqual(0, authorizationService.CachedRequestCount);

            //------------Execute Test---------------------------
            var result = authorizationService.IsAuthorized(request.Object);

            // Clear the cache out ;)
            ResultsCache.Instance.FetchResult(reciept);

            //------------Assert Results-------------------------
            securityService.VerifyGet(p => p.Permissions, Times.Exactly(2));
            Assert.AreEqual(0, authorizationService.CachedRequestCount);
            Assert.IsTrue(result);
        }
        public void FutureReceipt_ToKey_WhenUserNull_ExpectException()
        {
            //------------Setup for test--------------------------
            var futureReciept = new FutureReceipt { PartID = 1, RequestID = RequestID, User = null };

            //------------Execute Test---------------------------
            futureReciept.ToKey();
        }