Skip to content

Commit

Permalink
Merge branch 'release/1.0.0-rc5'
Browse files Browse the repository at this point in the history
  • Loading branch information
albx committed Sep 22, 2018
2 parents dc55a3e + 30847dc commit aa7432c
Show file tree
Hide file tree
Showing 52 changed files with 1,380 additions and 1,022 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Wilcommerce.Auth
Wilcommerce Authentication and Authorization package
Wilcommerce Authentication and Authorization package.<br/>
It uses AspNetCore Identity framework to manage sign in and user persistence.

## Installation
Nuget package available here [https://www.nuget.org/packages/Wilcommerce.Auth](https://www.nuget.org/packages/Wilcommerce.Auth)

## Models
The **Models** namespace contains all the classes representing the components used for creating authentication tokens.
The **Models** namespace contains the user class.

## Read models
This namespace contains the interface which gives a readonly access to the components.
Expand All @@ -16,9 +17,6 @@ The **Services** namespace contains a set of components which gives a simple acc
## Commands
**Commands** namespace contains all the actions available on this package.

## Repository
This namespace contains the interface which defines the persistence of the components.

## Events
In the **Events** namespace are defined all the events that could happen after an action made.

Expand Down
129 changes: 129 additions & 0 deletions Wilcommerce.Auth.Test/Models/UserTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
using System;
using Wilcommerce.Auth.Models;
using Xunit;

namespace Wilcommerce.Auth.Test.Models
{
public class UserTest
{
#region Administrator tests
[Theory]
[InlineData(null)]
[InlineData("")]
public void AdministratorFactory_Should_Throw_ArgumentNull_Exception_If_Name_IsEmpty(string value)
{
var ex = Assert.Throws<ArgumentException>(() => User.CreateAsAdministrator(
value,
"[email protected]",
true));

Assert.Equal("name", ex.ParamName);
}

[Theory]
[InlineData(null)]
[InlineData("")]
public void AdministratorFactory_Should_Throw_ArgumentNull_Exception_If_Email_IsEmpty(string value)
{
var ex = Assert.Throws<ArgumentException>(() => User.CreateAsAdministrator(
"Administrator",
value,
true));

Assert.Equal("email", ex.ParamName);
}

#endregion

#region Customer tests
[Theory]
[InlineData(null)]
[InlineData("")]
public void CustomerFactory_Should_Throw_ArgumentNull_Exception_If_Name_IsEmpty(string value)
{
var ex = Assert.Throws<ArgumentException>(() => User.CreateAsCustomer(
value,
"[email protected]"));

Assert.Equal("name", ex.ParamName);
}

[Theory]
[InlineData(null)]
[InlineData("")]
public void CustomerFactory_Should_Throw_ArgumentNull_Exception_If_Email_IsEmpty(string value)
{
var ex = Assert.Throws<ArgumentException>(() => User.CreateAsCustomer(
"Customer",
value));

Assert.Equal("email", ex.ParamName);
}
#endregion

[Fact]
public void Enable_Should_Active_User_And_Set_Date_To_Null()
{
var user = User.CreateAsAdministrator(
"Admin",
"[email protected]",
false);

user.Enable();

Assert.True(user.IsActive);
Assert.Null(user.DisabledOn);
}

[Fact]
public void Disable_Should_Set_Date_To_Now()
{
var user = User.CreateAsAdministrator(
"Admin",
"[email protected]",
true);

user.Disable();

Assert.False(user.IsActive);
Assert.Equal(DateTime.Today, ((DateTime)user.DisabledOn).Date);
}

[Theory]
[InlineData("")]
[InlineData(null)]
public void ChangeName_Should_Throw_ArgumentNullException_If_Name_IsEmpty(string value)
{
var user = User.CreateAsAdministrator(
"Admin",
"[email protected]",
true);

var ex = Assert.Throws<ArgumentException>(() => user.ChangeName(value));
Assert.Equal("name", ex.ParamName);
}

[Fact]
public void SetProfileImage_Should_Throw_ArgumentNullException_If_Image_IsNull()
{
var user = User.CreateAsAdministrator(
"Admin",
"[email protected]",
true);

var ex = Assert.Throws<ArgumentNullException>(() => user.SetProfileImage(null));
Assert.Equal("profileImage", ex.ParamName);
}

[Fact]
public void Constructor_Should_Initialize_Empty_ProfileImage()
{
var admin = User.CreateAsAdministrator(
"Administrator",
"[email protected]",
true);

Assert.NotNull(admin.ProfileImage);
}
}
}
118 changes: 0 additions & 118 deletions Wilcommerce.Auth.Test/Models/UserTokenTest.cs

This file was deleted.

74 changes: 0 additions & 74 deletions Wilcommerce.Auth.Test/Services/IdentityFactoryTest.cs

This file was deleted.

8 changes: 4 additions & 4 deletions Wilcommerce.Auth.Test/Wilcommerce.Auth.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Moq" Version="4.8.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="Moq" Version="4.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="xunit" Version="2.4.0" />
</ItemGroup>

</Project>

This file was deleted.

This file was deleted.

Loading

0 comments on commit aa7432c

Please sign in to comment.