public void AddRemoveNullEntity() { var ctxwrap = this.CreateWrappedContext <DefaultContainer>(); var context = ctxwrap.Context; DataServiceCollection <Customer> DSC = new DataServiceCollection <Customer>(context); try { DSC.Add(null); Assert.True(false, "Expected error not thrown"); } catch (InvalidOperationException e) { StringResourceUtil.VerifyDataServicesClientString(e.Message, "DataBinding_BindingOperation_ArrayItemNull", "Add"); } try { DSC.Remove(null); Assert.True(false, "Expected error not thrown"); } catch (InvalidOperationException e) { StringResourceUtil.VerifyDataServicesClientString(e.Message, "DataBinding_BindingOperation_ArrayItemNull", "Remove"); } this.EnqueueTestComplete(); }
public void HttpMergeIsNoLongerSupported() { Func <DataServiceClientRequestMessageArgs, DataServiceClientRequestMessage> addHeader = (args) => { if (args.Method == "PATCH") { // use Merge var newArgs = new DataServiceClientRequestMessageArgs("MERGE", args.RequestUri, true, args.UsePostTunneling, args.Headers); // use V4 since Merge is removed only in V4 newArgs.Headers["DataServiceVersion"] = "4.0"; return(new HttpWebRequestMessage(newArgs)); } return(new HttpWebRequestMessage(args)); }; var ctx = this.CreateContext(addHeader); Product product = null; var query = ctx.Context.Product.Take(1) as DataServiceQuery <Product>; var ar = query.BeginExecute(null, null).EnqueueWait(this); product = query.EndExecute(ar).Single(); product.Description = "New Description " + Guid.NewGuid().ToString(); ctx.UpdateObject(product); try { var ar2 = ctx.BeginSaveChanges(null, null).EnqueueWait(this); ctx.EndSaveChanges(ar2); Assert.Fail("Expected error not thrown"); } catch (DataServiceRequestException e) { #if !PORTABLELIB && !SILVERLIGHT StringResourceUtil.VerifyDataServicesClientString(e.Message, "DataServiceException_GeneralError"); #else Assert.IsNotNull(e); #endif } }