我有一个 Android 应用程序,它使用 Android Mobile Vision API 来识别文本 (OCR)。但是,安装该应用程序的设备未安装 Google Play 服务。
我想知道是否可以仅安装 Mobile Vision API 或 ML Kit,而不安装 Google Play 服务。
操作系统:棒棒糖
android xamarin google-play-services google-vision firebase-mlkit
通过 Azure DevOps / VSTS,已设置计划的构建每天在特定时间运行,例如下午 13 点。
但是,失败的计划构建不会发送电子邮件通知。当构建是手动启动或由代码更改触发时,它会这样做。
如何在计划构建失败时启用电子邮件通知?
我有一个方法,其操作依赖于其依赖,如下所示.做单元测试仍然有价值吗?因为单元测试不是测试任何业务逻辑,而是测试模拟.
单元测试如下:
请注意,方法的操作expectedCustomerValidality由测试确定,由测试设置.大多数情况下,逻辑是由模拟决定的(例如Setup(c => c.IsValid()).
[Test]
[TestCase(true)]
[TestCase(false)]
public void AddCustomer(bool expectedCustomerValidality)
{
//using Moq
companyRepositoryMock.Setup(c => c.GetById(It.IsAny<int>())).Returns(new Company());
customerValidatorMock.Setup(c => c.IsValid(It.IsAny<Customer>())).Returns(expectedCustomerValidality);
var customer = new Customer
{
Firstname = "firstName",
Surname = "surname",
Company = new Company { Id = 1 }
};
var addCustomer = customerServiceSut.AddCustomer(customer);
Assert.AreEqual(expectedCustomerValidality,addCustomer);
}
Run Code Online (Sandbox Code Playgroud)
生产代码如下:
public class CustomerService : ICustomerService
{
private ICompanyRepository companyRepository;
private ICustomerRepository customerRepository;
private ICustomerValidator customerValidator;
public CustomerService(ICompanyRepository companyRepository, ICustomerRepository customerRepository, ICustomerValidator customerValidator)
{
this.companyRepository = …Run Code Online (Sandbox Code Playgroud) 我遵循了 hello world 示例表单IOptionsSnapshot,但在文件config.json更改和保存后内容不会刷新。
我的开发环境:
1.VS 2017
2 .csproj 文件如下
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>UsingOptions</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>UsingOptions</PackageId>
<RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion>
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Options" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
下面是来自IOptionsSnapshot的代码
config.json:
{
"Time": { …Run Code Online (Sandbox Code Playgroud) 我是 Dapper 的新手,想知道为什么在我的代码在没有它的情况下运行时会建议以下建议?
Dapper 支持 varchar 参数,如果您使用参数在 varchar 列上执行 where 子句,请确保以这种方式传递它:
Run Code Online (Sandbox Code Playgroud)Query<Thing>("select * from Thing where Name = @Name", new {Name = new DbString { Value = "abcde", IsFixedLength = true, Length = 10, IsAnsi = true });在 SQL Server 上,查询 unicode 时使用 unicode 和查询非 unicode 时使用 ansi 至关重要。
下面是我的代码,它在不使用 DbString 等的情况下针对 SQL Server 2012 运行。
create table Author (
Id int identity(1,1),
FirstName varchar(50),
LastName varchar(50)
);
go
insert into Author (FirstName, LastName) values ('Tom', …Run Code Online (Sandbox Code Playgroud) 我尝试验证使用异步Put()和Commit()使用下面的代码的速度。问题是它的速度比仅使用 asyncPut()或Commit()only 慢十倍,这是没有意义的。
我在这里错过了什么吗?
class AsyncProducerWithCommit
{
private MQQueueManager _queueManager;
private MQQueue _queue;
public void Run()
{
Produce();
}
void Produce()
{
Open(ConnectionMode.Write);
PutMessage(ConvertMessageToByte(message));
_queue.Close();
_queueManager.Disconnect();
}
void PutMessage(byte[] messageString)
{
MQMessage _message = new MQMessage();
_message.Write(messageString);
_message.Format = MQC.MQFMT_STRING;
_message.CharacterSet = 1208;// IbmUtf8Encoding;
_message.Persistence = MQC.MQPER_PERSISTENT;
var putMessageOptions = new MQPutMessageOptions();
putMessageOptions.Options = MQC.MQPMO_SYNCPOINT //unit of work
+ MQC.MQPMO_ASYNC_RESPONSE; //async
_queue.Put(_message, putMessageOptions); //send message asynchronously
_queueManager.Commit();
}
void Open(ConnectionMode connectionMode)
{ …Run Code Online (Sandbox Code Playgroud) 我有一个通过 Portal 创建的功能应用程序,另一个由 Visual Studio 创建。后一个导致两个应用程序都变为只读,并显示以下消息:
您的应用程序当前处于只读模式,因为您已发布生成的 function.json。Functions 运行时不会支持对 function.json 所做的更改
这个功能正确吗?
对比:15.8.5
我在使一个API控制器调用同一项目中的另一个API控制器时遇到问题。
具体来说,集成项目能够调用生产项目中的控制器,并且该控制器将再次调用同一项目中的虚拟控制器,但是第一个控制器因内部服务器错误而失败。
但是,第一个控制器可以调用google.com。
请注意,当通过控制台或Windows服务托管生产项目时,它可以工作。仅在集成项目中的测试运行时才会发生。
生产项目是一个ASP.NET CORE Web API项目v2.1,集成测试项目是通过xUnit v2.1,请按照以下步骤进行操作
https://docs.microsoft.com/zh-cn/aspnet/core/test/integration-tests?view=aspnetcore-2.2
与xUnit的集成项目如下:
public class RetryPolicyTests: IClassFixture<WebApplicationFactory<Startup>>
{
private readonly WebApplicationFactory<Startup> _factory;
public RetryPolicyTests(WebApplicationFactory<Startup> factory)
{
_factory = factory;
}
[Theory]
[InlineData("http://localhost:1234/api/v1/Book/")]
public async Task Test(string url)
{
// Arrange
var client = _factory.CreateClient();
// Act
var body = "{}";
using (var content = new StringContent(body, Encoding.UTF8, "application/json"))
{
var response = await client.PostAsync(url, content);
// Assert
response.EnsureSuccessStatusCode(); //Failed here with internal server error
Assert.Equal(StatusCodes.Status200OK,
(int) (response.StatusCode));
}
}
}
Run Code Online (Sandbox Code Playgroud)
BookController
[ApiVersion("1")] …Run Code Online (Sandbox Code Playgroud) 我想知道HttpClientFactory或类似产品是否可用于Azure Functions v2。
下面是推荐的内容,但是未显示HttpClientFactory或类似内容。
// Create a single, static HttpClient
private static HttpClient httpClient = new HttpClient();
public static async Task Run(string input)
{
var response = await httpClient.GetAsync("https://example.com");
// Rest of function
}
Run Code Online (Sandbox Code Playgroud)
https://docs.microsoft.com/zh-CN/azure/azure-functions/manage-connections
以下是一个很好的链接,但是我不确定它是否可以在生产中使用,或者是否提供正式功能。
https://www.tpeczek.com/2018/12/alternative-approach-to-httpclient-in.html
更新:
要解决的问题
1提供托管的HttpClient池而不是单个HttpClient,例如ASP.NET CORE 2.2中的HttpClientFactory
Azure应用程序见解或日志分析的用例是什么?
我正在使用APIM和Azure函数,并希望对请求执行日志记录。哪一种是最合适的,应用程序见解或日志分析?
https://docs.microsoft.com/zh-CN/azure/azure-monitor/overview
更新资料
特别是,有关用于APIM的Azure应用程序见解与日志分析的任何信息?
azure azure-application-insights azure-functions azure-log-analytics
c# ×5
azure ×3
asp.net-core ×2
.net-core ×1
android ×1
azure-devops ×1
boolean ×1
dapper ×1
double ×1
ibm-mq ×1
unit-testing ×1
xamarin ×1