public void Query_Select_AnonymousLiteral_ToWhere() { Execute(q => q.Select(s => new { First = 3 }).Where(f => f.First == 3), $"content=sensors&columns={UnitRequest.DefaultSensorProperties()}&count=500", s => Assert.IsTrue(s.All(e => e.First == 3))); }
public void Query_Select_Overload_TSourceIntTResult_SelectIndex() { Execute(q => q.Select((s, i) => i), $"content=sensors&columns={UnitRequest.DefaultSensorProperties()}&count=500", s => { Assert.AreEqual(0, s[0]); Assert.AreEqual(1, s[1]); Assert.AreEqual(2, s[2]); }); }
protected void ExecuteNullable <TResult>(Func <IQueryable <Sensor>, IQueryable <TResult> > func, string url, Action <SensorItem> manipulator) { var u = "content=sensors&"; if (!url.Contains("columns")) { u += $"columns={UnitRequest.DefaultSensorProperties()}"; } else { u += url; } if (url.StartsWith("filter_")) { u += "&count=500&" + url; } else { u += "&count=500"; } Execute(func, new[] { u }, s => { if (s.Count > 0) { Assert.AreEqual(3, s.Count); Assert.AreEqual(null, s[0]); Assert.AreEqual(null, s[1]); Assert.AreEqual(null, s[2]); } else { Assert.AreEqual(0, s.Count); } }, propertyManipulator: new Dictionary <Content, Action <BaseItem> > { [Content.Sensors] = i => manipulator(((SensorItem)i)) }); }
public void Query_Select_FromUnsupported_FromSupported() { Execute(q => q.Where(s => s.Active).SkipWhile((s, i) => i == 0).Select(s => s.Name), $"content=sensors&columns={UnitRequest.DefaultSensorProperties()}&count=500&filter_active=-1", s => { Assert.AreEqual("Volume IO _Total1", s[0]); Assert.AreEqual("Volume IO _Total2", s[1]); }); }