-
Notifications
You must be signed in to change notification settings - Fork 1
Heedls 441 edit course content #634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
b42730c
HEEDLS-441 Add new action/views
AlexJacksonDS f175e66
HEEDLS-441 Make form able to post to complex model
AlexJacksonDS 4ae0cdd
HEEDLS-441 Save tutorial statuses to database
AlexJacksonDS 5df5e24
HEEDLS-441 Fix styling on checkboxes and layout issues
AlexJacksonDS bf0e531
HEEDLS-441 No javascript Select/Deselect buttons
AlexJacksonDS 2587c9a
HEEDLS-441 Add javascript select all
AlexJacksonDS 4e93f83
HEEDLS-441 Refactor screen to be only single section
AlexJacksonDS 6967820
HEEDLS-441 Make the sets of checkboxes into columns for desktop
AlexJacksonDS f94aaa8
HEEDLS-441 Refactor form data classes and fix javascript
AlexJacksonDS 8335017
HEEDLS-441 Lint fix unexpected Unicode BOM
AlexJacksonDS 92f7bdf
HEEDLS-441 Add unit tests for new services and controller actions
AlexJacksonDS a0d7a9d
Merge branch 'master' into HEEDLS-441-edit-course-content
AlexJacksonDS bbf9e53
HEEDLS-441 Add final unit tests post merge
AlexJacksonDS 54d75f3
HEEDLS-441 Change customisation used in tests
AlexJacksonDS d706c6a
HEEDLS-441 Break down a few long lines
AlexJacksonDS bbbcb56
HEEDLS-441 Review markups
AlexJacksonDS 7dab11c
HEEDLS-441 Add new service to Startup
AlexJacksonDS 54fea49
Merge branch 'master' into HEEDLS-441-edit-course-content
AlexJacksonDS 2932f6a
Merge branch 'master' into HEEDLS-441-edit-course-content
AlexJacksonDS b5a73ac
HEEDLS-441 Review markups
AlexJacksonDS 88b246e
HEEDLS-441 Further review markups
AlexJacksonDS 0187d12
Merge branch 'master' into HEEDLS-441-edit-course-content
AlexJacksonDS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
DigitalLearningSolutions.Data.Tests/Services/SectionServiceTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| namespace DigitalLearningSolutions.Data.Tests.Services | ||
| { | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using DigitalLearningSolutions.Data.DataServices; | ||
| using DigitalLearningSolutions.Data.Models; | ||
| using DigitalLearningSolutions.Data.Services; | ||
| using FakeItEasy; | ||
| using FluentAssertions; | ||
| using FluentAssertions.Execution; | ||
| using NUnit.Framework; | ||
|
|
||
| public class SectionServiceTests | ||
| { | ||
| private ISectionContentDataService sectionContentDataService = null!; | ||
| private ISectionService sectionService = null!; | ||
| private ITutorialContentDataService tutorialContentDataService = null!; | ||
|
|
||
| [SetUp] | ||
| public void Setup() | ||
| { | ||
| sectionContentDataService = A.Fake<ISectionContentDataService>(); | ||
| tutorialContentDataService = A.Fake<ITutorialContentDataService>(); | ||
|
|
||
| sectionService = new SectionService( | ||
| sectionContentDataService, | ||
| tutorialContentDataService | ||
| ); | ||
| } | ||
|
|
||
| [Test] | ||
| public void GetSectionsAndTutorialsForCustomisation_returns_fully_populated_list() | ||
| { | ||
| // Given | ||
| var tutorialOne = new Tutorial(1, "Test", true, true); | ||
| var tutorialTwo = new Tutorial(2, "Case", false, false); | ||
| var tutorials = new List<Tutorial> { tutorialOne, tutorialTwo }; | ||
| var sectionOne = new Section(1, "Section"); | ||
| var sectionTwo = new Section(2, "Second Section"); | ||
| A.CallTo(() => sectionContentDataService.GetSectionsByApplicationId(1)) | ||
| .Returns(new List<Section> { sectionOne, sectionTwo }); | ||
| A.CallTo(() => tutorialContentDataService.GetTutorialsBySectionId(A<int>._, 1)) | ||
| .Returns(tutorials); | ||
|
|
||
| // When | ||
| var result = sectionService.GetSectionsAndTutorialsForCustomisation(1, 1).ToList(); | ||
|
|
||
| // Then | ||
| using (new AssertionScope()) | ||
| { | ||
| A.CallTo(() => tutorialContentDataService.GetTutorialsBySectionId(A<int>._, 1)) | ||
| .MustHaveHappenedTwiceExactly(); | ||
| result.Count.Should().Be(2); | ||
| result.First().SectionId.Should().Be(1); | ||
| result.First().SectionName.Should().Be("Section"); | ||
| result.First().Tutorials.Should().BeEquivalentTo(tutorials); | ||
| } | ||
| } | ||
|
|
||
| [Test] | ||
| public void GetSectionAndTutorialsBySectionIdForCustomisation_returns_fully_populated_Section() | ||
| { | ||
| // Given | ||
| var tutorialOne = new Tutorial(1, "Test", true, true); | ||
| var tutorialTwo = new Tutorial(2, "Case", false, false); | ||
| var tutorials = new List<Tutorial> { tutorialOne, tutorialTwo }; | ||
| var section = new Section(1, "Section"); | ||
| A.CallTo(() => sectionContentDataService.GetSectionById(1)) | ||
| .Returns(section); | ||
| A.CallTo(() => tutorialContentDataService.GetTutorialsBySectionId(A<int>._, 1)) | ||
| .Returns(tutorials); | ||
|
|
||
| // When | ||
| var result = sectionService.GetSectionAndTutorialsBySectionIdForCustomisation(1, 1); | ||
|
|
||
| // Then | ||
| using (new AssertionScope()) | ||
| { | ||
| A.CallTo(() => tutorialContentDataService.GetTutorialsBySectionId(A<int>._, 1)) | ||
| .MustHaveHappenedOnceExactly(); | ||
| result?.SectionId.Should().Be(1); | ||
| result?.SectionName.Should().Be("Section"); | ||
| result?.Tutorials.Should().BeEquivalentTo(tutorials); | ||
| } | ||
| } | ||
|
|
||
| [Test] | ||
| public void GetSectionAndTutorialsBySectionIdForCustomisation_returns_null_if_section_not_found() | ||
| { | ||
| // Given | ||
| A.CallTo(() => sectionContentDataService.GetSectionById(1)) | ||
| .Returns(null); | ||
|
|
||
| // When | ||
| var result = sectionService.GetSectionAndTutorialsBySectionIdForCustomisation(1, 1); | ||
|
|
||
| // Then | ||
| using (new AssertionScope()) | ||
| { | ||
| result.Should().BeNull(); | ||
| A.CallTo(() => tutorialContentDataService.GetTutorialsBySectionId(A<int>._, 1)) | ||
| .MustNotHaveHappened(); | ||
| } | ||
| } | ||
| } | ||
| } |
68 changes: 68 additions & 0 deletions
68
DigitalLearningSolutions.Data.Tests/Services/TutorialServiceTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| namespace DigitalLearningSolutions.Data.Tests.Services | ||
| { | ||
| using System.Collections.Generic; | ||
| using DigitalLearningSolutions.Data.DataServices; | ||
| using DigitalLearningSolutions.Data.Models; | ||
| using DigitalLearningSolutions.Data.Services; | ||
| using FakeItEasy; | ||
| using FluentAssertions.Execution; | ||
| using NUnit.Framework; | ||
|
|
||
| public class TutorialServiceTests | ||
| { | ||
| private IProgressDataService progressDataService = null!; | ||
| private ITutorialContentDataService tutorialContentDataService = null!; | ||
| private ITutorialService tutorialService = null!; | ||
|
|
||
| [SetUp] | ||
| public void Setup() | ||
| { | ||
| progressDataService = A.Fake<IProgressDataService>(); | ||
| tutorialContentDataService = A.Fake<ITutorialContentDataService>(); | ||
|
|
||
| tutorialService = new TutorialService( | ||
| tutorialContentDataService, | ||
| progressDataService | ||
| ); | ||
| } | ||
|
|
||
| [Test] | ||
| public void UpdateTutorialsStatuses_calls_data_services_correct_number_of_times() | ||
| { | ||
| // Given | ||
| var tutorialOne = new Tutorial(1, "Test", true, true); | ||
| var tutorialTwo = new Tutorial(2, "Case", false, false); | ||
| var tutorials = new List<Tutorial> { tutorialOne, tutorialTwo }; | ||
| A.CallTo( | ||
| () => tutorialContentDataService.UpdateOrInsertCustomisationTutorialStatuses( | ||
| A<int>._, | ||
| A<int>._, | ||
| A<bool>._, | ||
| A<bool>._ | ||
| ) | ||
| ) | ||
| .DoesNothing(); | ||
| A.CallTo(() => progressDataService.InsertNewAspProgressRecordsForTutorialIfNoneExist(A<int>._, A<int>._)) | ||
| .DoesNothing(); | ||
|
|
||
| // When | ||
| tutorialService.UpdateTutorialsStatuses(tutorials, 1); | ||
|
|
||
| // Then | ||
| using (new AssertionScope()) | ||
| { | ||
| A.CallTo( | ||
| () => tutorialContentDataService.UpdateOrInsertCustomisationTutorialStatuses( | ||
| A<int>._, | ||
| A<int>._, | ||
| A<bool>._, | ||
| A<bool>._ | ||
| ) | ||
| ) | ||
| .MustHaveHappened(2, Times.Exactly); | ||
| A.CallTo(() => progressDataService.InsertNewAspProgressRecordsForTutorialIfNoneExist(A<int>._, A<int>._)) | ||
| .MustHaveHappened(2, Times.Exactly); | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.