Skip to content

Commit

Permalink
Created unit test for sample project
Browse files Browse the repository at this point in the history
  • Loading branch information
hikalkan committed Jan 30, 2015
1 parent 9f35048 commit c80e519
Show file tree
Hide file tree
Showing 23 changed files with 477 additions and 291 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Abp, Version=0.5.0.4, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="Abp, Version=0.5.1.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Abp.0.5.0.4\lib\net451\Abp.dll</HintPath>
<HintPath>..\packages\Abp.0.5.1.1\lib\net451\Abp.dll</HintPath>
</Reference>
<Reference Include="Abp.AutoMapper, Version=0.5.0.4, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="Abp.AutoMapper, Version=0.5.1.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Abp.AutoMapper.0.5.0.4\lib\net451\Abp.AutoMapper.dll</HintPath>
<HintPath>..\packages\Abp.AutoMapper.0.5.1.1\lib\net451\Abp.AutoMapper.dll</HintPath>
</Reference>
<Reference Include="Abp.EntityFramework, Version=0.5.0.4, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="Abp.EntityFramework, Version=0.5.1.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Abp.EntityFramework.0.5.0.4\lib\net451\Abp.EntityFramework.dll</HintPath>
<HintPath>..\packages\Abp.EntityFramework.0.5.1.1\lib\net451\Abp.EntityFramework.dll</HintPath>
</Reference>
<Reference Include="Abp.Zero, Version=0.5.0.2, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="Abp.Zero, Version=0.5.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Abp.Zero.0.5.0.2\lib\net451\Abp.Zero.dll</HintPath>
<HintPath>..\packages\Abp.Zero.0.5.1.0\lib\net451\Abp.Zero.dll</HintPath>
</Reference>
<Reference Include="AutoMapper, Version=3.3.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Reflection;
using Abp.AutoMapper;
using Abp.Modules;
using ModuleZeroSampleProject.Authorization;

