Skip to content

Commit aa7432c

Browse files
committed
Merge branch 'release/1.0.0-rc5'
2 parents dc55a3e + 30847dc commit aa7432c

File tree

52 files changed

+1380
-1022
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1380
-1022
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Wilcommerce.Auth
2-
Wilcommerce Authentication and Authorization package
2+
Wilcommerce Authentication and Authorization package.<br/>
3+
It uses AspNetCore Identity framework to manage sign in and user persistence.
34

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

78
## Models
8-
The **Models** namespace contains all the classes representing the components used for creating authentication tokens.
9+
The **Models** namespace contains the user class.
910

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

19-
## Repository
20-
This namespace contains the interface which defines the persistence of the components.
21-
2220
## Events
2321
In the **Events** namespace are defined all the events that could happen after an action made.
2422

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
using System;
2+
using Wilcommerce.Auth.Models;
3+
using Xunit;
4+
5+
namespace Wilcommerce.Auth.Test.Models
6+
{
7+
public class UserTest
8+
{
9+
#region Administrator tests
10+
[Theory]
11+
[InlineData(null)]
12+
[InlineData("")]
13+
public void AdministratorFactory_Should_Throw_ArgumentNull_Exception_If_Name_IsEmpty(string value)
14+
{
15+
var ex = Assert.Throws<ArgumentException>(() => User.CreateAsAdministrator(
16+
value,
17+
"admin@email.com",
18+
true));
19+
20+
Assert.Equal("name", ex.ParamName);
21+
}
22+
23+
[Theory]
24+
[InlineData(null)]
25+
[InlineData("")]
26+
public void AdministratorFactory_Should_Throw_ArgumentNull_Exception_If_Email_IsEmpty(string value)
27+
{
28+
var ex = Assert.Throws<ArgumentException>(() => User.CreateAsAdministrator(
29+
"Administrator",
30+
value,
31+
true));
32+
33+
Assert.Equal("email", ex.ParamName);
34+
}
35+
36+
#endregion
37+
38+
#region Customer tests
39+
[Theory]
40+
[InlineData(null)]
41+
[InlineData("")]
42+
public void CustomerFactory_Should_Throw_ArgumentNull_Exception_If_Name_IsEmpty(string value)
43+
{
44+
var ex = Assert.Throws<ArgumentException>(() => User.CreateAsCustomer(
45+
value,
46+
"customer@email.com"));
47+
48+
Assert.Equal("name", ex.ParamName);
49+
}
50+
51+
[Theory]
52+
[InlineData(null)]
53+
[InlineData("")]
54+
public void CustomerFactory_Should_Throw_ArgumentNull_Exception_If_Email_IsEmpty(string value)
55+
{
56+
var ex = Assert.Throws<ArgumentException>(() => User.CreateAsCustomer(
57+
"Customer",
58+
value));
59+
60+
Assert.Equal("email", ex.ParamName);
61+
}
62+
#endregion
63+
64+
[Fact]
65+
public void Enable_Should_Active_User_And_Set_Date_To_Null()
66+
{
67+
var user = User.CreateAsAdministrator(
68+
"Admin",
69+
"admin@email.com",
70+
false);
71+
72+
user.Enable();
73+
74+
Assert.True(user.IsActive);
75+
Assert.Null(user.DisabledOn);
76+
}
77+
78+
[Fact]
79+
public void Disable_Should_Set_Date_To_Now()
80+
{
81+
var user = User.CreateAsAdministrator(
82+
"Admin",
83+
"admin@email.com",
84+
true);
85+
86+
user.Disable();
87+
88+
Assert.False(user.IsActive);
89+
Assert.Equal(DateTime.Today, ((DateTime)user.DisabledOn).Date);
90+
}
91+
92+
[Theory]
93+
[InlineData("")]
94+
[InlineData(null)]
95+
public void ChangeName_Should_Throw_ArgumentNullException_If_Name_IsEmpty(string value)
96+
{
97+
var user = User.CreateAsAdministrator(
98+
"Admin",
99+
"admin@email.com",
100+
true);
101+
102+
var ex = Assert.Throws<ArgumentException>(() => user.ChangeName(value));
103+
Assert.Equal("name", ex.ParamName);
104+
}
105+
106+
[Fact]
107+
public void SetProfileImage_Should_Throw_ArgumentNullException_If_Image_IsNull()
108+
{
109+
var user = User.CreateAsAdministrator(
110+
"Admin",
111+
"admin@email.com",
112+
true);
113+
114+
var ex = Assert.Throws<ArgumentNullException>(() => user.SetProfileImage(null));
115+
Assert.Equal("profileImage", ex.ParamName);
116+
}
117+
118+
[Fact]
119+
public void Constructor_Should_Initialize_Empty_ProfileImage()
120+
{
121+
var admin = User.CreateAsAdministrator(
122+
"Administrator",
123+
"admin@email.com",
124+
true);
125+
126+
Assert.NotNull(admin.ProfileImage);
127+
}
128+
}
129+
}

Wilcommerce.Auth.Test/Models/UserTokenTest.cs

Lines changed: 0 additions & 118 deletions
This file was deleted.

Wilcommerce.Auth.Test/Services/IdentityFactoryTest.cs

Lines changed: 0 additions & 74 deletions
This file was deleted.

Wilcommerce.Auth.Test/Wilcommerce.Auth.Test.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
</ItemGroup>
1818

1919
<ItemGroup>
20-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
21-
<PackageReference Include="Moq" Version="4.8.3" />
22-
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
23-
<PackageReference Include="xunit" Version="2.3.1" />
20+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
21+
<PackageReference Include="Moq" Version="4.9.0" />
22+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
23+
<PackageReference Include="xunit" Version="2.4.0" />
2424
</ItemGroup>
2525

2626
</Project>

src/Wilcommerce.Auth/Commands/Handlers/Interfaces/IRecoverPasswordCommandHandler.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/Wilcommerce.Auth/Commands/Handlers/Interfaces/IValidatePasswordRecoveryCommandHandler.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)