/// <summary> /// Invokes the GetSessions business operation. /// </summary> private async Task <GetSessionsBusinessResponse> InvokeGetSessions(IDatabaseConnection databaseConnection) { try { // Build the GetSessions business request. GetSessionsBusinessRequest getSessionsBusinessRequest = new GetSessionsBusinessRequest(); // Invoke the GetSessions business operation. GetSessionsBusinessResponse getSessionsBusinessResponse = await this.schedulingBusinessLogicComponent.GetSessions(databaseConnection, getSessionsBusinessRequest); // The business operation succeeded. return(getSessionsBusinessResponse); } catch (GetSessionsBusinessException getSessionsBusinessException) { // Wrap the GetSessions business exception into a service exception. ServiceException serviceException = ServiceExceptionBuilder.BuildServiceException( "SchedulingServiceComponent.SessionsController.Get()", getSessionsBusinessException, getSessionsBusinessException.Errors.Select(error => error.ErrorCode.ToString()).ToArray(), getSessionsBusinessException.Errors.Select(error => error.ErroneousValue).ToArray()); // Throw the ErrorCode service exception. throw serviceException; } }
/// <summary> /// Invokes the GetSessions business operation. /// </summary> private async Task<GetSessionsBusinessResponse> InvokeGetSessions(IDatabaseConnection databaseConnection) { try { // Build the GetSessions business request. GetSessionsBusinessRequest getSessionsBusinessRequest = new GetSessionsBusinessRequest(); // Invoke the GetSessions business operation. GetSessionsBusinessResponse getSessionsBusinessResponse = await this.schedulingBusinessLogicComponent.GetSessions(databaseConnection, getSessionsBusinessRequest); // The business operation succeeded. return getSessionsBusinessResponse; } catch (GetSessionsBusinessException getSessionsBusinessException) { // Wrap the GetSessions business exception into a service exception. ServiceException serviceException = ServiceExceptionBuilder.BuildServiceException( "SchedulingServiceComponent.SessionsController.Get()", getSessionsBusinessException, getSessionsBusinessException.Errors.Select(error => error.ErrorCode.ToString()).ToArray(), getSessionsBusinessException.Errors.Select(error => error.ErroneousValue).ToArray()); // Throw the ErrorCode service exception. throw serviceException; } }
/// <summary> /// Executes the GetSessions business operation. /// </summary> public async virtual Task<GetSessionsBusinessResponse> GetSessions(IDatabaseConnection databaseConnection, GetSessionsBusinessRequest businessRequest) { // Validate the business request. this.ValidateGetSessionsRequest(businessRequest); // Initialize the operation data. GetSessionsOperationData operationData = new GetSessionsOperationData(); // Validate the business operation. await this.ValidateGetSessionsOperation(databaseConnection, businessRequest, operationData); // Read the Session data rows. operationData.SessionDataRows = await this.sessionDataAccessComponent.ReadAll(databaseConnection); // Build the business response. GetSessionsBusinessResponse businessResponse = new GetSessionsBusinessResponse(); // Build the Session business response elements. List<GetSessionsBusinessResponse.SessionBusinessResponseElement> sessionBusinessResponseElements = new List<GetSessionsBusinessResponse.SessionBusinessResponseElement>(); foreach (SessionDataRow sessionDataRow in operationData.SessionDataRows) { // Build the Session business response element. GetSessionsBusinessResponse.SessionBusinessResponseElement sessionBusinessResponseElement = new GetSessionsBusinessResponse.SessionBusinessResponseElement(); sessionBusinessResponseElement.SessionCode = sessionDataRow.SessionCode; sessionBusinessResponseElement.Name = sessionDataRow.Name; sessionBusinessResponseElement.StartDate = sessionDataRow.StartDate; sessionBusinessResponseElements.Add(sessionBusinessResponseElement); } // Set the Session business response elements. businessResponse.Sessions = sessionBusinessResponseElements.ToArray(); // Return the business response. return businessResponse; }
public void ShouldReturnZeroSessionsResponseElements() { // Build the test harness. SchedulingBusinessLogicComponentTestHarness testHarness = new SchedulingBusinessLogicComponentTestHarness(); // Mock the reading of the Session data rows. testHarness.MockedSessionDataAccessComponent .Setup(mock => mock.ReadAll(It.IsAny <IDatabaseConnection>())) .Returns(Task.FromResult(new SessionDataRow[0])) .Verifiable(); // Build the GetSessions business request. GetSessionsBusinessRequest getSessionsBusinessRequest = new GetSessionsBusinessRequest(); // Invoke the GetSessions business operation. GetSessionsBusinessResponse getSessionsBusinessResponse = testHarness.SchedulingBusinessLogicComponent.GetSessions(testHarness.MockedDatabaseConnection, getSessionsBusinessRequest).Result; // Verify the mocked components. testHarness.VerifyMockedComponents(); // Validate the Session business response elements count. Assert.IsNotNull(getSessionsBusinessResponse); Assert.IsNotNull(getSessionsBusinessResponse.Sessions); Assert.AreEqual(0, getSessionsBusinessResponse.Sessions.Length); }
public void ShouldReturnOneSessionResponseElement() { // Build the test harness. SchedulingBusinessLogicComponentTestHarness testHarness = new SchedulingBusinessLogicComponentTestHarness(); // Mock the reading of the Session data rows. testHarness.MockedSessionDataAccessComponent .Setup(mock => mock.ReadAll(It.IsAny <IDatabaseConnection>())) .Returns(Task.FromResult(new SessionDataRow[] { new SessionDataRow() { SessionID = 10001, SessionCode = "6dk61ufcuzp3f7vs", Name = "Session Alpha", StartDate = new DateTime(2001, 1, 1) } })) .Verifiable(); // Build the GetSessions business request. GetSessionsBusinessRequest getSessionsBusinessRequest = new GetSessionsBusinessRequest(); // Invoke the GetSessions business operation. GetSessionsBusinessResponse getSessionsBusinessResponse = testHarness.SchedulingBusinessLogicComponent.GetSessions(testHarness.MockedDatabaseConnection, getSessionsBusinessRequest).Result; // Verify the mocked components. testHarness.VerifyMockedComponents(); // Validate the Session business response elements count. Assert.IsNotNull(getSessionsBusinessResponse); Assert.IsNotNull(getSessionsBusinessResponse.Sessions); Assert.AreEqual(1, getSessionsBusinessResponse.Sessions.Length); // Validate the Session business response element. Assert.IsNotNull(getSessionsBusinessResponse.Sessions[0]); Assert.AreEqual("6dk61ufcuzp3f7vs", getSessionsBusinessResponse.Sessions[0].SessionCode); Assert.AreEqual("Session Alpha", getSessionsBusinessResponse.Sessions[0].Name); Assert.AreEqual(new DateTime(2001, 1, 1), getSessionsBusinessResponse.Sessions[0].StartDate); }
public void ShouldReturnOneSessionResponseElement() { // Build the test harness. SchedulingBusinessLogicComponentTestHarness testHarness = new SchedulingBusinessLogicComponentTestHarness(); // Mock the reading of the Session data rows. testHarness.MockedSessionDataAccessComponent .Setup(mock => mock.ReadAll(It.IsAny<IDatabaseConnection>())) .Returns(Task.FromResult(new SessionDataRow[] { new SessionDataRow() { SessionID = 10001, SessionCode = "6dk61ufcuzp3f7vs", Name = "Session Alpha", StartDate = new DateTime(2001, 1, 1) } })) .Verifiable(); // Build the GetSessions business request. GetSessionsBusinessRequest getSessionsBusinessRequest = new GetSessionsBusinessRequest(); // Invoke the GetSessions business operation. GetSessionsBusinessResponse getSessionsBusinessResponse = testHarness.SchedulingBusinessLogicComponent.GetSessions(testHarness.MockedDatabaseConnection, getSessionsBusinessRequest).Result; // Verify the mocked components. testHarness.VerifyMockedComponents(); // Validate the Session business response elements count. Assert.IsNotNull(getSessionsBusinessResponse); Assert.IsNotNull(getSessionsBusinessResponse.Sessions); Assert.AreEqual(1, getSessionsBusinessResponse.Sessions.Length); // Validate the Session business response element. Assert.IsNotNull(getSessionsBusinessResponse.Sessions[0]); Assert.AreEqual("6dk61ufcuzp3f7vs", getSessionsBusinessResponse.Sessions[0].SessionCode); Assert.AreEqual("Session Alpha", getSessionsBusinessResponse.Sessions[0].Name); Assert.AreEqual(new DateTime(2001, 1, 1), getSessionsBusinessResponse.Sessions[0].StartDate); }
public void ShouldReturnZeroSessionsResponseElements() { // Build the test harness. SchedulingBusinessLogicComponentTestHarness testHarness = new SchedulingBusinessLogicComponentTestHarness(); // Mock the reading of the Session data rows. testHarness.MockedSessionDataAccessComponent .Setup(mock => mock.ReadAll(It.IsAny<IDatabaseConnection>())) .Returns(Task.FromResult(new SessionDataRow[0])) .Verifiable(); // Build the GetSessions business request. GetSessionsBusinessRequest getSessionsBusinessRequest = new GetSessionsBusinessRequest(); // Invoke the GetSessions business operation. GetSessionsBusinessResponse getSessionsBusinessResponse = testHarness.SchedulingBusinessLogicComponent.GetSessions(testHarness.MockedDatabaseConnection, getSessionsBusinessRequest).Result; // Verify the mocked components. testHarness.VerifyMockedComponents(); // Validate the Session business response elements count. Assert.IsNotNull(getSessionsBusinessResponse); Assert.IsNotNull(getSessionsBusinessResponse.Sessions); Assert.AreEqual(0, getSessionsBusinessResponse.Sessions.Length); }
/// <summary> /// Validates the GetSessions business operation. /// </summary> private Task ValidateGetSessionsOperation(IDatabaseConnection databaseConnection, GetSessionsBusinessRequest businessRequest, GetSessionsOperationData operationData) { return Task.FromResult<object>(null); }
/// <summary> /// Validates the GetSessions business request. /// </summary> private void ValidateGetSessionsRequest(GetSessionsBusinessRequest businessRequest) { return; }
/// <summary> /// Executes the GetSessions business operation. /// </summary> public async virtual Task <GetSessionsBusinessResponse> GetSessions(IDatabaseConnection databaseConnection, GetSessionsBusinessRequest businessRequest) { // Validate the business request. this.ValidateGetSessionsRequest(businessRequest); // Initialize the operation data. GetSessionsOperationData operationData = new GetSessionsOperationData(); // Validate the business operation. await this.ValidateGetSessionsOperation(databaseConnection, businessRequest, operationData); // Read the Session data rows. operationData.SessionDataRows = await this.sessionDataAccessComponent.ReadAll(databaseConnection); // Build the business response. GetSessionsBusinessResponse businessResponse = new GetSessionsBusinessResponse(); // Build the Session business response elements. List <GetSessionsBusinessResponse.SessionBusinessResponseElement> sessionBusinessResponseElements = new List <GetSessionsBusinessResponse.SessionBusinessResponseElement>(); foreach (SessionDataRow sessionDataRow in operationData.SessionDataRows) { // Build the Session business response element. GetSessionsBusinessResponse.SessionBusinessResponseElement sessionBusinessResponseElement = new GetSessionsBusinessResponse.SessionBusinessResponseElement(); sessionBusinessResponseElement.SessionCode = sessionDataRow.SessionCode; sessionBusinessResponseElement.Name = sessionDataRow.Name; sessionBusinessResponseElement.StartDate = sessionDataRow.StartDate; sessionBusinessResponseElements.Add(sessionBusinessResponseElement); } // Set the Session business response elements. businessResponse.Sessions = sessionBusinessResponseElements.ToArray(); // Return the business response. return(businessResponse); }
/// <summary> /// Validates the GetSessions business operation. /// </summary> private Task ValidateGetSessionsOperation(IDatabaseConnection databaseConnection, GetSessionsBusinessRequest businessRequest, GetSessionsOperationData operationData) { return(Task.FromResult <object>(null)); }