예제 #1
0
        public void CreateContext_AttributeUri_Wins(string attributeUriString, string configUriString, string expectedUriString)
        {
            // Arrange
            var attribute = new EasyTableAttribute
            {
                MobileAppUri = attributeUriString
            };

            var mockFactory = new Mock <IMobileServiceClientFactory>();

            mockFactory
            .Setup(f => f.CreateClient(new Uri(expectedUriString), null))
            .Returns <IMobileServiceClient>(null);

            var config = new EasyTablesConfiguration
            {
                MobileAppUri  = new Uri(configUriString),
                ClientFactory = mockFactory.Object
            };

            // Act
            EasyTableAttributeBindingProvider.CreateContext(config, attribute, null);

            // Assert
            mockFactory.VerifyAll();
        }
예제 #2
0
        public void CreateContext_AttributeKey_Wins(string attributeKey, string configKey, string expectedKey)
        {
            // Arrange
            var attribute = new EasyTableAttribute
            {
                ApiKey = attributeKey
            };

            var handler = new TestHandler();
            var config  = new EasyTablesConfiguration
            {
                MobileAppUri  = new Uri("https://someuri"),
                ApiKey        = configKey,
                ClientFactory = new TestMobileServiceClientFactory(handler)
            };

            // Act
            var context = EasyTableAttributeBindingProvider.CreateContext(config, attribute, null);

            // Assert
            // Issue a request to check the header that's being sent.
            context.Client.GetTable("Test").LookupAsync("123");

            IEnumerable <string> values = null;
            string actualKey            = null;

            if (handler.IssuedRequest.Headers.TryGetValues("ZUMO-API-KEY", out values))
            {
                actualKey = values.Single();
            }

            Assert.Equal(expectedKey, actualKey);
        }
예제 #3
0
        public void CreateContext_ResolvesNames()
        {
            // Arrange
            var resolver = new TestNameResolver();

            resolver.Values.Add("MyTableName", "TestTable");
            resolver.Values.Add("MyId", "abc123");

            var attribute = new EasyTableAttribute
            {
                TableName = "%MyTableName%",
                Id        = "%MyId%"
            };

            // Act
            var context = EasyTableAttributeBindingProvider.CreateContext(_easyTableConfig, attribute, resolver);

            // Assert
            Assert.Equal("TestTable", context.ResolvedTableName);
            Assert.Equal("abc123", context.ResolvedId);
        }