Initial commit: SWP.Core enterprise framework with multi-tenant architecture, configuration management, security, telemetry and comprehensive test suite
This commit is contained in:
commit
5275a75502
87 changed files with 6140 additions and 0 deletions
83
Tests/Entities/UserTests.cs
Normal file
83
Tests/Entities/UserTests.cs
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Shouldly;
|
||||
using SWP.Core.Entities.Users;
|
||||
using SWP.Core.X.TDD.TestHelpers;
|
||||
|
||||
namespace SWP.Core.X.TDD.Entities;
|
||||
|
||||
[TestClass]
|
||||
public class UserTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void User_ShouldHaveBasicProperties()
|
||||
{
|
||||
// Arrange & Act
|
||||
var user = new User
|
||||
{
|
||||
Id = 1,
|
||||
Email = "test@example.com",
|
||||
PasswordHash = "hashedPassword",
|
||||
SecurityStamp = "securityStamp",
|
||||
EmailConfirmed = true,
|
||||
CreatedDate = DateTime.UtcNow
|
||||
};
|
||||
|
||||
// Assert
|
||||
user.Id.ShouldBe(1);
|
||||
user.Email.ShouldBe("test@example.com");
|
||||
user.PasswordHash.ShouldBe("hashedPassword");
|
||||
user.SecurityStamp.ShouldBe("securityStamp");
|
||||
user.EmailConfirmed.ShouldBeTrue();
|
||||
user.CreatedDate.ShouldBeInRange(DateTime.UtcNow.AddMinutes(-1), DateTime.UtcNow.AddMinutes(1));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestDataBuilder_ShouldCreateValidUser()
|
||||
{
|
||||
// Act
|
||||
var user = TestDataBuilder.Users.CreateTestUser();
|
||||
|
||||
// Assert
|
||||
user.ShouldNotBeNull();
|
||||
user.Email.ShouldNotBeNullOrEmpty();
|
||||
user.Email.ShouldContain("@example.com");
|
||||
user.CreatedDate.ShouldBeInRange(DateTime.UtcNow.AddMinutes(-1), DateTime.UtcNow.AddMinutes(1));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestDataBuilder_ShouldCreateUserWithCustomEmail()
|
||||
{
|
||||
// Arrange
|
||||
var customEmail = "custom@test.com";
|
||||
|
||||
// Act
|
||||
var user = TestDataBuilder.Users.CreateTestUser(customEmail);
|
||||
|
||||
// Assert
|
||||
user.Email.ShouldBe(customEmail);
|
||||
}
|
||||
}
|
||||
|
||||
[TestClass]
|
||||
public class OrganizationTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void Organization_ShouldHaveBasicProperties()
|
||||
{
|
||||
// Arrange & Act
|
||||
var org = new Organization
|
||||
{
|
||||
Id = 1,
|
||||
ConnectionString = "test connection",
|
||||
CreatedDate = DateTime.UtcNow,
|
||||
CreatedBy = 1,
|
||||
IsActive = true
|
||||
};
|
||||
|
||||
// Assert
|
||||
org.Id.ShouldBe(1);
|
||||
org.ConnectionString.ShouldBe("test connection");
|
||||
org.CreatedBy.ShouldBe(1);
|
||||
org.IsActive.ShouldBeTrue();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue