コード例 #1
0
        public void ClientLibraryIsCorrectlyGenerated()
        {
            var foundError = false;
            var errors     = new StringBuilder();
            var client     = new CritterClient("http://test", new HttpWebClient(new HttpClient()));

            foreach (
                var prop in
                typeof(CritterClient).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(
                    x =>
                    x.PropertyType.IsGenericType &&
                    x.PropertyType.GetGenericTypeDefinition() == typeof(ClientRepository <, ,>)))
            {
                var value = prop.GetValue(client, null);
                if (value == null)
                {
                    foundError = true;
                    errors.AppendFormat("Property {0} of generated client lib is null\r\n", prop.Name);
                }
                if (prop.GetSetMethod(true).IsPublic)
                {
                    foundError = true;
                    errors.AppendFormat("Property {0} of generated client lib has a public setter.\r\n", prop.Name);
                }
            }

            if (foundError)
            {
                Assert.Fail("Found the following errors on generated client lib: {0}\r\n", errors);
            }
        }
コード例 #2
0
        public void ClientLibraryIsCorrectlyGenerated()
        {
            var foundError = false;
            var errors = new StringBuilder();
            var client = new CritterClient("http://test", new HttpWebClient(new HttpClient()));
            foreach (
                var prop in
                    typeof(CritterClient).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(
                        x =>
                            x.PropertyType.IsGenericType
                            && x.PropertyType.GetGenericTypeDefinition() == typeof(ClientRepository<,,>)))
            {
                var value = prop.GetValue(client, null);
                if (value == null)
                {
                    foundError = true;
                    errors.AppendFormat("Property {0} of generated client lib is null\r\n", prop.Name);
                }
                if (prop.GetSetMethod(true).IsPublic)
                {
                    foundError = true;
                    errors.AppendFormat("Property {0} of generated client lib has a public setter.\r\n", prop.Name);
                }
            }

            if (foundError)
                Assert.Fail("Found the following errors on generated client lib: {0}\r\n", errors);
        }