public void ToTraceString_NullParameters()
        {
            var req    = StubRequest.GetRequest();
            var count  = _random.Next();
            var actual = MethodInvocationStub.GetNullParametersProxyMock().ToTraceString(_serializer);

            Assert.AreEqual("MethodInvocationStub.NoParmsMethod", actual);
        }
        public void ToTraceString_NullValue()
        {
            var count          = _random.Next();
            var actual         = MethodInvocationStub.GetNullValueProxyMock(count).ToTraceString(_serializer);
            var expectedFormat = @"MethodInvocationStub.StubMethod request: [null], count: {0}";
            var expected       = string.Format(expectedFormat, count);

            Assert.AreEqual(expected, actual);
        }
        public void ToTraceString_Xml()
        {
            var req            = StubRequest.GetRequest();
            var count          = _random.Next();
            var actual         = MethodInvocationStub.GetProxyMock(req, count).ToTraceString(Serializer.Default.Xml);
            var expectedFormat = @"MethodInvocationStub.StubMethod <StubRequest xmlns=""http://schemas.datacontract.org/2004/07/Sixeyed.Caching.Tests.Stubs"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance""><CreatedOn>{0}T00:00:00Z</CreatedOn><Id>{1}</Id><Name>{2}</Name></StubRequest>_<int xmlns=""http://schemas.microsoft.com/2003/10/Serialization/"">{3}</int>";
            var expected       = string.Format(expectedFormat, req.CreatedOn.ToString("yyyy-MM-dd"), req.Id, req.Name, count);

            Assert.AreEqual(expected, actual);
        }
        public void ToTraceString()
        {
            var req            = StubRequest.GetRequest();
            var count          = _random.Next();
            var actual         = MethodInvocationStub.GetProxyMock(req, count).ToTraceString(_serializer);
            var expectedFormat = @"MethodInvocationStub.StubMethod request: {0}""Id"":{1},""Name"":""{2}"",""CreatedOn"":""{3}T00:00:00Z""{4}, count: {5}";
            var expected       = string.Format(expectedFormat, "{", req.Id, req.Name, req.CreatedOn.ToString("yyyy-MM-dd"), "}", count);

            Assert.AreEqual(expected, actual);
        }
예제 #5
0
        public void GetCacheKey_MethodInvocation()
        {
            var invocation = MethodInvocationStub.GetProxyMock();
            var key1       = CacheKeyBuilder.GetCacheKey(invocation);

            Assert.IsTrue(key1.StartsWith("MethodInvocationStub.StubMethod"));
            AssertGuid(key1, true);
            //same input should generate same key:
            var key1v2 = CacheKeyBuilder.GetCacheKey(invocation);

            Assert.AreEqual(key1, key1v2);
            //different input should generate different key:
            invocation = MethodInvocationStub.GetProxyMock();
            var key2 = CacheKeyBuilder.GetCacheKey(invocation);

            Assert.IsTrue(key2.StartsWith("MethodInvocationStub.StubMethod"));
            AssertGuid(key2, true);
            Assert.AreNotEqual(key1, key2);
        }
        public void GetMethodCallPrefix()
        {
            var prefix = MethodInvocationStub.GetProxyMock().GetMethodCallPrefix();

            Assert.AreEqual("MethodInvocationStub.StubMethod ", prefix);
        }