Zaria.Calabash.DevHost
2.6.7
dotnet add package Zaria.Calabash.DevHost --version 2.6.7
NuGet\Install-Package Zaria.Calabash.DevHost -Version 2.6.7
<PackageReference Include="Zaria.Calabash.DevHost" Version="2.6.7" />
<PackageVersion Include="Zaria.Calabash.DevHost" Version="2.6.7" />
<PackageReference Include="Zaria.Calabash.DevHost" />
paket add Zaria.Calabash.DevHost --version 2.6.7
#r "nuget: Zaria.Calabash.DevHost, 2.6.7"
#:package Zaria.Calabash.DevHost@2.6.7
#addin nuget:?package=Zaria.Calabash.DevHost&version=2.6.7
#tool nuget:?package=Zaria.Calabash.DevHost&version=2.6.7
Instructions
Version 2.0.0
===========================
In the latest build the individual Startxxxx methods have been consolidated into
one method that will start the dev hosting environment as a Blazor app. While it can techically
be started from a console, you will need to configure the project SDK as a web project
Microsoft.NET.Sdk.Web.
The following code demonstrates using it in this way
var configuration = new ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddEnvironmentVariables()
.AddCommandLine(args)
.Build();
var host = new CalabashDevHost();
await host.InitializeAI<SampleHost>(new HostSettings
{
AIDeploymentName = "<The deployment name>",
AIEndpoint = "<The AI endpoing>",
AIKey = "<The AI key>",
LogCategory = "<A string for the log category you want>",
Username = "<anything you want to tbe passed as the username>",
BasePath = "api",
Configuration = builder.Configuration,
SessionID = <A guid to represent the session id>,
Profile = new Zaria.Calabash.Data.UserProfile
{
User = new Zaria.Calabash.Data.User
{
FirstName = "<Anything you want to be passed as the first name>",
LastName = "<Anything you want to be passed as the last name>",
},
EffectiveRoles = "<The roles you want to emulate>"
},
});
host.StartCalabashHost();
Note that to get this to work properly you will have to add a blank .razor file to the console project. This file
does not need to contain anything but is needed to properly run the devhost.
A much better approach is to simply create a new blazor application and use it as the devhost. The following steps demonstrate the approach.
- Create a blazor application
- Add a reference to this nuget package
- Delete the
wwwrootand any blazor related items like theComponentsfolder from the project. LeaveProgram.csandappsettings.json - Reference the calabash .NET plugin you want to test
- In
Program.csremove all the blazor configuration boilerplate except forvar builder = WebApplication.CreateBuilder(args); - Now add the following code
// Add services to the container.
await builder.RunCalabash<SampleHost>(new HostSettings
{
AIDeploymentName = "<The deployment name>",
AIEndpoint = "<The AI endpoing>",
AIKey = "<The AI key>",
LogCategory = "<A string for the log category you want>",
Username = "<anything you want to tbe passed as the username>",
BasePath = "api",
Configuration = builder.Configuration,
SessionID = <A guid to represent the session id>,
Profile = new Zaria.Calabash.Data.UserProfile
{
User = new Zaria.Calabash.Data.User
{
FirstName = "<Anything you want to be passed as the first name>",
LastName = "<Anything you want to be passed as the last name>",
},
EffectiveRoles = "<The roles you want to emulate>"
},
});
SampleHost here represents the SolutionHost from the plugin library.
This method allows you to test all scenarios in a real world manner. A web page
is opened that points to an isolated instance of Calabash. You have access to the
chatbox in the Calabash dashboard, your time triggered jobs run as background workers,
and your http triggered workers can be called via rest.
Version 1.*
===========================
To use this dev host do th following:
- Create a console applicaiton
- Reference the calabash .NET plugin you want to test
- Create a new instance of the
CalabashDevHostclass - Call
InitializeAIpassing in a class that inherits fromSolutionHostas the type argument and a populatedHostSettingsargument - Call
StartREPLto start a REPL loop for testing your AI skills - To test your HTTP triggers you can alternatively call
StartHTTP - To test your time triggered workers you can alternatively call
StartBackgroundWorker
The following sample code illustrates:
namespace Calabash.AgentTestHarness
{
internal class Program
{
async static Task Main(string[] args)
{
var host = new CalabashDevHost();
await host.InitializeAI<SampleHost>(new HostSettings
{
AIDeploymentName = "<ai deployment name>",
AIEndpoint = "<ai url>",
AIKey = "<ai key>",
LogCategory = "test",
Username = "<some email>",
HttpListenPort = 5000,
BasePath = "/api",
});
//await host.StartHTTP(); //Starts an http listener that can be used to test your http triggers
//await host.StartREPL(); //Starts a console repl for testing your AI skills
//await host.StartBackgroundWorker(); //Starts background workers for testing your time triggers.
}
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Markdig.Signed (>= 1.1.3)
- Microsoft.AspNetCore.Components.QuickGrid (>= 10.0.7)
- Microsoft.Extensions.Logging (>= 10.0.8)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Logging.Console (>= 10.0.8)
- OpenTelemetry.Api (>= 1.15.3)
- Radzen.Blazor (>= 10.3.1)
- Zaria.AI (>= 2.6.5)
- Zaria.AI.AspNetCore (>= 2.6.5)
- Zaria.Calabash.Library (>= 2.6.5)
- Zaria.Core (>= 2.6.5)
- Zaria.Data (>= 2.6.5)
- Zaria.IUI (>= 2.6.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.