Added initial data and test passed.

This commit is contained in:
hikalkan 2015-07-14 13:28:20 +03:00
Родитель f609ba2a7b
Коммит 5b15ad59ac
6 изменённых файлов: 37 добавлений и 14 удалений

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

@ -83,7 +83,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AbpSampleBlogCoreModule.cs" /> <Compile Include="AbpSampleBlogApplicationModule.cs" />
<Compile Include="BlogAppServiceBase.cs" /> <Compile Include="BlogAppServiceBase.cs" />
<Compile Include="Posts\Dtos\GetPostsInput.cs" /> <Compile Include="Posts\Dtos\GetPostsInput.cs" />
<Compile Include="Posts\IPostAppService.cs" /> <Compile Include="Posts\IPostAppService.cs" />

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

@ -1,9 +1,10 @@
using System.Reflection; using System.Reflection;
using Abp.AutoMapper;
using Abp.Modules; using Abp.Modules;
namespace Abp.Samples.Blog namespace Abp.Samples.Blog
{ {
[DependsOn(typeof(AbpSampleBlogCoreModule))] [DependsOn(typeof(AbpSampleBlogCoreModule), typeof(AbpAutoMapperModule))]
public class AbpSampleBlogApplicationModule : AbpModule public class AbpSampleBlogApplicationModule : AbpModule
{ {
public override void Initialize() public override void Initialize()

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

@ -88,6 +88,9 @@
<Reference Include="NMemory"> <Reference Include="NMemory">
<HintPath>..\packages\NMemory.1.0.1\lib\net45\NMemory.dll</HintPath> <HintPath>..\packages\NMemory.1.0.1\lib\net45\NMemory.dll</HintPath>
</Reference> </Reference>
<Reference Include="Shouldly">
<HintPath>..\packages\Shouldly.2.5.0\lib\net40\Shouldly.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Collections.Immutable"> <Reference Include="System.Collections.Immutable">
<HintPath>..\packages\Microsoft.Bcl.Immutable.1.0.34\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath> <HintPath>..\packages\Microsoft.Bcl.Immutable.1.0.34\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>

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

@ -1,9 +1,4 @@
using System; using System.Linq;
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.Auth;
using Abp.Samples.Blog.Categories; using Abp.Samples.Blog.Categories;
using Abp.Samples.Blog.EntityFramework; using Abp.Samples.Blog.EntityFramework;
@ -36,14 +31,34 @@ namespace Abp.Samples.Blog.Tests.Data
private void CreatePosts() private void CreatePosts()
{ {
var admin = _context.Users.Single(u => u.TenantId == 1 && u.UserName == BlogUser.AdminUserName); const int defaultTenantId = 1;
//TODO: ... var adminUser = _context.Users.Single(u => u.TenantId == defaultTenantId && u.UserName == BlogUser.AdminUserName);
var programmingCategory = _context.Categories.Single(c => c.Name == "Programming");
//_context.Posts.Add(new Post _context.Posts.Add(
// { new Post
{
// }); CategoryId = programmingCategory.Id,
Title = "Introduction to ASP.NET Boilerplate",
Content = "ASP.NET Boilerplate is a starting point for new modern web applications using best practices and most popular tools. It's aimed to be a solid model, a general-purpose application framework and a project template.",
Status = PostStatus.Published,
Tags = "domain driven design",
CreatorUserId = adminUser.Id
});
_context.Posts.Add(
new Post
{
CategoryId = programmingCategory.Id,
Title = "Unit testing in C# using xUnit, Entity Framework, Effort and ASP.NET Boilerplate.",
Content = "Implemented unit and integration tests on ASP.NET Boilerplate framework using xUnit, Entity Framework, Effort and Shouldly. See http://www.codeproject.com/Articles/871786/Unit-testing-in-Csharp-using-xUnit-Entity-Framewor for details...",
Status = PostStatus.Published,
Tags = "domain driven design",
CreatorUserId = adminUser.Id
});
_context.SaveChanges();
} }
} }
} }

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

@ -1,5 +1,6 @@
using Abp.Samples.Blog.Posts; using Abp.Samples.Blog.Posts;
using Abp.Samples.Blog.Posts.Dtos; using Abp.Samples.Blog.Posts.Dtos;
using Shouldly;
using Xunit; using Xunit;
namespace Abp.Samples.Blog.Tests.Posts namespace Abp.Samples.Blog.Tests.Posts
@ -17,6 +18,8 @@ namespace Abp.Samples.Blog.Tests.Posts
public void Should_Get_Posts() public void Should_Get_Posts()
{ {
var posts = _postAppService.GetPosts(new GetPostsInput()); var posts = _postAppService.GetPosts(new GetPostsInput());
posts.TotalCount.ShouldBe(2);
posts.Items.Count.ShouldBe(2);
} }
} }
} }

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

@ -16,6 +16,7 @@
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" /> <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
<package id="Nito.AsyncEx" version="3.0.0" targetFramework="net451" /> <package id="Nito.AsyncEx" version="3.0.0" targetFramework="net451" />
<package id="NMemory" version="1.0.1" targetFramework="net451" /> <package id="NMemory" version="1.0.1" targetFramework="net451" />
<package id="Shouldly" version="2.5.0" targetFramework="net451" />
<package id="xunit" version="2.0.0" targetFramework="net451" /> <package id="xunit" version="2.0.0" targetFramework="net451" />
<package id="xunit.abstractions" 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.assert" version="2.0.0" targetFramework="net451" />