mirror of
https://github.com/dotnetcore/Util.git
synced 2026-10-24 00:15:10 +08:00
80 lines
3.0 KiB
Plaintext
80 lines
3.0 KiB
Plaintext
<%@ Template Language="C#" TargetLanguage="C#" Debug="True" Encoding="UTF-8" %>
|
|
|
|
<%@ Assembly Src="..\..\Common\Model.cs" %>
|
|
<%@ Assembly Src="..\..\Common\Extensions.cs" %>
|
|
|
|
<%@ Import Namespace="System.Collections.Generic" %>
|
|
<%@ Import Namespace="System.Linq" %>
|
|
<%@ Import Namespace="System.Text" %>
|
|
<%@ Import Namespace="System.Text.RegularExpressions" %>
|
|
<%@ Import Namespace="SchemaMapper" %>
|
|
|
|
<%@ Property Name="Entity" Type="SchemaMapper.Entity" %>
|
|
<%@ Property Name="Namespace" Type="System.String" %>
|
|
<%-- Safe类名 --%>
|
|
<% string SafeClassName = Entity.ClassName.ToSafeName(); %>
|
|
<%-- 描述 --%>
|
|
<% string Description = Entity.Description; %>
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using Xunit;
|
|
using Util;
|
|
using Util.Helpers;
|
|
using Util.Dependency;
|
|
using <%= Entity.GetNamespace(Namespace,"Domain","Models") %>;
|
|
using <%= Entity.GetNamespace(Namespace,"Domain","Repositories") %>;
|
|
using <%= string.Format("{0}.Service.Abstractions.{1}",Namespace,Entity.TableSchema) %>;
|
|
using <%= string.Format("{0}.Service.Dtos.{1}",Namespace,Entity.TableSchema) %>;
|
|
using <%= string.Format("{0}.Test.Integration.Dtos.{1}",Namespace,Entity.TableSchema) %>;
|
|
|
|
namespace <%= string.Format("{0}.Test.Integration.Services.{1}",Namespace,Entity.TableSchema) %> {
|
|
/// <summary>
|
|
/// <%= Description %>服务测试
|
|
/// </summary>
|
|
[Collection( "GlobalConfig" )]
|
|
public class <%= SafeClassName %>ServiceTest : IDisposable {
|
|
/// <summary>
|
|
/// 容器作用域
|
|
/// </summary>
|
|
private readonly IScope _scope;
|
|
/// <summary>
|
|
/// <%= Description %>服务
|
|
/// </summary>
|
|
private readonly I<%= SafeClassName %>Service <%= SafeClassName.ToFieldName() %>Service;
|
|
/// <summary>
|
|
/// <%= Description %>仓储
|
|
/// </summary>
|
|
private readonly I<%= SafeClassName %>Repository <%= SafeClassName.ToFieldName() %>Repository;
|
|
/// <summary>
|
|
/// <%= Description %>Dto
|
|
/// </summary>
|
|
private readonly <%= SafeClassName %>Dto <%= SafeClassName.ToFieldName() %>Dto;
|
|
|
|
/// <summary>
|
|
/// 测试初始化
|
|
/// </summary>
|
|
public <%= SafeClassName %>ServiceTest() {
|
|
_scope = Ioc.BeginScope();
|
|
<%= SafeClassName.ToFieldName() %>Repository = _scope.Create<I<%= SafeClassName %>Repository>();
|
|
<%= SafeClassName.ToFieldName() %>Service = _scope.Create<I<%= SafeClassName %>Service>();
|
|
<%= SafeClassName.ToFieldName() %>Dto = <%= SafeClassName %>DtoTest.Create();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 测试清理
|
|
/// </summary>
|
|
public void Dispose() {
|
|
_scope.Dispose();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 测试
|
|
/// </summary>
|
|
[Fact]
|
|
public void Test() {
|
|
var count = <%= SafeClassName.ToFieldName() %>Repository.Count();
|
|
<%= SafeClassName.ToFieldName() %>Service.Save( <%= SafeClassName.ToFieldName() %>Dto );
|
|
Assert.Equal( count + 1, <%= SafeClassName.ToFieldName() %>Repository.Count() );
|
|
}
|
|
}
|
|
} |