Switched to standard MonIn library
This commit is contained in:
@ -115,21 +115,21 @@ internal class ECNServiceTests {
|
||||
OriginatorID = 1,
|
||||
Title = "title1",
|
||||
IsTECN = true,
|
||||
ExpirationDate = DateTime.Now.AddHours(-2)
|
||||
ExpirationDate = DateTime.Now.Date.AddHours(2)
|
||||
},
|
||||
new ECN() {
|
||||
ECNNumber = 2,
|
||||
OriginatorID = 1,
|
||||
Title = "title2",
|
||||
IsTECN = true,
|
||||
ExpirationDate = DateTime.Now.AddHours(-20)
|
||||
ExpirationDate = DateTime.Now.Date.AddHours(20)
|
||||
},
|
||||
new ECN() {
|
||||
ECNNumber = 3,
|
||||
OriginatorID = 1,
|
||||
Title = "title3",
|
||||
IsTECN = true,
|
||||
ExpirationDate = DateTime.Now.AddHours(-12)
|
||||
ExpirationDate = DateTime.Now.Date.AddHours(12)
|
||||
},
|
||||
};
|
||||
|
||||
@ -186,22 +186,22 @@ internal class ECNServiceTests {
|
||||
OriginatorID = 1,
|
||||
Title = "title1",
|
||||
IsTECN = true,
|
||||
ExpirationDate = DateTime.Now.AddHours(-2)
|
||||
ExpirationDate = DateTime.Now.Date.AddHours(2)
|
||||
},
|
||||
new ECN() {
|
||||
ECNNumber = 2,
|
||||
OriginatorID = 1,
|
||||
Title = "title2",
|
||||
IsTECN = true,
|
||||
ExpirationDate = DateTime.Now.AddHours(-20)
|
||||
ExpirationDate = DateTime.Now.Date.AddHours(20)
|
||||
},
|
||||
new ECN() {
|
||||
ECNNumber = 3,
|
||||
OriginatorID = 1,
|
||||
Title = "title3",
|
||||
IsTECN = true,
|
||||
ExpirationDate = DateTime.Now.AddHours(-12),
|
||||
ExtensionDate = DateTime.Now.AddDays(10)
|
||||
ExpirationDate = DateTime.Now.Date.AddHours(12),
|
||||
ExtensionDate = DateTime.Now.Date.AddDays(10)
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -26,4 +26,147 @@ public class TrainingServiceTests {
|
||||
public void TrainingServiceWithNullDalServiceShouldThrowException() {
|
||||
Assert.Throws<ArgumentNullException>(() => new TrainingService(_mockLogger.Object, null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeleteDocAssignmentWithInvalidIdShouldThrowException() {
|
||||
_trainingService = new TrainingService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<ArgumentException>(async Task () => await _trainingService.DeleteDocAssignment(-1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeleteDocAssignmentWithDbErrorShouldThrowException() {
|
||||
_mockDalService.Setup(d => d.ExecuteAsync(It.IsAny<string>())).Throws(new Exception());
|
||||
|
||||
_trainingService = new TrainingService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async Task () => await _trainingService.DeleteDocAssignment(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task DeleteDocAssignmentShouldExecuteSqlQuery() {
|
||||
_mockDalService.Setup(d => d.ExecuteAsync(It.IsAny<string>())).Returns(Task.FromResult(3));
|
||||
|
||||
_trainingService = new TrainingService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
await _trainingService.DeleteDocAssignment(3);
|
||||
|
||||
_mockDalService.Verify(d => d.ExecuteAsync(It.IsAny<string>()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeleteTrainingAssignmentWithInvalidIdShouldThrowException() {
|
||||
_trainingService = new TrainingService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<ArgumentException>(async Task () => await _trainingService.DeleteTrainingAssignment(-1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeleteTrainingAssignmentWithDbErrorShouldThrowException() {
|
||||
_mockDalService.Setup(d => d.ExecuteAsync(It.IsAny<string>())).Throws(new Exception());
|
||||
|
||||
_trainingService = new TrainingService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async Task () => await _trainingService.DeleteTrainingAssignment(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task DeleteTrainingAssignmentShouldExecuteSqlQuery() {
|
||||
_mockDalService.Setup(d => d.ExecuteAsync(It.IsAny<string>())).Returns(Task.FromResult(3));
|
||||
|
||||
_trainingService = new TrainingService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
await _trainingService.DeleteTrainingAssignment(3);
|
||||
|
||||
_mockDalService.Verify(d => d.ExecuteAsync(It.IsAny<string>()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetTrainingAssignmentIdsForTrainingWithInvalidIdShouldThrowException() {
|
||||
_trainingService = new TrainingService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<ArgumentException>(async Task () => {
|
||||
IEnumerable<int> ids = await _trainingService.GetTrainingAssignmentIdsForTraining(-1);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetTrainingAssignmentIdsForTrainingWithDbErrorShouldThrowException() {
|
||||
_mockDalService.Setup(d => d.QueryAsync<int>(It.IsAny<string>())).Throws(new Exception());
|
||||
|
||||
_trainingService = new TrainingService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async Task () => await _trainingService.GetTrainingAssignmentIdsForTraining(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetTrainingAssignmentIdsForTrainingShouldReturnExpectedIds() {
|
||||
IEnumerable<int> expectedIds = new List<int>() { 4, 7, 2 };
|
||||
|
||||
_mockDalService.Setup(d => d.QueryAsync<int>(It.IsAny<string>())).Returns(Task.FromResult(expectedIds));
|
||||
|
||||
_trainingService = new TrainingService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
IEnumerable<int> actualIds = await _trainingService.GetTrainingAssignmentIdsForTraining(1);
|
||||
|
||||
Assert.That(actualIds.Count(), Is.EqualTo(expectedIds.Count()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetTrainingIdsForEcnWithInvalidIdShouldThrowException() {
|
||||
_trainingService = new TrainingService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<ArgumentException>(async Task () => {
|
||||
IEnumerable<int> ids = await _trainingService.GetTrainingIdsForECN(-1);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetTrainingIdsForEcnWithDbErrorShouldThrowException() {
|
||||
_mockDalService.Setup(d => d.QueryAsync<int>(It.IsAny<string>())).Throws(new Exception());
|
||||
|
||||
_trainingService = new TrainingService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async Task () => await _trainingService.GetTrainingIdsForECN(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetTrainingIdsForEcnsShouldReturnExpectedIds() {
|
||||
IEnumerable<int> expectedIds = new List<int>() { 4, 7, 2 };
|
||||
|
||||
_mockDalService.Setup(d => d.QueryAsync<int>(It.IsAny<string>())).Returns(Task.FromResult(expectedIds));
|
||||
|
||||
_trainingService = new TrainingService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
IEnumerable<int> actualIds = await _trainingService.GetTrainingIdsForECN(1);
|
||||
|
||||
Assert.That(actualIds.Count(), Is.EqualTo(expectedIds.Count()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MarkTrainingAsCompleteWithInvalidIdShouldThrowException() {
|
||||
_trainingService = new TrainingService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<ArgumentException>(async Task() => await _trainingService.MarkTrainingAsComplete(-1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MarkTrainingCompleteWithDbErrorShouldThrowException() {
|
||||
_mockDalService.Setup(d => d.ExecuteAsync(It.IsAny<string>())).Throws(new Exception());
|
||||
|
||||
_trainingService = new TrainingService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async Task () => await _trainingService.MarkTrainingAsComplete(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task MarkTrainingCompleteShouldExecuteSql() {
|
||||
_mockDalService.Setup(d => d.ExecuteAsync(It.IsAny<string>())).Returns(Task.FromResult(1));
|
||||
|
||||
_trainingService = new TrainingService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
await _trainingService.MarkTrainingAsComplete(1);
|
||||
|
||||
_mockDalService.Verify(d => d.ExecuteAsync(It.IsAny<string>()));
|
||||
}
|
||||
}
|
||||
|
@ -272,13 +272,6 @@ internal class UserServiceTests {
|
||||
Assert.ThrowsAsync<ArgumentException>(async Task () => await _userService.RemoveDelegatedUserSubRoles(0, 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task RemoveDelegateUserSubRolesWithInvalidDelegateIdShouldThrowException() {
|
||||
_userService = new UserService(MOCK_LOGGER, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<ArgumentException>(async Task () => await _userService.RemoveDelegatedUserSubRoles(2, 0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task RemoveDelegatedUserSubRolesWithValidParamsShouldReturnTrue() {
|
||||
IEnumerable<int> roleIds = new List<int>() {1, 2};
|
||||
@ -323,13 +316,6 @@ internal class UserServiceTests {
|
||||
Assert.ThrowsAsync<ArgumentException>(async Task () => await _userService.RemoveDelegatedApprovalsForUser(0, 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task RemoveDelegatedApprovalsForUserWithInvalidDelegateIdShouldThrowException() {
|
||||
_userService = new UserService(MOCK_LOGGER, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<ArgumentException>(async Task () => await _userService.RemoveDelegatedApprovalsForUser(2, 0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task RemoveDelegatedApprovalsForUserWithValidUserIdShouldReturnTrue() {
|
||||
IEnumerable<int> roleIds = new List<int>() { 1, 2 };
|
||||
|
Reference in New Issue
Block a user