e0e362d700
SDK Tests / changes (push) Successful in 2m29s
Real E2E Tests / changes (push) Successful in 2m29s
Deploy Docs Pages / build (push) Has been cancelled
Deploy Docs Pages / deploy (push) Has been cancelled
Real E2E Tests / JavaScript E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Python E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Java E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / C# E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Go E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Real E2E CI (push) Has been cancelled
SDK Tests / SDK CI (push) Has been cancelled
SDK Tests / CLI Tests (push) Has been cancelled
SDK Tests / Python SDK Quality (code-interpreter) (push) Has been cancelled
SDK Tests / Python SDK Quality (sandbox) (push) Has been cancelled
SDK Tests / Python SDK Tests (code-interpreter) (push) Has been cancelled
SDK Tests / JavaScript SDK Quality And Tests (code-interpreter) (push) Has been cancelled
SDK Tests / JavaScript SDK Quality And Tests (sandbox) (push) Has been cancelled
SDK Tests / Python SDK Tests (sandbox) (push) Has been cancelled
SDK Tests / CLI Quality (push) Has been cancelled
SDK Tests / Kotlin SDK Quality And Tests (sandbox) (push) Has been cancelled
SDK Tests / Kotlin SDK Quality And Tests (code-interpreter) (push) Has been cancelled
SDK Tests / C# SDK Quality And Tests (code-interpreter) (push) Has been cancelled
SDK Tests / C# SDK Quality And Tests (sandbox) (push) Has been cancelled
SDK Tests / Go SDK Quality And Tests (push) Has been cancelled
94 lines
3.5 KiB
C#
94 lines
3.5 KiB
C#
// Copyright 2026 Alibaba Group Holding Ltd.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
using OpenSandbox.CodeInterpreter.Factory;
|
|
using OpenSandbox.Core;
|
|
using OpenSandbox;
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
using Xunit;
|
|
|
|
namespace OpenSandbox.CodeInterpreter.Tests;
|
|
|
|
public class FactoryTests
|
|
{
|
|
[Fact]
|
|
public void DefaultCodeInterpreterAdapterFactory_Create_ReturnsInstance()
|
|
{
|
|
var factory = DefaultCodeInterpreterAdapterFactory.Create();
|
|
|
|
Assert.NotNull(factory);
|
|
Assert.IsType<DefaultCodeInterpreterAdapterFactory>(factory);
|
|
}
|
|
|
|
[Fact]
|
|
public void DefaultCodeInterpreterAdapterFactory_CreateCodes_ThrowsOnNullOptions()
|
|
{
|
|
var factory = DefaultCodeInterpreterAdapterFactory.Create();
|
|
|
|
Assert.Throws<InvalidArgumentException>(() => factory.CreateCodes(null!));
|
|
}
|
|
|
|
[Fact]
|
|
public void DefaultCodeInterpreterAdapterFactory_CreateCodes_ThrowsOnNullConnectionConfig()
|
|
{
|
|
var factory = DefaultCodeInterpreterAdapterFactory.Create();
|
|
var options = new CreateCodesStackOptions
|
|
{
|
|
ConnectionConfig = null!,
|
|
ExecdBaseUrl = "http://localhost:44772",
|
|
ExecdHeaders = new Dictionary<string, string>(),
|
|
HttpClientProvider = new HttpClientProvider(new OpenSandbox.Config.ConnectionConfig(), NullLoggerFactory.Instance),
|
|
LoggerFactory = NullLoggerFactory.Instance
|
|
};
|
|
|
|
Assert.Throws<InvalidArgumentException>(() => factory.CreateCodes(options));
|
|
}
|
|
|
|
[Fact]
|
|
public void DefaultCodeInterpreterAdapterFactory_CreateCodes_ThrowsOnEmptyBaseUrl()
|
|
{
|
|
var factory = DefaultCodeInterpreterAdapterFactory.Create();
|
|
|
|
var options = new CreateCodesStackOptions
|
|
{
|
|
ConnectionConfig = new OpenSandbox.Config.ConnectionConfig(),
|
|
ExecdBaseUrl = "",
|
|
ExecdHeaders = new Dictionary<string, string>(),
|
|
HttpClientProvider = new HttpClientProvider(new OpenSandbox.Config.ConnectionConfig(), NullLoggerFactory.Instance),
|
|
LoggerFactory = NullLoggerFactory.Instance
|
|
};
|
|
|
|
Assert.Throws<InvalidArgumentException>(() => factory.CreateCodes(options));
|
|
}
|
|
|
|
[Fact]
|
|
public void CreateCodesStackOptions_RequiredProperties()
|
|
{
|
|
var options = new CreateCodesStackOptions
|
|
{
|
|
ConnectionConfig = new OpenSandbox.Config.ConnectionConfig(),
|
|
ExecdBaseUrl = "http://test:8080",
|
|
ExecdHeaders = new Dictionary<string, string> { ["X-Test"] = "value" },
|
|
HttpClientProvider = new HttpClientProvider(new OpenSandbox.Config.ConnectionConfig(), NullLoggerFactory.Instance),
|
|
LoggerFactory = NullLoggerFactory.Instance
|
|
};
|
|
|
|
Assert.NotNull(options.ConnectionConfig);
|
|
Assert.Equal("http://test:8080", options.ExecdBaseUrl);
|
|
Assert.Equal("value", options.ExecdHeaders["X-Test"]);
|
|
Assert.NotNull(options.HttpClientProvider);
|
|
Assert.NotNull(options.LoggerFactory);
|
|
}
|
|
}
|