Ejemplo n.º 1
0
 public void TestInitializeMethod() {
   
   Configuration.Instance.ProbeAssemblies(typeof(Make).Assembly);
   
   var serviceName = "http://api.edmunds.com/v1/api/"; // edmunds
   _dataService = new DataService(serviceName) {HasServerMetadata = false};
   
 }
Ejemplo n.º 2
0
 public static async Task<EntityManager> NewEm(DataService dataService, MetadataStore metadataStore = null) {
   metadataStore = metadataStore ?? DefaultMetadataStore;
   if (dataService.HasServerMetadata && metadataStore.GetDataService(dataService.ServiceName) == null) {
     var em = new EntityManager(dataService.ServiceName, metadataStore);
     await em.FetchMetadata();
     return em;
   } else {
     return new EntityManager(dataService, metadataStore);
   }
 }
Ejemplo n.º 3
0
        private static EntityManager GetInitializedEntityManager()
        {
            var endpointUrl = ConfigurationManager.AppSettings["apiEndpointUrl"];
            var credentials = Convert.ToBase64String(Encoding.UTF8.GetBytes((Constants.DefaultTestUserName + "|" + Constants.DefaultTestUserPassword).ToCharArray()));

            var breezeDataService = new DataService(endpointUrl);
            breezeDataService.HttpClient.DefaultRequestHeaders.Add("Authorization", "Basic " + credentials);
            var entityManager = new EntityManager(breezeDataService);
            return entityManager;
        }
Ejemplo n.º 4
0
    public async Task HttpClientHandler() {
      var  httpClient = new HttpClient(new HttpClientHandler() {
        UseDefaultCredentials = true
      });
      var ds = new DataService(_serviceName, httpClient);
      var em = new EntityManager(ds);
      em.MetadataStore.AllowedMetadataMismatchTypes = MetadataMismatchTypes.MissingCLREntityType;
      var md = await em.FetchMetadata(ds);
      Assert.IsTrue(md != null);

    }
Ejemplo n.º 5
0
    public async Task BadURL() {

      var serviceName = "http://localhost:7150/breeze/xxxFoo";
      var ds = new DataService(serviceName);
      try {
        var ms = new MetadataStore();
        await ms.FetchMetadata(ds);
      } catch (Exception e) {
        Assert.IsTrue(e.Message.Contains("metadata resource"));
      }

      try {
        var em = new EntityManager(ds);
        await em.FetchMetadata();
      } catch (Exception e) {
        Assert.IsTrue(e.Message.Contains("metadata resource"));
      }
    }
Ejemplo n.º 6
0
    public async Task NoClrTypes() {
      
      var serviceName = "http://localhost:7150/breeze/NorthwindIBModel";
      var ds = new DataService(serviceName);
      try {
        var ms = new MetadataStore();
        await ms.FetchMetadata(ds);
      } catch (Exception e) {
        Assert.IsTrue(e.Message.Contains("Configuration.Instance"), e.Message);
      }

      try {
        var em = new EntityManager(ds);
        await em.FetchMetadata();
      }
      catch (Exception e) {
        Assert.IsTrue(e.Message.Contains("Configuration.Instance"), e.Message);
      }
    }
Ejemplo n.º 7
0
    public async Task NoClrTypes() {
      
      var serviceName = TestFns.serviceName;
      var ds = new DataService(serviceName);
      try {
        var ms = new MetadataStore();
        await ms.FetchMetadata(ds);
      } catch (Exception e) {
        Assert.IsTrue(e.Message.Contains("Configuration.Instance"), e.Message);
      }

      try {
        var em = new EntityManager(ds);
        await em.FetchMetadata();
      }
      catch (Exception e) {
        Assert.IsTrue(e.Message.Contains("Configuration.Instance"), e.Message);
      }
    }
Ejemplo n.º 8
0
 public SaveOptions(string resourceName=null, DataService dataService=null,  String tag=null) {
   ResourceName = resourceName;
   DataService = dataService;
   Tag = tag;
 }
    public async Task MetadataWithEmbeddedQuotes() {
      
      // this is a legacy service that has quoted metadata.
      var serviceName = "http://sampleservice.breezejs.com/api/todos/";
      var ds = new DataService(serviceName);

      var metadata = await ds.GetAsync("Metadata", new CancellationToken(false));

      var metadata2 = System.Text.RegularExpressions.Regex.Unescape(metadata).Trim('"');
      var jo = (JObject) JsonConvert.DeserializeObject(metadata2);
      var em = new EntityManager(ds);
      try {
        var x = await em.FetchMetadata();
        Assert.Fail("should not get here - CLR types for this metadata are not available");
      }
      catch (Exception e) {
        Assert.IsTrue(e.Message.Contains("CLR Entity"));
      }
      
    }