You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
abp/modules/blogging/test/Volo.Blogging.TestBase/Volo/Blogging/BloggingTestBase.cs

34 lines
933 B

using System;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using Volo.Abp;
using Volo.Abp.Modularity;
using Volo.Abp.Users;
using Volo.Abp.Testing;
namespace Volo.Blogging
{
public abstract class BloggingTestBase<TStartupModule> : AbpIntegratedTest<TStartupModule>
where TStartupModule : IAbpModule
{
protected Guid? CurrentUserId { get; set; }
protected BloggingTestBase()
{
CurrentUserId = Guid.NewGuid();
}
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options)
{
options.UseAutofac();
}
protected override void AfterAddApplication(IServiceCollection services)
{
var currentUser = Substitute.For<ICurrentUser>();
currentUser.Id.Returns(ci => CurrentUserId);
services.AddSingleton(currentUser);
}
}
}