Created project structure and some code.

This commit is contained in:
hikalkan 2015-07-14 11:58:30 +03:00
Родитель 196289b194
Коммит 25543becaf
41 изменённых файлов: 1304 добавлений и 14 удалений

Просмотреть файл

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{167E2EB1-C7A2-4182-93E7-C64230CED65D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Abp.Samples.Blog</RootNamespace>
<AssemblyName>Abp.Samples.Blog.Application</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Abp">
<HintPath>..\packages\Abp.0.6.4.0\lib\net451\Abp.dll</HintPath>
</Reference>
<Reference Include="Abp.AutoMapper">
<HintPath>..\packages\Abp.AutoMapper.0.6.4.0\lib\net451\Abp.AutoMapper.dll</HintPath>
</Reference>
<Reference Include="Abp.Zero">
<HintPath>..\packages\Abp.Zero.0.6.4.0\lib\net451\Abp.Zero.dll</HintPath>
</Reference>
<Reference Include="AutoMapper">
<HintPath>..\packages\AutoMapper.3.3.1\lib\net40\AutoMapper.dll</HintPath>
</Reference>
<Reference Include="AutoMapper.Net4">
<HintPath>..\packages\AutoMapper.3.3.1\lib\net40\AutoMapper.Net4.dll</HintPath>
</Reference>
<Reference Include="Castle.Core">
<HintPath>..\packages\Castle.Core.3.3.3\lib\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Castle.Facilities.Logging">
<HintPath>..\packages\Castle.LoggingFacility.3.3.0\lib\net45\Castle.Facilities.Logging.dll</HintPath>
</Reference>
<Reference Include="Castle.Windsor">
<HintPath>..\packages\Castle.Windsor.3.3.0\lib\net45\Castle.Windsor.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNet.Identity.Core">
<HintPath>..\packages\Microsoft.AspNet.Identity.Core.2.2.1\lib\net45\Microsoft.AspNet.Identity.Core.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Nito.AsyncEx">
<HintPath>..\packages\Nito.AsyncEx.3.0.0\lib\net45\Nito.AsyncEx.dll</HintPath>
</Reference>
<Reference Include="Nito.AsyncEx.Concurrent">
<HintPath>..\packages\Nito.AsyncEx.3.0.0\lib\net45\Nito.AsyncEx.Concurrent.dll</HintPath>
</Reference>
<Reference Include="Nito.AsyncEx.Enlightenment">
<HintPath>..\packages\Nito.AsyncEx.3.0.0\lib\net45\Nito.AsyncEx.Enlightenment.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Collections.Immutable">
<HintPath>..\packages\Microsoft.Bcl.Immutable.1.0.34\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AbpSampleBlogCoreModule.cs" />
<Compile Include="BlogAppServiceBase.cs" />
<Compile Include="Posts\Dtos\GetPostsInput.cs" />
<Compile Include="Posts\IPostAppService.cs" />
<Compile Include="Posts\PostAppService.cs" />
<Compile Include="Posts\Dtos\PostDto.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Abp.Samples.Blog.Core\Abp.Samples.Blog.Core.csproj">
<Project>{CF891696-558F-47E4-A092-28A2565B9310}</Project>
<Name>Abp.Samples.Blog.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\AutoMapper.3.3.1\tools\AutoMapper.targets" Condition="Exists('..\packages\AutoMapper.3.3.1\tools\AutoMapper.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -0,0 +1,14 @@
using System.Reflection;
using Abp.Modules;
namespace Abp.Samples.Blog
{
[DependsOn(typeof(AbpSampleBlogCoreModule))]
public class AbpSampleBlogApplicationModule : AbpModule
{
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
}
}
}

Просмотреть файл

@ -0,0 +1,12 @@
using Abp.Application.Services;
namespace Abp.Samples.Blog
{
public abstract class BlogAppServiceBase : ApplicationService
{
protected BlogAppServiceBase()
{
//LocalizationSourceName = "AbpSampleBlog"; //TODO: Create a localization source
}
}
}

Просмотреть файл

@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations;
using Abp.Application.Services.Dto;
namespace Abp.Samples.Blog.Posts.Dtos
{
public class GetPostsInput : IPagedResultRequest
{
public const int DefaultPageSize = 10;
[Range(1, int.MaxValue)]
public int MaxResultCount { get; set; }
[Range(0, int.MaxValue)]
public int SkipCount { get; set; }
public GetPostsInput()
{
MaxResultCount = DefaultPageSize;
}
}
}

Просмотреть файл

@ -0,0 +1,21 @@
using Abp.Application.Services.Dto;
using Abp.AutoMapper;
namespace Abp.Samples.Blog.Posts.Dtos
{
[AutoMapFrom(typeof(Post))]
public class PostDto : EntityDto
{
public int CategoryId { get; set; }
public string CategoryName { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public string Tags { get; set; }
public PostStatus Status { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,11 @@
using Abp.Application.Services;
using Abp.Application.Services.Dto;
using Abp.Samples.Blog.Posts.Dtos;
namespace Abp.Samples.Blog.Posts
{
public interface IPostAppService : IApplicationService
{
PagedResultOutput<PostDto> GetPosts(GetPostsInput input);
}
}

Просмотреть файл

@ -0,0 +1,31 @@
using System.Collections.Generic;
using System.Linq;
using Abp.Application.Services.Dto;
using Abp.AutoMapper;
using Abp.Domain.Repositories;
using Abp.Linq.Extensions;
using Abp.Samples.Blog.Posts.Dtos;
namespace Abp.Samples.Blog.Posts
{
public class PostAppService : BlogAppServiceBase, IPostAppService
{
private readonly IRepository<Post> _postRepository;
public PostAppService(IRepository<Post> postRepository)
{
_postRepository = postRepository;
}
public PagedResultOutput<PostDto> GetPosts(GetPostsInput input)
{
var postCount = _postRepository.Count();
var posts = _postRepository.GetAll().OrderByDescending(p => p.CreationTime).PageBy(input);
return new PagedResultOutput<PostDto>(
postCount,
posts.MapTo<List<PostDto>>()
);
}
}
}

Просмотреть файл

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Abp.Samples.Blog.Application")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Abp.Samples.Blog.Application")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a9c6abde-35be-4de5-a7da-4461c7647054")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Abp" version="0.6.4.0" targetFramework="net451" />
<package id="Abp.AutoMapper" version="0.6.4.0" targetFramework="net451" />
<package id="Abp.Zero" version="0.6.4.0" targetFramework="net451" />
<package id="AutoMapper" version="3.3.1" targetFramework="net451" />
<package id="Castle.Core" version="3.3.3" targetFramework="net451" />
<package id="Castle.LoggingFacility" version="3.3.0" targetFramework="net451" />
<package id="Castle.Windsor" version="3.3.0" targetFramework="net451" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net451" />
<package id="Microsoft.Bcl.Immutable" version="1.0.34" targetFramework="net451" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
<package id="Nito.AsyncEx" version="3.0.0" targetFramework="net451" />
</packages>

Просмотреть файл

@ -7,7 +7,7 @@
<ProjectGuid>{CF891696-558F-47E4-A092-28A2565B9310}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Abp.Samples.Blog.Core</RootNamespace>
<RootNamespace>Abp.Samples.Blog</RootNamespace>
<AssemblyName>Abp.Samples.Blog.Core</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
@ -30,7 +30,42 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Abp">
<HintPath>..\packages\Abp.0.6.4.0\lib\net451\Abp.dll</HintPath>
</Reference>
<Reference Include="Abp.Zero">
<HintPath>..\packages\Abp.Zero.0.6.4.0\lib\net451\Abp.Zero.dll</HintPath>
</Reference>
<Reference Include="Castle.Core">
<HintPath>..\packages\Castle.Core.3.3.0\lib\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Castle.Facilities.Logging">
<HintPath>..\packages\Castle.LoggingFacility.3.3.0\lib\net45\Castle.Facilities.Logging.dll</HintPath>
</Reference>
<Reference Include="Castle.Windsor">
<HintPath>..\packages\Castle.Windsor.3.3.0\lib\net45\Castle.Windsor.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNet.Identity.Core">
<HintPath>..\packages\Microsoft.AspNet.Identity.Core.2.2.1\lib\net45\Microsoft.AspNet.Identity.Core.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Nito.AsyncEx">
<HintPath>..\packages\Nito.AsyncEx.3.0.0\lib\net45\Nito.AsyncEx.dll</HintPath>
</Reference>
<Reference Include="Nito.AsyncEx.Concurrent">
<HintPath>..\packages\Nito.AsyncEx.3.0.0\lib\net45\Nito.AsyncEx.Concurrent.dll</HintPath>
</Reference>
<Reference Include="Nito.AsyncEx.Enlightenment">
<HintPath>..\packages\Nito.AsyncEx.3.0.0\lib\net45\Nito.AsyncEx.Enlightenment.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Collections.Immutable">
<HintPath>..\packages\Microsoft.Bcl.Immutable.1.0.34\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@ -39,9 +74,26 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="AbpSampleBlogCoreModule.cs" />
<Compile Include="Categories\Category.cs" />
<Compile Include="Comments\Comment.cs" />
<Compile Include="Auth\PermissionChecker.cs" />
<Compile Include="Posts\Post.cs" />
<Compile Include="Posts\PostStatus.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Auth\BlogRole.cs" />
<Compile Include="Auth\RoleManager.cs" />
<Compile Include="Auth\RoleStore.cs" />
<Compile Include="Auth\BlogTenant.cs" />
<Compile Include="Auth\TenantManager.cs" />
<Compile Include="Auth\BlogUser.cs" />
<Compile Include="Auth\UserManager.cs" />
<Compile Include="Auth\UserStore.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

Просмотреть файл

@ -0,0 +1,15 @@
using System.Reflection;
using Abp.Modules;
using Abp.Zero;
namespace Abp.Samples.Blog
{
[DependsOn(typeof(AbpZeroCoreModule))]
public class AbpSampleBlogCoreModule : AbpModule
{
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
}
}
}

Просмотреть файл

@ -0,0 +1,9 @@
using Abp.Authorization.Roles;
namespace Abp.Samples.Blog.Auth
{
public class BlogRole : AbpRole<BlogTenant, BlogUser>
{
}
}

Просмотреть файл

@ -0,0 +1,9 @@
using Abp.MultiTenancy;
namespace Abp.Samples.Blog.Auth
{
public class BlogTenant : AbpTenant<BlogTenant, BlogUser>
{
}
}

Просмотреть файл

@ -0,0 +1,9 @@
using Abp.Authorization.Users;
namespace Abp.Samples.Blog.Auth
{
public class BlogUser : AbpUser<BlogTenant, BlogUser>
{
}
}

Просмотреть файл

@ -0,0 +1,13 @@
using Abp.Authorization;
namespace Abp.Samples.Blog.Auth
{
public class PermissionChecker : PermissionChecker<BlogTenant, BlogRole, BlogUser>
{
public PermissionChecker(UserManager userManager)
: base(userManager)
{
}
}
}

Просмотреть файл

@ -0,0 +1,23 @@
using Abp.Authorization;
using Abp.Authorization.Roles;
using Abp.Domain.Uow;
using Abp.Zero.Configuration;
namespace Abp.Samples.Blog.Auth
{
public class RoleManager : AbpRoleManager<BlogTenant, BlogRole, BlogUser>
{
public RoleManager(
RoleStore store,
IPermissionManager permissionManager,
IRoleManagementConfig roleManagementConfig,
IUnitOfWorkManager unitOfWorkManager)
: base(
store,
permissionManager,
roleManagementConfig,
unitOfWorkManager)
{
}
}
}

Просмотреть файл

@ -0,0 +1,20 @@
using Abp.Authorization.Roles;
using Abp.Authorization.Users;
using Abp.Domain.Repositories;
namespace Abp.Samples.Blog.Auth
{
public class RoleStore : AbpRoleStore<BlogTenant, BlogRole, BlogUser>
{
public RoleStore(
IRepository<BlogRole> roleRepository,
IRepository<UserRole, long> userRoleRepository,
IRepository<RolePermissionSetting, long> rolePermissionSettingRepository)
: base(
roleRepository,
userRoleRepository,
rolePermissionSettingRepository)
{
}
}
}

Просмотреть файл

@ -0,0 +1,14 @@
using Abp.Domain.Repositories;
using Abp.MultiTenancy;
namespace Abp.Samples.Blog.Auth
{
public class TenantManager : AbpTenantManager<BlogTenant, BlogRole, BlogUser>
{
public TenantManager(IRepository<BlogTenant> tenantRepository)
: base(tenantRepository)
{
}
}
}

Просмотреть файл

@ -0,0 +1,37 @@
using Abp.Authorization;
using Abp.Authorization.Users;
using Abp.Configuration;
using Abp.Configuration.Startup;
using Abp.Dependency;
using Abp.Domain.Repositories;
using Abp.Domain.Uow;
using Abp.Zero.Configuration;
namespace Abp.Samples.Blog.Auth
{
public class UserManager : AbpUserManager<BlogTenant, BlogRole, BlogUser>
{
public UserManager(
UserStore store,
RoleManager roleManager,
IRepository<BlogTenant> tenantRepository,
IMultiTenancyConfig multiTenancyConfig,
IPermissionManager permissionManager,
IUnitOfWorkManager unitOfWorkManager,
ISettingManager settingManager,
IUserManagementConfig userManagementConfig,
IIocResolver iocResolver)
: base(
store,
roleManager,
tenantRepository,
multiTenancyConfig,
permissionManager,
unitOfWorkManager,
settingManager,
userManagementConfig,
iocResolver)
{
}
}
}

Просмотреть файл

@ -0,0 +1,29 @@
using Abp.Authorization.Users;
using Abp.Domain.Repositories;
using Abp.Domain.Uow;
using Abp.Runtime.Session;
namespace Abp.Samples.Blog.Auth
{
public class UserStore : AbpUserStore<BlogTenant, BlogRole, BlogUser>
{
public UserStore(
IRepository<BlogUser, long> userRepository,
IRepository<UserLogin, long> userLoginRepository,
IRepository<UserRole, long> userRoleRepository,
IRepository<BlogRole> roleRepository,
IRepository<UserPermissionSetting, long> userPermissionSettingRepository,
IAbpSession session,
IUnitOfWorkManager unitOfWorkManager)
: base(
userRepository,
userLoginRepository,
userRoleRepository,
roleRepository,
userPermissionSettingRepository,
session,
unitOfWorkManager)
{
}
}
}

Просмотреть файл

@ -0,0 +1,10 @@
using Abp.Domain.Entities.Auditing;
using Abp.Samples.Blog.Auth;
namespace Abp.Samples.Blog.Categories
{
public class Category : CreationAuditedEntity<int, BlogUser>
{
public virtual string Name { get; set; }
}
}

Просмотреть файл

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Abp.Samples.Blog.Core
{
public class Class1
{
}
}

Просмотреть файл

@ -0,0 +1,10 @@
using Abp.Domain.Entities.Auditing;
using Abp.Samples.Blog.Auth;
namespace Abp.Samples.Blog.Comments
{
public class Comment : CreationAuditedEntity<int, BlogUser>
{
public virtual string Content { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,22 @@
using System.ComponentModel.DataAnnotations.Schema;
using Abp.Domain.Entities.Auditing;
using Abp.Samples.Blog.Auth;
using Abp.Samples.Blog.Categories;
namespace Abp.Samples.Blog.Posts
{
public class Post : FullAuditedEntity<int, BlogUser>
{
[ForeignKey("CategoryId")]
public virtual Category Category { get; set; }
public virtual int CategoryId { get; set; }
public virtual string Title { get; set; }
public virtual string Content { get; set; }
public virtual string Tags { get; set; }
public virtual PostStatus Status { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,8 @@
namespace Abp.Samples.Blog.Posts
{
public enum PostStatus : byte
{
Draft = 0,
Published = 1
}
}

Просмотреть файл

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Abp" version="0.6.4.0" targetFramework="net451" />
<package id="Abp.Zero" version="0.6.4.0" targetFramework="net451" />
<package id="Castle.Core" version="3.3.0" targetFramework="net451" />
<package id="Castle.LoggingFacility" version="3.3.0" targetFramework="net451" />
<package id="Castle.Windsor" version="3.3.0" targetFramework="net451" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net451" />
<package id="Microsoft.Bcl.Immutable" version="1.0.34" targetFramework="net451" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
<package id="Nito.AsyncEx" version="3.0.0" targetFramework="net451" />
</packages>

Просмотреть файл

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{737125E6-9615-4734-B6A7-9771843BC2FD}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Abp.Samples.Blog.EntityFramework</RootNamespace>
<AssemblyName>Abp.Samples.Blog.EntityFramework</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Abp">
<HintPath>..\packages\Abp.0.6.3.1\lib\net451\Abp.dll</HintPath>
</Reference>
<Reference Include="Abp.EntityFramework">
<HintPath>..\packages\Abp.EntityFramework.0.6.3.1\lib\net451\Abp.EntityFramework.dll</HintPath>
</Reference>
<Reference Include="Abp.Zero">
<HintPath>..\packages\Abp.Zero.0.6.4.0\lib\net451\Abp.Zero.dll</HintPath>
</Reference>
<Reference Include="Abp.Zero.EntityFramework">
<HintPath>..\packages\Abp.Zero.EntityFramework.0.6.4.0\lib\net451\Abp.Zero.EntityFramework.dll</HintPath>
</Reference>
<Reference Include="Castle.Core">
<HintPath>..\packages\Castle.Core.3.3.0\lib\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Castle.Facilities.Logging">
<HintPath>..\packages\Castle.LoggingFacility.3.3.0\lib\net45\Castle.Facilities.Logging.dll</HintPath>
</Reference>
<Reference Include="Castle.Windsor">
<HintPath>..\packages\Castle.Windsor.3.3.0\lib\net45\Castle.Windsor.dll</HintPath>
</Reference>
<Reference Include="EntityFramework">
<HintPath>..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.DynamicFilters">
<HintPath>..\packages\EntityFramework.DynamicFilters.1.3.15\lib\net40\EntityFramework.DynamicFilters.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer">
<HintPath>..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.AspNet.Identity.Core">
<HintPath>..\packages\Microsoft.AspNet.Identity.Core.2.2.1\lib\net45\Microsoft.AspNet.Identity.Core.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Nito.AsyncEx">
<HintPath>..\packages\Nito.AsyncEx.3.0.0\lib\net45\Nito.AsyncEx.dll</HintPath>
</Reference>
<Reference Include="Nito.AsyncEx.Concurrent">
<HintPath>..\packages\Nito.AsyncEx.3.0.0\lib\net45\Nito.AsyncEx.Concurrent.dll</HintPath>
</Reference>
<Reference Include="Nito.AsyncEx.Enlightenment">
<HintPath>..\packages\Nito.AsyncEx.3.0.0\lib\net45\Nito.AsyncEx.Enlightenment.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Collections.Immutable">
<HintPath>..\packages\Microsoft.Bcl.Immutable.1.0.34\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AbpZeroSampleDbContext.cs" />
<Compile Include="AbpSampleBlogEntityFrameworkModule.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Abp.Samples.Blog.Core\Abp.Samples.Blog.Core.csproj">
<Project>{CF891696-558F-47E4-A092-28A2565B9310}</Project>
<Name>Abp.Samples.Blog.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -0,0 +1,15 @@
using System.Reflection;
using Abp.Modules;
using Abp.Zero.EntityFramework;
namespace Abp.Samples.Blog.EntityFramework
{
[DependsOn(typeof(AbpZeroEntityFrameworkModule), typeof(AbpSampleBlogCoreModule))]
public class AbpSampleBlogEntityFrameworkModule : AbpModule
{
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
}
}
}

Просмотреть файл

@ -0,0 +1,47 @@
using System.Data.Common;
using System.Data.Entity;
using Abp.Samples.Blog.Auth;
using Abp.Samples.Blog.Categories;
using Abp.Samples.Blog.Comments;
using Abp.Samples.Blog.Posts;
using Abp.Zero.EntityFramework;
namespace Abp.Samples.Blog.EntityFramework
{
public class SampleBlogDbContext : AbpZeroDbContext<BlogTenant, BlogRole, BlogUser>
{
public IDbSet<Post> Posts { get; set; }
public IDbSet<Category> Categories { get; set; }
public IDbSet<Comment> Comments { get; set; }
/* NOTE:
* Setting "Default" to base class helps us when working migration commands on Package Manager Console.
* But it may cause problems when working Migrate.exe of EF. If you will apply migrations on command line, do not
* pass connection string name to base classes. ABP works either way.
*/
public SampleBlogDbContext()
: base("Default")
{
}
/* NOTE:
* This constructor is used by ABP to pass connection string defined in AbpProjectNameDataModule.PreInitialize.
* Notice that, actually you will not directly create an instance of AbpProjectNameDbContext since ABP automatically handles it.
*/
public SampleBlogDbContext(string nameOrConnectionString)
: base(nameOrConnectionString)
{
}
//This constructor is used in tests
public SampleBlogDbContext(DbConnection connection)
: base(connection, true)
{
}
}
}

Просмотреть файл

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>

Просмотреть файл

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Abp.Samples.Blog.EntityFramework")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Abp.Samples.Blog.EntityFramework")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("bd80a08c-bf2f-4f13-b01a-0c7fa730ce4f")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Abp" version="0.6.3.1" targetFramework="net451" />
<package id="Abp.EntityFramework" version="0.6.3.1" targetFramework="net451" />
<package id="Abp.Zero" version="0.6.4.0" targetFramework="net451" />
<package id="Abp.Zero.EntityFramework" version="0.6.4.0" targetFramework="net451" />
<package id="Castle.Core" version="3.3.0" targetFramework="net451" />
<package id="Castle.LoggingFacility" version="3.3.0" targetFramework="net451" />
<package id="Castle.Windsor" version="3.3.0" targetFramework="net451" />
<package id="EntityFramework" version="6.1.1" targetFramework="net451" />
<package id="EntityFramework.DynamicFilters" version="1.3.15" targetFramework="net451" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net451" />
<package id="Microsoft.Bcl.Immutable" version="1.0.34" targetFramework="net451" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
<package id="Nito.AsyncEx" version="3.0.0" targetFramework="net451" />
</packages>

Просмотреть файл

@ -0,0 +1,156 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\xunit.runner.visualstudio.2.0.1\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.0.1\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0FD1B299-9019-4572-B106-902C2AD3DC93}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Abp.Samples.Blog.Tests</RootNamespace>
<AssemblyName>Abp.Samples.Blog.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>18351bfd</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Abp">
<HintPath>..\packages\Abp.0.6.3.1\lib\net451\Abp.dll</HintPath>
</Reference>
<Reference Include="Abp.EntityFramework">
<HintPath>..\packages\Abp.EntityFramework.0.6.3.1\lib\net451\Abp.EntityFramework.dll</HintPath>
</Reference>
<Reference Include="Abp.TestBase">
<HintPath>..\packages\Abp.TestBase.0.2.0.0\lib\net451\Abp.TestBase.dll</HintPath>
</Reference>
<Reference Include="Abp.Zero">
<HintPath>..\packages\Abp.Zero.0.6.4.0\lib\net451\Abp.Zero.dll</HintPath>
</Reference>
<Reference Include="Abp.Zero.EntityFramework">
<HintPath>..\packages\Abp.Zero.EntityFramework.0.6.4.0\lib\net451\Abp.Zero.EntityFramework.dll</HintPath>
</Reference>
<Reference Include="Castle.Core">
<HintPath>..\packages\Castle.Core.3.3.0\lib\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Castle.Facilities.Logging">
<HintPath>..\packages\Castle.LoggingFacility.3.3.0\lib\net45\Castle.Facilities.Logging.dll</HintPath>
</Reference>
<Reference Include="Castle.Windsor">
<HintPath>..\packages\Castle.Windsor.3.3.0\lib\net45\Castle.Windsor.dll</HintPath>
</Reference>
<Reference Include="Effort">
<HintPath>..\packages\Effort.EF6.1.1.4\lib\net45\Effort.dll</HintPath>
</Reference>
<Reference Include="EntityFramework">
<HintPath>..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.DynamicFilters">
<HintPath>..\packages\EntityFramework.DynamicFilters.1.3.15\lib\net40\EntityFramework.DynamicFilters.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer">
<HintPath>..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNet.Identity.Core">
<HintPath>..\packages\Microsoft.AspNet.Identity.Core.2.2.1\lib\net45\Microsoft.AspNet.Identity.Core.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Nito.AsyncEx">
<HintPath>..\packages\Nito.AsyncEx.3.0.0\lib\net45\Nito.AsyncEx.dll</HintPath>
</Reference>
<Reference Include="Nito.AsyncEx.Concurrent">
<HintPath>..\packages\Nito.AsyncEx.3.0.0\lib\net45\Nito.AsyncEx.Concurrent.dll</HintPath>
</Reference>
<Reference Include="Nito.AsyncEx.Enlightenment">
<HintPath>..\packages\Nito.AsyncEx.3.0.0\lib\net45\Nito.AsyncEx.Enlightenment.dll</HintPath>
</Reference>
<Reference Include="NMemory">
<HintPath>..\packages\NMemory.1.0.1\lib\net45\NMemory.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Collections.Immutable">
<HintPath>..\packages\Microsoft.Bcl.Immutable.1.0.34\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="xunit.abstractions">
<HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
</Reference>
<Reference Include="xunit.assert">
<HintPath>..\packages\xunit.assert.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.assert.dll</HintPath>
</Reference>
<Reference Include="xunit.core">
<HintPath>..\packages\xunit.extensibility.core.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Data\BlogTestDataBuilder.cs" />
<Compile Include="Data\DefaultTenantRoleAndUserBuilder.cs" />
<Compile Include="Posts\PostAppService_Tests.cs" />
<Compile Include="SampleBlogTestBase.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Abp.Samples.Blog.Application\Abp.Samples.Blog.Application.csproj">
<Project>{167E2EB1-C7A2-4182-93E7-C64230CED65D}</Project>
<Name>Abp.Samples.Blog.Application</Name>
</ProjectReference>
<ProjectReference Include="..\Abp.Samples.Blog.Core\Abp.Samples.Blog.Core.csproj">
<Project>{CF891696-558F-47E4-A092-28A2565B9310}</Project>
<Name>Abp.Samples.Blog.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Abp.Samples.Blog.EntityFramework\Abp.Samples.Blog.EntityFramework.csproj">
<Project>{737125E6-9615-4734-B6A7-9771843BC2FD}</Project>
<Name>Abp.Samples.Blog.EntityFramework</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props'))" />
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.0.1\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.0.1\build\net20\xunit.runner.visualstudio.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>

Просмотреть файл

@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Abp.MultiTenancy;
using Abp.Samples.Blog.Auth;
using Abp.Samples.Blog.Categories;
using Abp.Samples.Blog.EntityFramework;
using Abp.Samples.Blog.Posts;
namespace Abp.Samples.Blog.Tests.Data
{
public class BlogTestDataBuilder
{
private readonly SampleBlogDbContext _context;
public BlogTestDataBuilder(SampleBlogDbContext context)
{
_context = context;
}
public void Build()
{
CreateCategories();
CreatePosts();
}
private void CreateCategories()
{
_context.Categories.Add(new Category { Name = "Programming" });
_context.Categories.Add(new Category { Name = "Design" });
_context.SaveChanges();
}
private void CreatePosts()
{
var admin = _context.Users.Single(u => u.TenantId == 1 && u.UserName == BlogUser.AdminUserName);
//TODO: ...
//_context.Posts.Add(new Post
// {
// });
}
}
}

Просмотреть файл

@ -0,0 +1,98 @@
using System.Linq;
using Abp.Authorization.Users;
using Abp.Samples.Blog.Auth;
using Abp.Samples.Blog.EntityFramework;
namespace Abp.Samples.Blog.Tests.Data
{
public class DefaultTenantRoleAndUserBuilder
{
private readonly SampleBlogDbContext _context;
public DefaultTenantRoleAndUserBuilder(SampleBlogDbContext context)
{
_context = context;
}
public void Build()
{
CreateUserAndRoles();
}
private void CreateUserAndRoles()
{
//Admin role for tenancy owner
var adminRoleForTenancyOwner = _context.Roles.FirstOrDefault(r => r.TenantId == null && r.Name == "Admin");
if (adminRoleForTenancyOwner == null)
{
adminRoleForTenancyOwner = _context.Roles.Add(new BlogRole { Name = "Admin", DisplayName = "Admin" });
_context.SaveChanges();
}
//Admin user for tenancy owner
var adminUserForTenancyOwner = _context.Users.FirstOrDefault(u => u.TenantId == null && u.UserName == "admin");
if (adminUserForTenancyOwner == null)
{
adminUserForTenancyOwner = _context.Users.Add(
new BlogUser
{
TenantId = null,
UserName = "admin",
Name = "System",
Surname = "Administrator",
EmailAddress = "admin@aspnetboilerplate.com",
IsEmailConfirmed = true,
Password = "AM4OLBpptxBYmM79lGOX9egzZk3vIQU3d/gFCJzaBjAPXzYIK3tQ2N7X4fcrHtElTw==" //123qwe
});
_context.SaveChanges();
_context.UserRoles.Add(new UserRole(adminUserForTenancyOwner.Id, adminRoleForTenancyOwner.Id));
_context.SaveChanges();
}
//Default tenant
var defaultTenant = _context.Tenants.FirstOrDefault(t => t.TenancyName == "Default");
if (defaultTenant == null)
{
defaultTenant = _context.Tenants.Add(new BlogTenant { TenancyName = "Default", Name = "Default" });
_context.SaveChanges();
}
//Admin role for 'Default' tenant
var adminRoleForDefaultTenant = _context.Roles.FirstOrDefault(r => r.TenantId == defaultTenant.Id && r.Name == "Admin");
if (adminRoleForDefaultTenant == null)
{
adminRoleForDefaultTenant = _context.Roles.Add(new BlogRole { TenantId = defaultTenant.Id, Name = "Admin", DisplayName = "Admin" });
_context.SaveChanges();
}
//Admin for 'Default' tenant
var adminUserForDefaultTenant = _context.Users.FirstOrDefault(u => u.TenantId == defaultTenant.Id && u.UserName == "admin");
if (adminUserForDefaultTenant == null)
{
adminUserForDefaultTenant = _context.Users.Add(
new BlogUser
{
TenantId = defaultTenant.Id,
UserName = "admin",
Name = "System",
Surname = "Administrator",
EmailAddress = "admin@aspnetboilerplate.com",
IsEmailConfirmed = true,
Password = "AM4OLBpptxBYmM79lGOX9egzZk3vIQU3d/gFCJzaBjAPXzYIK3tQ2N7X4fcrHtElTw==" //123qwe
});
_context.SaveChanges();
_context.UserRoles.Add(new UserRole(adminUserForDefaultTenant.Id, adminRoleForDefaultTenant.Id));
_context.SaveChanges();
}
}
}
}

Просмотреть файл

@ -0,0 +1,22 @@
using Abp.Samples.Blog.Posts;
using Abp.Samples.Blog.Posts.Dtos;
using Xunit;
namespace Abp.Samples.Blog.Tests.Posts
{
public class PostAppService_Tests : SampleBlogTestBase
{
private readonly IPostAppService _postAppService;
public PostAppService_Tests()
{
_postAppService = Resolve<IPostAppService>();
}
[Fact]
public void Should_Get_Posts()
{
var posts = _postAppService.GetPosts(new GetPostsInput());
}
}
}

Просмотреть файл

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Abp.Samples.Blog.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Abp.Samples.Blog.Tests")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("0785a393-830f-4139-8d6e-748a787bb9d4")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Text;
using System.Threading.Tasks;
using Abp.Collections;
using Abp.Modules;
using Abp.Samples.Blog.EntityFramework;
using Abp.Samples.Blog.Tests.Data;
using Abp.TestBase;
using Castle.MicroKernel.Registration;
using EntityFramework.DynamicFilters;
namespace Abp.Samples.Blog.Tests
{
public abstract class SampleBlogTestBase : AbpIntegratedTestBase
{
protected SampleBlogTestBase()
{
//Fake DbConnection using Effort!
LocalIocManager.IocContainer.Register(
Component.For<DbConnection>()
.UsingFactoryMethod(Effort.DbConnectionFactory.CreateTransient)
.LifestyleSingleton()
);
//Seed initial data
UsingDbContext(context => new DefaultTenantRoleAndUserBuilder(context).Build());
UsingDbContext(context => new BlogTestDataBuilder(context).Build());
}
protected override void AddModules(ITypeList<AbpModule> modules)
{
base.AddModules(modules);
//Adding testing modules. Depended modules of these modules are automatically added.
modules.Add<AbpSampleBlogApplicationModule>();
modules.Add<AbpSampleBlogEntityFrameworkModule>();
}
public void UsingDbContext(Action<SampleBlogDbContext> action)
{
using (var context = LocalIocManager.Resolve<SampleBlogDbContext>())
{
context.DisableAllFilters();
action(context);
context.SaveChanges();
}
}
public T UsingDbContext<T>(Func<SampleBlogDbContext, T> func)
{
T result;
using (var context = LocalIocManager.Resolve<SampleBlogDbContext>())
{
context.DisableAllFilters();
result = func(context);
context.SaveChanges();
}
return result;
}
}
}

Просмотреть файл

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Abp" version="0.6.3.1" targetFramework="net451" />
<package id="Abp.EntityFramework" version="0.6.3.1" targetFramework="net451" />
<package id="Abp.TestBase" version="0.2.0.0" targetFramework="net451" />
<package id="Abp.Zero" version="0.6.4.0" targetFramework="net451" />
<package id="Abp.Zero.EntityFramework" version="0.6.4.0" targetFramework="net451" />
<package id="Castle.Core" version="3.3.0" targetFramework="net451" />
<package id="Castle.LoggingFacility" version="3.3.0" targetFramework="net451" />
<package id="Castle.Windsor" version="3.3.0" targetFramework="net451" />
<package id="Effort.EF6" version="1.1.4" targetFramework="net451" />
<package id="EntityFramework" version="6.1.1" targetFramework="net451" />
<package id="EntityFramework.DynamicFilters" version="1.3.15" targetFramework="net451" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net451" />
<package id="Microsoft.Bcl.Immutable" version="1.0.34" targetFramework="net451" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
<package id="Nito.AsyncEx" version="3.0.0" targetFramework="net451" />
<package id="NMemory" version="1.0.1" targetFramework="net451" />
<package id="xunit" version="2.0.0" targetFramework="net451" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net451" />
<package id="xunit.assert" version="2.0.0" targetFramework="net451" />
<package id="xunit.core" version="2.0.0" targetFramework="net451" />
<package id="xunit.extensibility.core" version="2.0.0" targetFramework="net451" />
<package id="xunit.runner.visualstudio" version="2.0.1" targetFramework="net451" />
</packages>

Просмотреть файл

@ -5,6 +5,14 @@ VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Abp.Samples.Blog.Core", "Abp.Samples.Blog.Core\Abp.Samples.Blog.Core.csproj", "{CF891696-558F-47E4-A092-28A2565B9310}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Abp.Samples.Blog.EntityFramework", "Abp.Samples.Blog.EntityFramework\Abp.Samples.Blog.EntityFramework.csproj", "{737125E6-9615-4734-B6A7-9771843BC2FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Abp.Samples.Blog.Application", "Abp.Samples.Blog.Application\Abp.Samples.Blog.Application.csproj", "{167E2EB1-C7A2-4182-93E7-C64230CED65D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{40A07535-F28A-4A61-8462-A139B3D499DF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Abp.Samples.Blog.Tests", "Abp.Samples.Blog.Tests\Abp.Samples.Blog.Tests.csproj", "{0FD1B299-9019-4572-B106-902C2AD3DC93}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -15,8 +23,23 @@ Global
{CF891696-558F-47E4-A092-28A2565B9310}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF891696-558F-47E4-A092-28A2565B9310}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF891696-558F-47E4-A092-28A2565B9310}.Release|Any CPU.Build.0 = Release|Any CPU
{737125E6-9615-4734-B6A7-9771843BC2FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{737125E6-9615-4734-B6A7-9771843BC2FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{737125E6-9615-4734-B6A7-9771843BC2FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{737125E6-9615-4734-B6A7-9771843BC2FD}.Release|Any CPU.Build.0 = Release|Any CPU
{167E2EB1-C7A2-4182-93E7-C64230CED65D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{167E2EB1-C7A2-4182-93E7-C64230CED65D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{167E2EB1-C7A2-4182-93E7-C64230CED65D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{167E2EB1-C7A2-4182-93E7-C64230CED65D}.Release|Any CPU.Build.0 = Release|Any CPU
{0FD1B299-9019-4572-B106-902C2AD3DC93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0FD1B299-9019-4572-B106-902C2AD3DC93}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0FD1B299-9019-4572-B106-902C2AD3DC93}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0FD1B299-9019-4572-B106-902C2AD3DC93}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0FD1B299-9019-4572-B106-902C2AD3DC93} = {40A07535-F28A-4A61-8462-A139B3D499DF}
EndGlobalSection
EndGlobal