public void Test_Injection_WithoutServiceProvider() { PageDescriptor page = this.locator.FindPage("InjectedQuery", typeof(MiscAccessor)); ProcEngine engine = new ProcEngine(null); Should.Throw <NotSupportedException>(() => engine.Proc(page, new ProcArgs(typeof(object), typeof(object)))(null)); }
internal static Stream BuilderHeaderBuffer(CatalogStatus status, CatalogFormat format, DateTime update, DateTime persist, params Page[] pages) { var mStream = new MemoryStream(new byte[MaxHeaderSize]); using (var binWriter = new BinaryWriter(mStream, Encoding, true)) { binWriter.Write(update.Ticks); binWriter.Write(persist.Ticks); binWriter.Write((byte)status); binWriter.Write((byte)format); binWriter.Write(pages.Length); if (pages != null && pages.Length > 0) { // with pages (Type) in reverse order create PageDescriptor array var pageTypes = pages.Reverse() .SelectMany(p => { var pgDescr = PageDescriptor.Create(new byte[] { 1 }); pgDescr.Write(0, () => (byte)p.Type); return((byte[])pgDescr); }) .ToArray(); binWriter.Seek(-pageTypes.Length, SeekOrigin.End); binWriter.Write(pageTypes, 0, pageTypes.Length); } } return(mStream); }
public PagedList <T> QueryPaged(IExecuteContext <T> context) { this.CurrentContext = context; Page <T> result = null; if (null != context.PagingInfo) { PageDescriptor p = context.PagingInfo; result = DataBase.Page <T>(p.PageNumber, p.PageSize, GetExecuteContainer()); } else { result = DataBase.Page <T>(1, context.TopCount > 0 ? context.TopCount : MaxSearchCount, GetExecuteContainer()); } return(new PagedList <T> { CurrentPage = result.CurrentPage , Items = result.Items , ItemsPerPage = result.ItemsPerPage , TotalItems = result.TotalItems , TotalPages = result.TotalPages }); }
public void FindPage_WithRelativePath_ReturnsExpectedPage() { PageDescriptor page = this.FindPage("../Queries/Locator/SubFolder1/./SubFolder2/../../LocatorQuery2"); page.ShouldNotBeNull(); page.PageType.ShouldBe(typeof(Conventions.Queries.Locator.LocatorQuery2_cssql)); }
public void FindPage_WithAbsolutePath_ReturnsExpectedPage() { PageDescriptor page = this.FindPage("/Jerrycurl/Mvc/Test/Conventions/Queries/Locator/LocatorQuery2.cssql"); page.ShouldNotBeNull(); page.PageType.ShouldBe(typeof(Conventions.Queries.Locator.LocatorQuery2_cssql)); }
public void FindPage_WithDomainPath_ReturnsExpectedPage() { PageDescriptor page = this.FindPage("~/Queries/Locator/LocatorQuery2.cssql"); page.ShouldNotBeNull(); page.PageType.ShouldBe(typeof(Conventions.Queries.Locator.LocatorQuery2_cssql)); }
public void SqlBuffer_Batching_HasCorrectValue() { PageDescriptor page = this.locator.FindPage("../Commands/Batching/BatchedCommand.cssql", typeof(LocatorAccessor)); ProcFactory factory = this.engine.Proc(page, new ProcArgs(typeof(object), typeof(object))); IProcResult result = factory(null); ISqlSerializer <CommandData> serializer = result.Buffer as ISqlSerializer <CommandData>; IList <CommandData> batchedBySql = serializer.Serialize(new SqlOptions() { MaxSql = 1 }).ToList(); IList <CommandData> batchedByParams = serializer.Serialize(new SqlOptions() { MaxParameters = 2 }).ToList(); IList <CommandData> notBatched = serializer.Serialize(new SqlOptions()).ToList(); batchedBySql.ShouldNotBeNull(); batchedByParams.ShouldNotBeNull(); notBatched.ShouldNotBeNull(); batchedBySql.Count.ShouldBe(20); batchedByParams.Count.ShouldBe(10); notBatched.Count.ShouldBe(1); string joinedSql = string.Join("", batchedBySql.Select(d => d.CommandText)); string joinedParams = string.Join("", batchedByParams.Select(d => d.CommandText)); notBatched.First().CommandText.ShouldBe(joinedSql); notBatched.First().CommandText.ShouldBe(joinedParams); }
public void FindPage_FromPage_ReturnsExpectedPage() { PageDescriptor query = this.FindPage("LocatorQuery4", typeof(Conventions.Queries.Locator.LocatorQuery2_cssql)); PageDescriptor command = this.FindPage("LocatorCommand3", typeof(Conventions.Commands.Locator.LocatorCommand1_cssql)); query.PageType.ShouldBe(typeof(Conventions.Queries.LocatorQuery4_cssql)); command.PageType.ShouldBe(typeof(Conventions.Commands.LocatorCommand3_cssql)); }
public void FindPage_InSharedFolder_ReturnsExpectedPage() { PageDescriptor query = this.FindPage("LocatorQuery3"); PageDescriptor command = this.FindPage("LocatorCommand2"); query.PageType.ShouldBe(typeof(Conventions.Queries.Shared.LocatorQuery3_cssql)); command.PageType.ShouldBe(typeof(Conventions.Commands.Shared.LocatorCommand2_cssql)); }
public ProcContext(PageDescriptor descriptor, IDomainOptions domain) { this.Locator = descriptor.Locator; this.Domain = domain; this.Renderer = new ProcRenderer(this); this.Lookup = new ProcLookup(); this.Stack = new ProcExecutionStack(); }
public void ConfigurePartitions( ) { var partitions = new byte[] { 1, sizeof(long) }; var pgDescr = PageDescriptor.Create(partitions: partitions); Assert.AreEqual(2, pgDescr.Partitions.Count); Assert.AreEqual(1, pgDescr.Partitions[0]); Assert.AreEqual(sizeof(long), pgDescr.Partitions[1]); }
public void Test_ProjectionAndInjection_WithServiceProvider() { PageDescriptor page = this.locator.FindPage("DiQuery", typeof(DiAccessor)); ProcEngine engine = new ProcEngine(this.GetServiceProvider()); ISqlContent result = engine.Proc(page, new ProcArgs(typeof(object), typeof(object)))(null).Buffer.ReadToEnd(); result.Text.ShouldBe("SOMEVALUE+PROJ"); }
public void Page_WithResultObject_CanConvertFromAnyType() { PageDescriptor descriptor = this.FindPage("LocatorQuery2"); ProcArgs args1 = new ProcArgs(typeof(object), typeof(int)); ProcArgs args2 = new ProcArgs(typeof(object), typeof(string)); this.engine.Proc(descriptor, args1).ShouldNotBeNull(); this.engine.Proc(descriptor, args2).ShouldNotBeNull(); }
public void Page_IfExists_ReturnsFactory() { PageDescriptor descriptor = this.FindPage("LocatorQuery2"); ProcArgs args = new ProcArgs(typeof(int), typeof(object)); ProcFactory factory = this.engine.Proc(descriptor, args); factory.ShouldNotBeNull(); }
public void Test_Projection_WithoutServiceProvider() { PageDescriptor page = this.locator.FindPage("ProjectedQuery", typeof(MiscAccessor)); ProcEngine engine = new ProcEngine(null); ISqlContent result = engine.Proc(page, new ProcArgs(typeof(object), typeof(object)))(null).Buffer.ReadToEnd(); result.Text.ShouldBe("PROJEXISTS"); }
public void Proc_IfNoDomainAssociated_ThrowsExpectedException() { PageDescriptor descriptor = this.locator.FindPage("NoDomainQuery", typeof(NoDomainAccessor)); ProcArgs args = new ProcArgs(typeof(object), typeof(object)); descriptor.ShouldNotBeNull(); descriptor.DomainType.ShouldBeNull(); Should.Throw <ProcExecutionException>(() => this.engine.Proc(descriptor, args)); }
public void NullPageDescriptor( ) { // creates a null page descriptor var pgDescr = new PageDescriptor(); Assert.AreEqual(PageDescriptor.Null, pgDescr); Assert.AreEqual(0, PageDescriptor.Null.GetHashCode()); Assert.AreEqual(0, pgDescr.GetHashCode()); // null descriptor has null partition collection Assert.IsNull(PageDescriptor.Null.Partitions); }
public void EmptyPageDescriptor( ) { var expEmpty = PageDescriptor.Create(new byte[] { 0 }).Fill(255); Assert.AreEqual(expEmpty, PageDescriptor.Empty); Assert.AreEqual(-1450246159, PageDescriptor.Empty.GetHashCode()); Assert.AreNotEqual(PageDescriptor.Null, PageDescriptor.Empty); // empty descriptor has 1 partition of 0 length Assert.AreEqual(1, PageDescriptor.Empty.Partitions.Count); Assert.AreEqual(0, PageDescriptor.Empty.Partitions[0]); }
public string Sql <TModel, TResult>(Runnable <TModel, TResult> model) { IProcLocator locator = this.Context?.Locator ?? new ProcLocator(); IProcEngine engine = this.Context?.Engine ?? new ProcEngine(null); PageDescriptor descriptor = locator.FindPage("Query", this.GetType()); ProcArgs args = new ProcArgs(typeof(Runnable <TModel, TResult>), typeof(List <TResult>)); ProcFactory factory = engine.Proc(descriptor, args); return(factory(model).Buffer.ReadToEnd().Text.Trim()); }
public void Page_CanResolveFactory_WithoutDomain() { PageDescriptor descriptor = this.locator.FindPage("NoDomainQuery", typeof(NoDomainAccessor)); ProcArgs args = new ProcArgs(typeof(object), typeof(object)); descriptor.ShouldNotBeNull(); descriptor.DomainType.ShouldBeNull(); PageFactory factory = Should.NotThrow(() => this.engine.Page(descriptor.PageType)); factory.ShouldNotBeNull(); }
public TileGridItem( PageDescriptor descriptor, double width = 150, double height = 150, bool useMDL2 = false ) { UseIcon = true; Icon = (useMDL2) ? descriptor.Tag : descriptor.Icon; IconFontFamily = new FontFamily(useMDL2 ? SegoeMDL2FontFamily : DefaultFontFamily); Title = descriptor.Title; Data = descriptor; }
public async Task Handle_GetAllModelsFromEntityByPageQuery_Test() { using (var scope = this.provider.CreateScope()) { var mediator = scope.ServiceProvider.GetRequiredService <IMediator>(); var pageDescriptor = new PageDescriptor() { Take = 1 }; var request = new GetAllModelsFromEntityByPageQuery <Model, Entity, int, EntityDbContext>(pageDescriptor); var result = await mediator.HandleAsync(request, default); Assert.NotNull(result); } }
public ProcCacheKey(PageDescriptor descriptor, ProcArgs args) { if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } if (args == null) { throw new ArgumentNullException(nameof(args)); } this.PageType = descriptor.PageType; this.ModelType = args.ModelType; this.ResultType = args.ResultType; }
public static void WriteHandler(IndentedTextWriter writer, PageDescriptor page) { writer.Write($"public string {page.PageHandler}("); CodeGenerator.WriteMethodParameters(writer, page.Parameters); writer.WriteLine(")"); writer.WriteLine("{"); writer.Indent++; CodeGenerator.WriteRouteValues(writer, page.Parameters, new Dictionary <string, object> { ["area"] = page.Area.Name, ["handler"] = page.PageHandler }); writer.WriteLine($@"return urlHelper.Page(""{page.Name}"", __routeValues);"); writer.Indent--; writer.WriteLine("}\n"); }
public void ReadWritePartition( ) { var expType = PageType.Master; var expDate = DateTime.UtcNow; var partitions = new byte[] { 1, sizeof(long) }; var pgDescr = PageDescriptor.Create(partitions: partitions); // this will store a PageType enum value and a time stamp in partions 0, 1 respective pgDescr.Write(0, () => (byte)expType); pgDescr.Write(1, () => BitConverter.GetBytes(expDate.Ticks)); var actType = pgDescr.Read(0, b => (PageType)b); var actDate = pgDescr.Read(1, b => new DateTime(BitConverter.ToInt64(b, 0))); Assert.AreEqual(expType, actType); Assert.AreEqual(expDate, actDate); }
public void FindPage_InSubFolder_ReturnsExpectedPage() { PageDescriptor query = this.FindPage("SubFolder1/SubFolder2/LocatorQuery1"); query.PageType.ShouldBe(typeof(Conventions.Queries.Locator.SubFolder1.SubFolder2.LocatorQuery1_cssql)); }
public void FindPage_CaseInsensitive_ReturnsExpectedPage() { PageDescriptor query = this.FindPage("locatorquery2"); query.PageType.ShouldBe(typeof(Conventions.Queries.Locator.LocatorQuery2_cssql)); }
public NavBarDataItem(PageDescriptor descriptor) { Content = descriptor.Title; Icon = descriptor.Tag; PageName = descriptor.Type.FullName; }