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> /// Should throw the InvalidPlacesCount error code. /// </summary> private void ShouldThrowInvalidPlacesCountErrorCode(int placesCount) { // Build the test harness. SchedulingBusinessLogicComponentTestHarness testHarness = new SchedulingBusinessLogicComponentTestHarness(); // Build the NewCourseSchedule business request. NewCourseScheduleBusinessRequest newCourseScheduleBusinessRequest = new NewCourseScheduleBusinessRequest(); // Build the Session business request element. NewCourseScheduleBusinessRequest.SessionBusinessRequestElement sessionBusinessRequestElement = new NewCourseScheduleBusinessRequest.SessionBusinessRequestElement(); sessionBusinessRequestElement.SessionCode = "6dk61ufcuzp3f7vs"; newCourseScheduleBusinessRequest.Session = sessionBusinessRequestElement; // Build the CourseSchedule business request element. NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement courseScheduleBusinessRequestElement = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement(); courseScheduleBusinessRequestElement.DayOfWeek = DayOfWeek.Monday; courseScheduleBusinessRequestElement.Time = new TimeSpan(9, 15, 0); newCourseScheduleBusinessRequest.CourseSchedule = courseScheduleBusinessRequestElement; // Build the CourseGroup business request elements. List <NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement> courseGroupBusinessRequestElements = new List <NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement>(); // Build the CourseGroup business request element. NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement courseGroupBusinessRequestElement = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement(); courseGroupBusinessRequestElement.PlacesCount = placesCount; courseGroupBusinessRequestElements.Add(courseGroupBusinessRequestElement); // Set the CourseGroup business request elements. courseScheduleBusinessRequestElement.CourseGroups = courseGroupBusinessRequestElements.ToArray(); try { // Invoke the NewCourseSchedule business operation. testHarness.SchedulingBusinessLogicComponent.NewCourseSchedule(testHarness.MockedDatabaseConnection, newCourseScheduleBusinessRequest).Wait(); // Validate an exception was thrown. Assert.Fail(); } catch (AggregateException ex) { // Verify the mocked components. testHarness.VerifyMockedComponents(); // Validate a NewCourseSchedule business exception was thrown. NewCourseScheduleBusinessException NewCourseScheduleBusinessException = ex.InnerExceptions[0] as NewCourseScheduleBusinessException; Assert.IsNotNull(NewCourseScheduleBusinessException); Assert.AreEqual("SchedulingBusinessLogicComponent.NewCourseSchedule() has thrown a NewCourseSchedule business exception. See the Errors property for details.", NewCourseScheduleBusinessException.Message); // Validate the NewCourseSchedule business exception contains the InvalidPlacesCount error code. Assert.IsNotNull(NewCourseScheduleBusinessException.Errors); Assert.AreEqual(1, NewCourseScheduleBusinessException.Errors.Length); Assert.AreEqual(NewCourseScheduleBusinessException.ErrorCodes.InvalidPlacesCount, NewCourseScheduleBusinessException.Errors[0].ErrorCode); Assert.AreEqual(placesCount, NewCourseScheduleBusinessException.Errors[0].ErroneousValue); } }
public void ShouldThrowInvalidSessionCodeErrorCode_GivenNonExistingSessionCode() { // Build the test harness. SchedulingBusinessLogicComponentTestHarness testHarness = new SchedulingBusinessLogicComponentTestHarness(); // Mock the reading of the Session data row. testHarness.MockedSessionDataAccessComponent .Setup(mock => mock.ReadBySessionCode(It.IsAny <IDatabaseConnection>(), "6dk61ufcuzp3f7vs")) .Returns(Task.FromResult <SessionDataRow>(null)) .Verifiable(); // Build the NewCourseSchedule business request. NewCourseScheduleBusinessRequest newCourseScheduleBusinessRequest = new NewCourseScheduleBusinessRequest(); // Build the Session business request element. NewCourseScheduleBusinessRequest.SessionBusinessRequestElement sessionBusinessRequestElement = new NewCourseScheduleBusinessRequest.SessionBusinessRequestElement(); sessionBusinessRequestElement.SessionCode = "6dk61ufcuzp3f7vs"; newCourseScheduleBusinessRequest.Session = sessionBusinessRequestElement; // Build the CourseSchedule business request element. NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement courseScheduleBusinessRequestElement = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement(); courseScheduleBusinessRequestElement.DayOfWeek = DayOfWeek.Monday; courseScheduleBusinessRequestElement.Time = new TimeSpan(9, 15, 0); newCourseScheduleBusinessRequest.CourseSchedule = courseScheduleBusinessRequestElement; // Build the CourseGroup business request elements. courseScheduleBusinessRequestElement.CourseGroups = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement[0]; try { // Invoke the NewCourseSchedule business operation. testHarness.SchedulingBusinessLogicComponent.NewCourseSchedule(testHarness.MockedDatabaseConnection, newCourseScheduleBusinessRequest).Wait(); // Validate an exception was thrown. Assert.Fail(); } catch (AggregateException ex) { // Verify the mocked components. testHarness.VerifyMockedComponents(); // Validate a NewCourseSchedule business exception was thrown. NewCourseScheduleBusinessException NewCourseScheduleBusinessException = ex.InnerExceptions[0] as NewCourseScheduleBusinessException; Assert.IsNotNull(NewCourseScheduleBusinessException); Assert.AreEqual("SchedulingBusinessLogicComponent.NewCourseSchedule() has thrown a NewCourseSchedule business exception. See the Errors property for details.", NewCourseScheduleBusinessException.Message); // Validate the NewCourseSchedule business exception contains the InvalidSessionCode error code. Assert.IsNotNull(NewCourseScheduleBusinessException.Errors); Assert.AreEqual(1, NewCourseScheduleBusinessException.Errors.Length); Assert.AreEqual(NewCourseScheduleBusinessException.ErrorCodes.InvalidSessionCode, NewCourseScheduleBusinessException.Errors[0].ErrorCode); Assert.AreEqual("6dk61ufcuzp3f7vs", NewCourseScheduleBusinessException.Errors[0].ErroneousValue); } }
public void ShouldReturnSessionResponseElement() { // Build the test harness. SchedulingBusinessLogicComponentTestHarness testHarness = new SchedulingBusinessLogicComponentTestHarness(); // Mock the generation of the unique token. testHarness.MockedUniqueTokenGenerator .Setup(mock => mock.GenerateUniqueToken()) .Returns("6dk61ufcuzp3f7vs") .Verifiable(); // Mock the creation of the Session data row. testHarness.MockedSessionDataAccessComponent .Setup(mock => mock.Create( It.IsAny <IDatabaseConnection>(), It.Is <SessionDataRow>(sessionDataRow => ( sessionDataRow.SessionCode == "6dk61ufcuzp3f7vs" && sessionDataRow.Name == "Session Alpha" && sessionDataRow.StartDate == new DateTime(2001, 1, 1) )))) .Returns(Task.FromResult <object>(null)) .Callback((IDatabaseConnection databaseConnection, SessionDataRow sessionDataRow) => { sessionDataRow.SessionID = 10001; }) .Verifiable(); // Build the NewSession business request. NewSessionBusinessRequest newSessionBusinessRequest = new NewSessionBusinessRequest(); // Build the Session business request element. NewSessionBusinessRequest.SessionBusinessRequestElement sessionBusinessRequestElement = new NewSessionBusinessRequest.SessionBusinessRequestElement(); sessionBusinessRequestElement.Name = "Session Alpha"; sessionBusinessRequestElement.StartDate = new DateTime(2001, 1, 1); newSessionBusinessRequest.Session = sessionBusinessRequestElement; // Invoke the NewSession business operation. NewSessionBusinessResponse newSessionBusinessResponse = testHarness.SchedulingBusinessLogicComponent.NewSession(testHarness.MockedDatabaseConnection, newSessionBusinessRequest).Result; // Verify the mocked components. testHarness.VerifyMockedComponents(); // Validate the Session business response element. Assert.IsNotNull(newSessionBusinessResponse); Assert.IsNotNull(newSessionBusinessResponse.Session); Assert.AreEqual("6dk61ufcuzp3f7vs", newSessionBusinessResponse.Session.SessionCode); }
public void ShouldReturnSessionResponseElement() { // Build the test harness. SchedulingBusinessLogicComponentTestHarness testHarness = new SchedulingBusinessLogicComponentTestHarness(); // Mock the generation of the unique token. testHarness.MockedUniqueTokenGenerator .Setup(mock => mock.GenerateUniqueToken()) .Returns("6dk61ufcuzp3f7vs") .Verifiable(); // Mock the creation of the Session data row. testHarness.MockedSessionDataAccessComponent .Setup(mock => mock.Create( It.IsAny<IDatabaseConnection>(), It.Is<SessionDataRow>(sessionDataRow => ( sessionDataRow.SessionCode == "6dk61ufcuzp3f7vs" && sessionDataRow.Name == "Session Alpha" && sessionDataRow.StartDate == new DateTime(2001, 1, 1) )))) .Returns(Task.FromResult<object>(null)) .Callback((IDatabaseConnection databaseConnection, SessionDataRow sessionDataRow) => { sessionDataRow.SessionID = 10001; }) .Verifiable(); // Build the NewSession business request. NewSessionBusinessRequest newSessionBusinessRequest = new NewSessionBusinessRequest(); // Build the Session business request element. NewSessionBusinessRequest.SessionBusinessRequestElement sessionBusinessRequestElement = new NewSessionBusinessRequest.SessionBusinessRequestElement(); sessionBusinessRequestElement.Name = "Session Alpha"; sessionBusinessRequestElement.StartDate = new DateTime(2001, 1, 1); newSessionBusinessRequest.Session = sessionBusinessRequestElement; // Invoke the NewSession business operation. NewSessionBusinessResponse newSessionBusinessResponse = testHarness.SchedulingBusinessLogicComponent.NewSession(testHarness.MockedDatabaseConnection, newSessionBusinessRequest).Result; // Verify the mocked components. testHarness.VerifyMockedComponents(); // Validate the Session business response element. Assert.IsNotNull(newSessionBusinessResponse); Assert.IsNotNull(newSessionBusinessResponse.Session); Assert.AreEqual("6dk61ufcuzp3f7vs", newSessionBusinessResponse.Session.SessionCode); }
public void ShouldThrowInvalidSessionErrorCode() { // Build the test harness. SchedulingBusinessLogicComponentTestHarness testHarness = new SchedulingBusinessLogicComponentTestHarness(); // Build the NewCourseSchedule business request. NewCourseScheduleBusinessRequest newCourseScheduleBusinessRequest = new NewCourseScheduleBusinessRequest(); // Build the Session business request element. newCourseScheduleBusinessRequest.Session = null; // Build the CourseSchedule business request element. NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement courseScheduleBusinessRequestElement = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement(); courseScheduleBusinessRequestElement.DayOfWeek = DayOfWeek.Monday; courseScheduleBusinessRequestElement.Time = new TimeSpan(9, 15, 0); newCourseScheduleBusinessRequest.CourseSchedule = courseScheduleBusinessRequestElement; // Build the CourseGroup business request elements. courseScheduleBusinessRequestElement.CourseGroups = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement[0]; try { // Invoke the NewCourseSchedule business operation. testHarness.SchedulingBusinessLogicComponent.NewCourseSchedule(testHarness.MockedDatabaseConnection, newCourseScheduleBusinessRequest).Wait(); // Validate an exception was thrown. Assert.Fail(); } catch (AggregateException ex) { // Verify the mocked components. testHarness.VerifyMockedComponents(); // Validate a NewCourseSchedule business exception was thrown. NewCourseScheduleBusinessException NewCourseScheduleBusinessException = ex.InnerExceptions[0] as NewCourseScheduleBusinessException; Assert.IsNotNull(NewCourseScheduleBusinessException); Assert.AreEqual("SchedulingBusinessLogicComponent.NewCourseSchedule() has thrown a NewCourseSchedule business exception. See the Errors property for details.", NewCourseScheduleBusinessException.Message); // Validate the NewCourseSchedule business exception contains the InvalidSession error code. Assert.IsNotNull(NewCourseScheduleBusinessException.Errors); Assert.AreEqual(1, NewCourseScheduleBusinessException.Errors.Length); Assert.AreEqual(NewCourseScheduleBusinessException.ErrorCodes.InvalidSession, NewCourseScheduleBusinessException.Errors[0].ErrorCode); Assert.AreEqual(null, NewCourseScheduleBusinessException.Errors[0].ErroneousValue); } }
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); }
/// <summary> /// Should throw the InvalidName error code. /// </summary> private void ShouldThrowInvalidNameErrorCode(string name) { // Build the test harness. SchedulingBusinessLogicComponentTestHarness testHarness = new SchedulingBusinessLogicComponentTestHarness(); // Build the NewSession business request. NewSessionBusinessRequest newSessionBusinessRequest = new NewSessionBusinessRequest(); // Build the Session business request element. NewSessionBusinessRequest.SessionBusinessRequestElement sessionBusinessRequestElement = new NewSessionBusinessRequest.SessionBusinessRequestElement(); sessionBusinessRequestElement.Name = name; sessionBusinessRequestElement.StartDate = new DateTime(2001, 1, 1); newSessionBusinessRequest.Session = sessionBusinessRequestElement; try { // Invoke the NewSession business operation. testHarness.SchedulingBusinessLogicComponent.NewSession(testHarness.MockedDatabaseConnection, newSessionBusinessRequest).Wait(); // Validate an exception was thrown. Assert.Fail(); } catch (AggregateException ex) { // Verify the mocked components. testHarness.VerifyMockedComponents(); // Validate a NewSession business exception was thrown. NewSessionBusinessException NewSessionBusinessException = ex.InnerExceptions[0] as NewSessionBusinessException; Assert.IsNotNull(NewSessionBusinessException); Assert.AreEqual("SchedulingBusinessLogicComponent.NewSession() has thrown a NewSession business exception. See the Errors property for details.", NewSessionBusinessException.Message); // Validate the NewSession business exception contains the InvalidName error code. Assert.IsNotNull(NewSessionBusinessException.Errors); Assert.AreEqual(1, NewSessionBusinessException.Errors.Length); Assert.AreEqual(NewSessionBusinessException.ErrorCodes.InvalidName, NewSessionBusinessException.Errors[0].ErrorCode); Assert.AreEqual(name, NewSessionBusinessException.Errors[0].ErroneousValue); } }
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> /// Should throw the InvalidTime error code. /// </summary> private void ShouldThrowInvalidTimeErrorCode(TimeSpan time) { // Build the test harness. SchedulingBusinessLogicComponentTestHarness testHarness = new SchedulingBusinessLogicComponentTestHarness(); // Build the NewCourseSchedule business request. NewCourseScheduleBusinessRequest newCourseScheduleBusinessRequest = new NewCourseScheduleBusinessRequest(); // Build the Session business request element. NewCourseScheduleBusinessRequest.SessionBusinessRequestElement sessionBusinessRequestElement = new NewCourseScheduleBusinessRequest.SessionBusinessRequestElement(); sessionBusinessRequestElement.SessionCode = "6dk61ufcuzp3f7vs"; newCourseScheduleBusinessRequest.Session = sessionBusinessRequestElement; // Build the CourseSchedule business request element. NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement courseScheduleBusinessRequestElement = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement(); courseScheduleBusinessRequestElement.DayOfWeek = DayOfWeek.Monday; courseScheduleBusinessRequestElement.Time = time; newCourseScheduleBusinessRequest.CourseSchedule = courseScheduleBusinessRequestElement; // Build the CourseGroup business request elements. courseScheduleBusinessRequestElement.CourseGroups = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement[0]; try { // Invoke the NewCourseSchedule business operation. testHarness.SchedulingBusinessLogicComponent.NewCourseSchedule(testHarness.MockedDatabaseConnection, newCourseScheduleBusinessRequest).Wait(); // Validate an exception was thrown. Assert.Fail(); } catch (AggregateException ex) { // Verify the mocked components. testHarness.VerifyMockedComponents(); // Validate a NewCourseSchedule business exception was thrown. NewCourseScheduleBusinessException NewCourseScheduleBusinessException = ex.InnerExceptions[0] as NewCourseScheduleBusinessException; Assert.IsNotNull(NewCourseScheduleBusinessException); Assert.AreEqual("SchedulingBusinessLogicComponent.NewCourseSchedule() has thrown a NewCourseSchedule business exception. See the Errors property for details.", NewCourseScheduleBusinessException.Message); // Validate the NewCourseSchedule business exception contains the InvalidTime error code. Assert.IsNotNull(NewCourseScheduleBusinessException.Errors); Assert.AreEqual(1, NewCourseScheduleBusinessException.Errors.Length); Assert.AreEqual(NewCourseScheduleBusinessException.ErrorCodes.InvalidTime, NewCourseScheduleBusinessException.Errors[0].ErrorCode); Assert.AreEqual(time, NewCourseScheduleBusinessException.Errors[0].ErroneousValue); } }
public void ShouldThrowInvalidSessionCodeErrorCode_GivenNonExistingSessionCode() { // Build the test harness. SchedulingBusinessLogicComponentTestHarness testHarness = new SchedulingBusinessLogicComponentTestHarness(); // Mock the reading of the Session data row. testHarness.MockedSessionDataAccessComponent .Setup(mock => mock.ReadBySessionCode(It.IsAny<IDatabaseConnection>(), "6dk61ufcuzp3f7vs")) .Returns(Task.FromResult<SessionDataRow>(null)) .Verifiable(); // Build the NewCourseSchedule business request. NewCourseScheduleBusinessRequest newCourseScheduleBusinessRequest = new NewCourseScheduleBusinessRequest(); // Build the Session business request element. NewCourseScheduleBusinessRequest.SessionBusinessRequestElement sessionBusinessRequestElement = new NewCourseScheduleBusinessRequest.SessionBusinessRequestElement(); sessionBusinessRequestElement.SessionCode = "6dk61ufcuzp3f7vs"; newCourseScheduleBusinessRequest.Session = sessionBusinessRequestElement; // Build the CourseSchedule business request element. NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement courseScheduleBusinessRequestElement = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement(); courseScheduleBusinessRequestElement.DayOfWeek = DayOfWeek.Monday; courseScheduleBusinessRequestElement.Time = new TimeSpan(9, 15, 0); newCourseScheduleBusinessRequest.CourseSchedule = courseScheduleBusinessRequestElement; // Build the CourseGroup business request elements. courseScheduleBusinessRequestElement.CourseGroups = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement[0]; try { // Invoke the NewCourseSchedule business operation. testHarness.SchedulingBusinessLogicComponent.NewCourseSchedule(testHarness.MockedDatabaseConnection, newCourseScheduleBusinessRequest).Wait(); // Validate an exception was thrown. Assert.Fail(); } catch (AggregateException ex) { // Verify the mocked components. testHarness.VerifyMockedComponents(); // Validate a NewCourseSchedule business exception was thrown. NewCourseScheduleBusinessException NewCourseScheduleBusinessException = ex.InnerExceptions[0] as NewCourseScheduleBusinessException; Assert.IsNotNull(NewCourseScheduleBusinessException); Assert.AreEqual("SchedulingBusinessLogicComponent.NewCourseSchedule() has thrown a NewCourseSchedule business exception. See the Errors property for details.", NewCourseScheduleBusinessException.Message); // Validate the NewCourseSchedule business exception contains the InvalidSessionCode error code. Assert.IsNotNull(NewCourseScheduleBusinessException.Errors); Assert.AreEqual(1, NewCourseScheduleBusinessException.Errors.Length); Assert.AreEqual(NewCourseScheduleBusinessException.ErrorCodes.InvalidSessionCode, NewCourseScheduleBusinessException.Errors[0].ErrorCode); Assert.AreEqual("6dk61ufcuzp3f7vs", NewCourseScheduleBusinessException.Errors[0].ErroneousValue); } }
public void ShouldReturnZeroCourseGroupsResponseElements() { // Build the test harness. SchedulingBusinessLogicComponentTestHarness testHarness = new SchedulingBusinessLogicComponentTestHarness(); // Mock the reading of the Session data row. testHarness.MockedSessionDataAccessComponent .Setup(mock => mock.ReadBySessionCode(It.IsAny<IDatabaseConnection>(), "6dk61ufcuzp3f7vs")) .Returns(Task.FromResult(new SessionDataRow() { SessionID = 10001, SessionCode = "6dk61ufcuzp3f7vs", Name = "Session Alpha", StartDate = new DateTime(2001, 1, 1) })) .Verifiable(); // Mock the generation of the unique token. testHarness.MockedUniqueTokenGenerator .Setup(mock => mock.GenerateUniqueToken()) .Returns("zzcj32kpd6huzp1n") .Verifiable(); // Mock the creation of the CourseSchedule data row. testHarness.MockedCourseScheduleDataAccessComponent .Setup(mock => mock.Create( It.IsAny<IDatabaseConnection>(), It.Is<CourseScheduleDataRow>(courseScheduleDataRow => ( courseScheduleDataRow.CourseScheduleCode == "zzcj32kpd6huzp1n" && courseScheduleDataRow.SessionID == 10001 && courseScheduleDataRow.DayOfWeek == (int)DayOfWeek.Monday && courseScheduleDataRow.Time == new TimeSpan(9, 15, 0) )))) .Returns(Task.FromResult<object>(null)) .Callback((IDatabaseConnection databaseConnection, CourseScheduleDataRow courseScheduleDataRow) => { courseScheduleDataRow.CourseScheduleID = 20001; }) .Verifiable(); // Build the NewCourseSchedule business request. NewCourseScheduleBusinessRequest newCourseScheduleBusinessRequest = new NewCourseScheduleBusinessRequest(); // Build the Session business request element. NewCourseScheduleBusinessRequest.SessionBusinessRequestElement sessionBusinessRequestElement = new NewCourseScheduleBusinessRequest.SessionBusinessRequestElement(); sessionBusinessRequestElement.SessionCode = "6dk61ufcuzp3f7vs"; newCourseScheduleBusinessRequest.Session = sessionBusinessRequestElement; // Build the CourseSchedule business request element. NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement courseScheduleBusinessRequestElement = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement(); courseScheduleBusinessRequestElement.DayOfWeek = DayOfWeek.Monday; courseScheduleBusinessRequestElement.Time = new TimeSpan(9, 15, 0); newCourseScheduleBusinessRequest.CourseSchedule = courseScheduleBusinessRequestElement; // Build the CourseGroup business request elements. List<NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement> courseGroupBusinessRequestElements = new List<NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement>(); // Set the CourseGroup business request elements. courseScheduleBusinessRequestElement.CourseGroups = courseGroupBusinessRequestElements.ToArray(); // Invoke the NewCourseSchedule business operation. NewCourseScheduleBusinessResponse newCourseScheduleBusinessResponse = testHarness.SchedulingBusinessLogicComponent.NewCourseSchedule(testHarness.MockedDatabaseConnection, newCourseScheduleBusinessRequest).Result; // Verify the mocked components. testHarness.VerifyMockedComponents(); // Validate the CourseGroup business response elements count. Assert.IsNotNull(newCourseScheduleBusinessResponse); Assert.IsNotNull(newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups); Assert.AreEqual(0, newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups.Length); }
public void ShouldReturnMultipleCourseGroupsResponseElements() { // Build the test harness. SchedulingBusinessLogicComponentTestHarness testHarness = new SchedulingBusinessLogicComponentTestHarness(); // Mock the reading of the Session data row. testHarness.MockedSessionDataAccessComponent .Setup(mock => mock.ReadBySessionCode(It.IsAny<IDatabaseConnection>(), "6dk61ufcuzp3f7vs")) .Returns(Task.FromResult(new SessionDataRow() { SessionID = 10001, SessionCode = "6dk61ufcuzp3f7vs", Name = "Session Alpha", StartDate = new DateTime(2001, 1, 1) })) .Verifiable(); // Mock the generation of the unique tokens. Queue<string> uniqueTokens = new Queue<string>(new string[] { "zzcj32kpd6huzp1n", "5s1cgndj6e5x0uvz", "78zcn25ynkaz50ef", "q5692qwy70qde9uv" }); testHarness.MockedUniqueTokenGenerator .Setup(mock => mock.GenerateUniqueToken()) .Returns(() => uniqueTokens.Dequeue()) .Verifiable(); // Mock the creation of the CourseSchedule data row. testHarness.MockedCourseScheduleDataAccessComponent .Setup(mock => mock.Create( It.IsAny<IDatabaseConnection>(), It.Is<CourseScheduleDataRow>(courseScheduleDataRow => ( courseScheduleDataRow.CourseScheduleCode == "zzcj32kpd6huzp1n" && courseScheduleDataRow.SessionID == 10001 && courseScheduleDataRow.DayOfWeek == (int)DayOfWeek.Monday && courseScheduleDataRow.Time == new TimeSpan(9, 15, 0) )))) .Returns(Task.FromResult<object>(null)) .Callback((IDatabaseConnection databaseConnection, CourseScheduleDataRow courseScheduleDataRow) => { courseScheduleDataRow.CourseScheduleID = 20001; }) .Verifiable(); // Mock the creation of the first CourseGroup data row. testHarness.MockedCourseGroupDataAccessComponent .Setup(mock => mock.Create( It.IsAny<IDatabaseConnection>(), It.Is<CourseGroupDataRow>(courseGroupDataRow => ( courseGroupDataRow.CourseGroupCode == "5s1cgndj6e5x0uvz" && courseGroupDataRow.CourseScheduleID == 20001 && courseGroupDataRow.PlacesCount == 1 )))) .Returns(Task.FromResult<object>(null)) .Callback((IDatabaseConnection databaseConnection, CourseGroupDataRow courseGroupDataRow) => { courseGroupDataRow.CourseGroupID = 30001; }) .Verifiable(); // Mock the creation of the second CourseGroup data row. testHarness.MockedCourseGroupDataAccessComponent .Setup(mock => mock.Create( It.IsAny<IDatabaseConnection>(), It.Is<CourseGroupDataRow>(courseGroupDataRow => ( courseGroupDataRow.CourseGroupCode == "78zcn25ynkaz50ef" && courseGroupDataRow.CourseScheduleID == 20001 && courseGroupDataRow.PlacesCount == 2 )))) .Returns(Task.FromResult<object>(null)) .Callback((IDatabaseConnection databaseConnection, CourseGroupDataRow courseGroupDataRow) => { courseGroupDataRow.CourseGroupID = 30002; }) .Verifiable(); // Mock the creation of the third CourseGroup data row. testHarness.MockedCourseGroupDataAccessComponent .Setup(mock => mock.Create( It.IsAny<IDatabaseConnection>(), It.Is<CourseGroupDataRow>(courseGroupDataRow => ( courseGroupDataRow.CourseGroupCode == "q5692qwy70qde9uv" && courseGroupDataRow.CourseScheduleID == 20001 && courseGroupDataRow.PlacesCount == 3 )))) .Returns(Task.FromResult<object>(null)) .Callback((IDatabaseConnection databaseConnection, CourseGroupDataRow courseGroupDataRow) => { courseGroupDataRow.CourseGroupID = 30003; }) .Verifiable(); // Build the NewCourseSchedule business request. NewCourseScheduleBusinessRequest newCourseScheduleBusinessRequest = new NewCourseScheduleBusinessRequest(); // Build the Session business request element. NewCourseScheduleBusinessRequest.SessionBusinessRequestElement sessionBusinessRequestElement = new NewCourseScheduleBusinessRequest.SessionBusinessRequestElement(); sessionBusinessRequestElement.SessionCode = "6dk61ufcuzp3f7vs"; newCourseScheduleBusinessRequest.Session = sessionBusinessRequestElement; // Build the CourseSchedule business request element. NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement courseScheduleBusinessRequestElement = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement(); courseScheduleBusinessRequestElement.DayOfWeek = DayOfWeek.Monday; courseScheduleBusinessRequestElement.Time = new TimeSpan(9, 15, 0); newCourseScheduleBusinessRequest.CourseSchedule = courseScheduleBusinessRequestElement; // Build the CourseGroup business request elements. List<NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement> courseGroupBusinessRequestElements = new List<NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement>(); // Build the first CourseGroup business request element. NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement firstCourseGroupBusinessRequestElement = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement(); firstCourseGroupBusinessRequestElement.PlacesCount = 1; courseGroupBusinessRequestElements.Add(firstCourseGroupBusinessRequestElement); // Build the second CourseGroup business request element. NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement secondCourseGroupBusinessRequestElement = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement(); secondCourseGroupBusinessRequestElement.PlacesCount = 2; courseGroupBusinessRequestElements.Add(secondCourseGroupBusinessRequestElement); // Build the third CourseGroup business request element. NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement thirdCourseGroupBusinessRequestElement = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement(); thirdCourseGroupBusinessRequestElement.PlacesCount = 3; courseGroupBusinessRequestElements.Add(thirdCourseGroupBusinessRequestElement); // Set the CourseGroup business request elements. courseScheduleBusinessRequestElement.CourseGroups = courseGroupBusinessRequestElements.ToArray(); // Invoke the NewCourseSchedule business operation. NewCourseScheduleBusinessResponse newCourseScheduleBusinessResponse = testHarness.SchedulingBusinessLogicComponent.NewCourseSchedule(testHarness.MockedDatabaseConnection, newCourseScheduleBusinessRequest).Result; // Verify the mocked components. testHarness.VerifyMockedComponents(); // Validate the CourseGroup business response elements count. Assert.IsNotNull(newCourseScheduleBusinessResponse); Assert.IsNotNull(newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups); Assert.AreEqual(3, newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups.Length); // Validate the first CourseGroup business response element. Assert.IsNotNull(newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups[0]); Assert.AreEqual("5s1cgndj6e5x0uvz", newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups[0].CourseGroupCode); // Validate the second CourseGroup business response element. Assert.IsNotNull(newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups[1]); Assert.AreEqual("78zcn25ynkaz50ef", newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups[1].CourseGroupCode); // Validate the third CourseGroup business response element. Assert.IsNotNull(newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups[2]); Assert.AreEqual("q5692qwy70qde9uv", newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups[2].CourseGroupCode); }
public void ShouldReturnCourseScheduleResponseElement() { // Build the test harness. SchedulingBusinessLogicComponentTestHarness testHarness = new SchedulingBusinessLogicComponentTestHarness(); // Mock the reading of the Session data row. testHarness.MockedSessionDataAccessComponent .Setup(mock => mock.ReadBySessionCode(It.IsAny <IDatabaseConnection>(), "6dk61ufcuzp3f7vs")) .Returns(Task.FromResult(new SessionDataRow() { SessionID = 10001, SessionCode = "6dk61ufcuzp3f7vs", Name = "Session Alpha", StartDate = new DateTime(2001, 1, 1) })) .Verifiable(); // Mock the generation of the unique token. testHarness.MockedUniqueTokenGenerator .Setup(mock => mock.GenerateUniqueToken()) .Returns("zzcj32kpd6huzp1n") .Verifiable(); // Mock the creation of the CourseSchedule data row. testHarness.MockedCourseScheduleDataAccessComponent .Setup(mock => mock.Create( It.IsAny <IDatabaseConnection>(), It.Is <CourseScheduleDataRow>(courseScheduleDataRow => ( courseScheduleDataRow.CourseScheduleCode == "zzcj32kpd6huzp1n" && courseScheduleDataRow.SessionID == 10001 && courseScheduleDataRow.DayOfWeek == (int)DayOfWeek.Monday && courseScheduleDataRow.Time == new TimeSpan(9, 15, 0) )))) .Returns(Task.FromResult <object>(null)) .Callback((IDatabaseConnection databaseConnection, CourseScheduleDataRow courseScheduleDataRow) => { courseScheduleDataRow.CourseScheduleID = 20001; }) .Verifiable(); // Build the NewCourseSchedule business request. NewCourseScheduleBusinessRequest newCourseScheduleBusinessRequest = new NewCourseScheduleBusinessRequest(); // Build the Session business request element. NewCourseScheduleBusinessRequest.SessionBusinessRequestElement sessionBusinessRequestElement = new NewCourseScheduleBusinessRequest.SessionBusinessRequestElement(); sessionBusinessRequestElement.SessionCode = "6dk61ufcuzp3f7vs"; newCourseScheduleBusinessRequest.Session = sessionBusinessRequestElement; // Build the CourseSchedule business request element. NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement courseScheduleBusinessRequestElement = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement(); courseScheduleBusinessRequestElement.DayOfWeek = DayOfWeek.Monday; courseScheduleBusinessRequestElement.Time = new TimeSpan(9, 15, 0); newCourseScheduleBusinessRequest.CourseSchedule = courseScheduleBusinessRequestElement; // Build the CourseGroup business request elements. courseScheduleBusinessRequestElement.CourseGroups = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement[0]; // Invoke the NewCourseSchedule business operation. NewCourseScheduleBusinessResponse newCourseScheduleBusinessResponse = testHarness.SchedulingBusinessLogicComponent.NewCourseSchedule(testHarness.MockedDatabaseConnection, newCourseScheduleBusinessRequest).Result; // Verify the mocked components. testHarness.VerifyMockedComponents(); // Validate the CourseSchedule business response element. Assert.IsNotNull(newCourseScheduleBusinessResponse); Assert.IsNotNull(newCourseScheduleBusinessResponse.CourseSchedule); Assert.AreEqual("zzcj32kpd6huzp1n", newCourseScheduleBusinessResponse.CourseSchedule.CourseScheduleCode); }
public void ShouldReturnMultipleCourseGroupsResponseElements() { // Build the test harness. SchedulingBusinessLogicComponentTestHarness testHarness = new SchedulingBusinessLogicComponentTestHarness(); // Mock the reading of the Session data row. testHarness.MockedSessionDataAccessComponent .Setup(mock => mock.ReadBySessionCode(It.IsAny <IDatabaseConnection>(), "6dk61ufcuzp3f7vs")) .Returns(Task.FromResult(new SessionDataRow() { SessionID = 10001, SessionCode = "6dk61ufcuzp3f7vs", Name = "Session Alpha", StartDate = new DateTime(2001, 1, 1) })) .Verifiable(); // Mock the generation of the unique tokens. Queue <string> uniqueTokens = new Queue <string>(new string[] { "zzcj32kpd6huzp1n", "5s1cgndj6e5x0uvz", "78zcn25ynkaz50ef", "q5692qwy70qde9uv" }); testHarness.MockedUniqueTokenGenerator .Setup(mock => mock.GenerateUniqueToken()) .Returns(() => uniqueTokens.Dequeue()) .Verifiable(); // Mock the creation of the CourseSchedule data row. testHarness.MockedCourseScheduleDataAccessComponent .Setup(mock => mock.Create( It.IsAny <IDatabaseConnection>(), It.Is <CourseScheduleDataRow>(courseScheduleDataRow => ( courseScheduleDataRow.CourseScheduleCode == "zzcj32kpd6huzp1n" && courseScheduleDataRow.SessionID == 10001 && courseScheduleDataRow.DayOfWeek == (int)DayOfWeek.Monday && courseScheduleDataRow.Time == new TimeSpan(9, 15, 0) )))) .Returns(Task.FromResult <object>(null)) .Callback((IDatabaseConnection databaseConnection, CourseScheduleDataRow courseScheduleDataRow) => { courseScheduleDataRow.CourseScheduleID = 20001; }) .Verifiable(); // Mock the creation of the first CourseGroup data row. testHarness.MockedCourseGroupDataAccessComponent .Setup(mock => mock.Create( It.IsAny <IDatabaseConnection>(), It.Is <CourseGroupDataRow>(courseGroupDataRow => ( courseGroupDataRow.CourseGroupCode == "5s1cgndj6e5x0uvz" && courseGroupDataRow.CourseScheduleID == 20001 && courseGroupDataRow.PlacesCount == 1 )))) .Returns(Task.FromResult <object>(null)) .Callback((IDatabaseConnection databaseConnection, CourseGroupDataRow courseGroupDataRow) => { courseGroupDataRow.CourseGroupID = 30001; }) .Verifiable(); // Mock the creation of the second CourseGroup data row. testHarness.MockedCourseGroupDataAccessComponent .Setup(mock => mock.Create( It.IsAny <IDatabaseConnection>(), It.Is <CourseGroupDataRow>(courseGroupDataRow => ( courseGroupDataRow.CourseGroupCode == "78zcn25ynkaz50ef" && courseGroupDataRow.CourseScheduleID == 20001 && courseGroupDataRow.PlacesCount == 2 )))) .Returns(Task.FromResult <object>(null)) .Callback((IDatabaseConnection databaseConnection, CourseGroupDataRow courseGroupDataRow) => { courseGroupDataRow.CourseGroupID = 30002; }) .Verifiable(); // Mock the creation of the third CourseGroup data row. testHarness.MockedCourseGroupDataAccessComponent .Setup(mock => mock.Create( It.IsAny <IDatabaseConnection>(), It.Is <CourseGroupDataRow>(courseGroupDataRow => ( courseGroupDataRow.CourseGroupCode == "q5692qwy70qde9uv" && courseGroupDataRow.CourseScheduleID == 20001 && courseGroupDataRow.PlacesCount == 3 )))) .Returns(Task.FromResult <object>(null)) .Callback((IDatabaseConnection databaseConnection, CourseGroupDataRow courseGroupDataRow) => { courseGroupDataRow.CourseGroupID = 30003; }) .Verifiable(); // Build the NewCourseSchedule business request. NewCourseScheduleBusinessRequest newCourseScheduleBusinessRequest = new NewCourseScheduleBusinessRequest(); // Build the Session business request element. NewCourseScheduleBusinessRequest.SessionBusinessRequestElement sessionBusinessRequestElement = new NewCourseScheduleBusinessRequest.SessionBusinessRequestElement(); sessionBusinessRequestElement.SessionCode = "6dk61ufcuzp3f7vs"; newCourseScheduleBusinessRequest.Session = sessionBusinessRequestElement; // Build the CourseSchedule business request element. NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement courseScheduleBusinessRequestElement = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement(); courseScheduleBusinessRequestElement.DayOfWeek = DayOfWeek.Monday; courseScheduleBusinessRequestElement.Time = new TimeSpan(9, 15, 0); newCourseScheduleBusinessRequest.CourseSchedule = courseScheduleBusinessRequestElement; // Build the CourseGroup business request elements. List <NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement> courseGroupBusinessRequestElements = new List <NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement>(); // Build the first CourseGroup business request element. NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement firstCourseGroupBusinessRequestElement = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement(); firstCourseGroupBusinessRequestElement.PlacesCount = 1; courseGroupBusinessRequestElements.Add(firstCourseGroupBusinessRequestElement); // Build the second CourseGroup business request element. NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement secondCourseGroupBusinessRequestElement = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement(); secondCourseGroupBusinessRequestElement.PlacesCount = 2; courseGroupBusinessRequestElements.Add(secondCourseGroupBusinessRequestElement); // Build the third CourseGroup business request element. NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement thirdCourseGroupBusinessRequestElement = new NewCourseScheduleBusinessRequest.CourseScheduleBusinessRequestElement.CourseGroupBusinessRequestElement(); thirdCourseGroupBusinessRequestElement.PlacesCount = 3; courseGroupBusinessRequestElements.Add(thirdCourseGroupBusinessRequestElement); // Set the CourseGroup business request elements. courseScheduleBusinessRequestElement.CourseGroups = courseGroupBusinessRequestElements.ToArray(); // Invoke the NewCourseSchedule business operation. NewCourseScheduleBusinessResponse newCourseScheduleBusinessResponse = testHarness.SchedulingBusinessLogicComponent.NewCourseSchedule(testHarness.MockedDatabaseConnection, newCourseScheduleBusinessRequest).Result; // Verify the mocked components. testHarness.VerifyMockedComponents(); // Validate the CourseGroup business response elements count. Assert.IsNotNull(newCourseScheduleBusinessResponse); Assert.IsNotNull(newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups); Assert.AreEqual(3, newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups.Length); // Validate the first CourseGroup business response element. Assert.IsNotNull(newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups[0]); Assert.AreEqual("5s1cgndj6e5x0uvz", newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups[0].CourseGroupCode); // Validate the second CourseGroup business response element. Assert.IsNotNull(newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups[1]); Assert.AreEqual("78zcn25ynkaz50ef", newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups[1].CourseGroupCode); // Validate the third CourseGroup business response element. Assert.IsNotNull(newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups[2]); Assert.AreEqual("q5692qwy70qde9uv", newCourseScheduleBusinessResponse.CourseSchedule.CourseGroups[2].CourseGroupCode); }