Adding tests
This commit is contained in:
@@ -805,6 +805,52 @@ public class RoleController_Tests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task UpdateRoleAsync_NotEditable()
|
||||
{
|
||||
if (_roleController == null)
|
||||
{
|
||||
Assert.Fail($"_roleController is null");
|
||||
}
|
||||
|
||||
DatabaseSqlServer.Role role = ModelsInit.CreateRole();
|
||||
role.IsNotEditable = true;
|
||||
|
||||
CreateRoleRequest request = new CreateRoleRequest()
|
||||
{
|
||||
Data = new CreateRoleRequestData()
|
||||
{
|
||||
Name = "RoleTest",
|
||||
IsNotEditable = true
|
||||
}
|
||||
};
|
||||
|
||||
_roleServiceMock?.Setup(s => s.GetRoleByGuidAsync(It.IsAny<string>())).ReturnsAsync(role);
|
||||
_roleServiceMock?.Setup(s => s.CheckIfNameIsValid(It.IsAny<string>(), It.IsAny<string>())).ReturnsAsync(false);
|
||||
|
||||
ObjectResult response = (ObjectResult)(await _roleController.UpdateRoleAsync(request, role.Guid));
|
||||
|
||||
if (response != null && response.Value != null)
|
||||
{
|
||||
Assert.IsTrue(response.StatusCode == StatusCodes.Status400BadRequest);
|
||||
|
||||
var result = (BaseResponse<object>)response.Value;
|
||||
if (result != null)
|
||||
{
|
||||
Assert.IsTrue(result.Status == StatusCodes.Status400BadRequest);
|
||||
Assert.IsTrue(result.Message == "This role is not editable");
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Fail($"Result value is null");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Fail($"Response value is null");
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task UpdateRoleAsync_CreateRoleRequestDataNull()
|
||||
{
|
||||
|
||||
@@ -39,7 +39,6 @@ public class RootController_Test
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.InnerException);
|
||||
Assert.Fail($"An exception was thrown: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ public class UserController_Tests
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task CreateUserAsync_Should_Return_200_When_Successful()
|
||||
public async Task CreateUserAsync_Success()
|
||||
{
|
||||
if (_userController == null)
|
||||
{
|
||||
|
||||
@@ -68,7 +68,6 @@ public class VersionController_Tests
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.InnerException);
|
||||
Assert.Fail($"An exception was thrown: {ex}");
|
||||
}
|
||||
}
|
||||
@@ -80,7 +79,6 @@ public class VersionController_Tests
|
||||
|
||||
try
|
||||
{
|
||||
Console.WriteLine(System.AppDomain.CurrentDomain.BaseDirectory);
|
||||
var configuration = TestUtils.CreateEmptyConfiguration(System.AppDomain.CurrentDomain.BaseDirectory + "/JsonData", "emptyAppsettings.json");
|
||||
VersionController versionController = new VersionController(configuration);
|
||||
var result = versionController.GetVersion();
|
||||
@@ -97,7 +95,6 @@ public class VersionController_Tests
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.InnerException);
|
||||
Assert.Fail($"An exception was thrown: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user