namespace ModuleZeroSampleProject
{
[DependsOn(typeof(ModuleZeroSampleProjectCoreModule))]
[DependsOn(typeof(ModuleZeroSampleProjectCoreModule), typeof(AbpAutoMapperModule))]
public class ModuleZeroSampleProjectApplicationModule : AbpModule
{
public override void Initialize()
Expand Down
8 changes: 4 additions & 4 deletions sample/ModuleZeroSampleProject.Application/packages.config
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Abp" version="0.5.0.4" targetFramework="net451" />
<package id="Abp.AutoMapper" version="0.5.0.4" targetFramework="net451" />
<package id="Abp.EntityFramework" version="0.5.0.4" targetFramework="net451" />
<package id="Abp.Zero" version="0.5.0.2" targetFramework="net451" />
<package id="Abp" version="0.5.1.1" targetFramework="net451" />
<package id="Abp.AutoMapper" version="0.5.1.1" targetFramework="net451" />
<package id="Abp.EntityFramework" version="0.5.1.1" targetFramework="net451" />
<package id="Abp.Zero" version="0.5.1.0" targetFramework="net451" />
<package id="AutoMapper" version="3.3.0" targetFramework="net451" />
<package id="Castle.Core" version="3.3.3" targetFramework="net451" />
<package id="Castle.LoggingFacility" version="3.3.0" targetFramework="net451" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Abp, Version=0.5.0.4, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="Abp, Version=0.5.1.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Abp.0.5.0.4\lib\net451\Abp.dll</HintPath>
<HintPath>..\packages\Abp.0.5.1.1\lib\net451\Abp.dll</HintPath>
</Reference>
<Reference Include="Abp.Zero, Version=0.5.0.2, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="Abp.Zero, Version=0.5.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Abp.Zero.0.5.0.2\lib\net451\Abp.Zero.dll</HintPath>
<HintPath>..\packages\Abp.Zero.0.5.1.0\lib\net451\Abp.Zero.dll</HintPath>
</Reference>
<Reference Include="Castle.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
4 changes: 2 additions & 2 deletions sample/ModuleZeroSampleProject.Core/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Abp" version="0.5.0.4" targetFramework="net451" />
<package id="Abp.Zero" version="0.5.0.2" targetFramework="net451" />
<package id="Abp" version="0.5.1.1" targetFramework="net451" />
<package id="Abp.Zero" version="0.5.1.0" 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" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Data.Entity;
using System.Data.Common;
using System.Data.Entity;
using Abp.Zero.EntityFramework;
using ModuleZeroSampleProject.Authorization;
using ModuleZeroSampleProject.MultiTenancy;
Expand Down Expand Up @@ -36,5 +37,11 @@ public ModuleZeroSampleProjectDbContext(string nameOrConnectionString)
{

}

public ModuleZeroSampleProjectDbContext(DbConnection connection)
: base(connection, true)
{

}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Abp.Authorization.Roles;
using Abp.Authorization.Users;
using ModuleZeroSampleProject.Authorization;
using ModuleZeroSampleProject.EntityFramework;
using ModuleZeroSampleProject.MultiTenancy;
using ModuleZeroSampleProject.Questions;
using ModuleZeroSampleProject.Users;
using ModuleZeroSampleProject.Migrations.Data;

namespace ModuleZeroSampleProject.Migrations
{
using System.Data.Entity.Migrations;
using System.Linq;

internal sealed class Configuration : DbMigrationsConfiguration<ModuleZeroSampleProjectDbContext>
{
Expand All @@ -23,146 +17,7 @@ public Configuration()

protected override void Seed(ModuleZeroSampleProjectDbContext context)
{
CreateUserAndRoles(context);
}

private void CreateUserAndRoles(ModuleZeroSampleProjectDbContext context)
{
//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 Role(null, "Admin", "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 User
{
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 Tenant("Default", "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 Role(defaultTenant.Id, "Admin", "Admin"));
context.SaveChanges();

//Permission definitions for Admin of 'Default' tenant
context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForDefaultTenant.Id, Name = "CanDeleteAnswers", IsGranted = true });
context.Permissions.Add(new RolePermissionSetting { RoleId = adminRoleForDefaultTenant.Id, Name = "CanDeleteQuestions", IsGranted = true });
context.SaveChanges();
}

//User role for 'Default' tenant

var userRoleForDefaultTenant = context.Roles.FirstOrDefault(r => r.TenantId == defaultTenant.Id && r.Name == "User");
if (userRoleForDefaultTenant == null)
{
userRoleForDefaultTenant = context.Roles.Add(new Role(defaultTenant.Id, "User", "User"));
context.SaveChanges();

//Permission definitions for User of 'Default' tenant
context.Permissions.Add(new RolePermissionSetting { RoleId = userRoleForDefaultTenant.Id, Name = "CanCreateQuestions", IsGranted = true });
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 User
{
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.UserRoles.Add(new UserRole(adminUserForDefaultTenant.Id, userRoleForDefaultTenant.Id));
context.SaveChanges();

var question1 = context.Questions.Add(
new Question(
"What's the answer of ultimate question of life the universe and everything?",
"What's the answer of ultimate question of life the universe and everything? Please answer this question!"
)
);
context.SaveChanges();

question1.CreatorUserId = adminUserForDefaultTenant.Id;
context.SaveChanges();
}

//User 'Emre' for 'Default' tenant

var emreUserForDefaultTenant = context.Users.FirstOrDefault(u => u.TenantId == defaultTenant.Id && u.UserName == "emre");
if (emreUserForDefaultTenant == null)
{
emreUserForDefaultTenant = context.Users.Add(
new User
{
TenantId = defaultTenant.Id,
UserName = "emre",
Name = "Yunus Emre",
Surname = "Kalkan",
EmailAddress = "emre@aspnetboilerplate.com",
IsEmailConfirmed = true,
Password = "AM4OLBpptxBYmM79lGOX9egzZk3vIQU3d/gFCJzaBjAPXzYIK3tQ2N7X4fcrHtElTw==" //123qwe
});
context.SaveChanges();

context.UserRoles.Add(new UserRole(emreUserForDefaultTenant.Id, userRoleForDefaultTenant.Id));
context.SaveChanges();

var question2 = context.Questions.Add(
new Question(
"Jquery content replacement not working within my function",
@"What I am trying to achieve, and I am nearly there, is the user clicks on a checkbox and it turns green (Checkbox-active class). However, I also want the text/content of the clicked element to change to ""Activated"" and then reverts back to the original text when clicked again or on a sibling."
)
);
context.SaveChanges();

question2.CreatorUserId = emreUserForDefaultTenant.Id;
context.SaveChanges();
}
new InitialDataBuilder().Build(context);
}
}
}
Loading

0 comments on commit c80e519

Please sign in to comment.