Skip to content

Commit

Permalink
Annotated some tests in Presentation, Integration and BackendAccess w…
Browse files Browse the repository at this point in the history
…ith requirements id
  • Loading branch information
andreasweishaupt committed Jul 23, 2024
1 parent 8607fd4 commit 1c303ca
Show file tree
Hide file tree
Showing 22 changed files with 85 additions and 6 deletions.
10 changes: 6 additions & 4 deletions BackendAccessTest/BackendServices/UserWebApiServicesUt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,16 @@ public void GetUserTokenAsync_InvalidUrlSet_ThrowsException()
var mockHttpMessageHandler = new MockHttpMessageHandler();
httpClientFactory.CreateClient(Arg.Any<ProgressMessageHandler>())
.Returns(new HttpClient(mockHttpMessageHandler));

mockHttpMessageHandler.When("*").Throw(new HttpRequestException("Invalid URL", new SocketException()));

var userWebApiServices =
CreateTestableUserWebApiServices(applicationConfiguration, httpClientFactory: httpClientFactory);

var ex = Assert.ThrowsAsync<BackendInvalidUrlException>(async () =>
await userWebApiServices.GetUserTokenAsync("username", "password"));
Assert.That(ex!.Message, Is.EqualTo("The URL is not reachable. Either the URL does not exist or there is no internet connection."));
Assert.That(ex!.Message,
Is.EqualTo("The URL is not reachable. Either the URL does not exist or there is no internet connection."));
}

[Test]
Expand Down Expand Up @@ -739,7 +740,7 @@ public async Task DeleteLmsWorld_ValidRequest_ReturnsTrue()

mockedHttp.VerifyNoOutstandingExpectation();
}

private static IPreflightHttpClient CreatePreflightHttpClient()
{
var mockHttpHandler = new MockHttpMessageHandler();
Expand Down Expand Up @@ -772,6 +773,7 @@ private static UserWebApiServices CreateTestableUserWebApiServices(
fileSystem ??= Substitute.For<IFileSystem>();
preflightHttpClient ??= CreatePreflightHttpClient();

return new UserWebApiServices(configuration, progressMessageHandler, httpClientFactory, logger, fileSystem, preflightHttpClient);
return new UserWebApiServices(configuration, progressMessageHandler, httpClientFactory, logger, fileSystem,
preflightHttpClient);
}
}
3 changes: 3 additions & 0 deletions IntegrationTest/CachingMapperIt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace IntegrationTest;
public class CachingMapperIt
{
[Test]
// ANF-ID: [ASN0003, ASN0004]
public void CreateWorldThenUndoAndRedo_ViewModelShouldStayTheSame()
{
var commandStateManager = new CommandStateManager();
Expand Down Expand Up @@ -73,6 +74,7 @@ public void CreateWorldThenUndoAndRedo_ViewModelShouldStayTheSame()
}

[Test]
// ANF-ID: [ASN0003, ASN0004]
public void CreateWorldAndSpaceThenUndoAndRedo_CheckIfWorldViewModelStaysTheSame()
{
var commandStateManager = new CommandStateManager();
Expand Down Expand Up @@ -134,6 +136,7 @@ public void CreateWorldAndSpaceThenUndoAndRedo_CheckIfWorldViewModelStaysTheSame
}

[Test]
// ANF-ID: [ASN0003, ASN0004]
public void CreateWorldAndSpaceAndElementThenUndoAndRedo_CheckIfAllViewModelsStayTheSame()
{
var commandStateManager = new CommandStateManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void Render_ShowsAllFloorPlanValues_AndShowsSelectedFloorPlan()
}

[Test]
// ANF-ID: [AWA0023]
public async Task ClickFloorPlan_SetsFloorPlanInSpace()
{
var floorPlanValues = Enum.GetValues<FloorPlanEnum>();
Expand Down
11 changes: 11 additions & 0 deletions IntegrationTest/Dialogues/LmsLoginDialogIt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public async Task DialogCreated_CallsPresentationLogicForLmsConnection()
}

[Test]
// ANF-ID: [AHO21]
public async Task DialogCreated_LmsNotConnected_RenderLmsLoginDialogWithForm()
{
_presentationLogic.IsLmsConnected().Returns(false);
Expand Down Expand Up @@ -97,6 +98,7 @@ public async Task DialogCreated_LmsNotConnected_RenderLmsLoginDialogWithForm()
}

[Test]
// ANF-ID: [AHO25]
public async Task DialogCreated_LmsConnected_RenderLmsLoginDialogWithWorldsAndLogoutButton()
{
_presentationLogic.IsLmsConnected().Returns(true);
Expand Down Expand Up @@ -151,6 +153,7 @@ public async Task DialogCreated_LmsConnected_RenderLmsLoginDialogWithWorldsAndLo
}

[Test]
// ANF-ID: [AHO21]
public async Task DialogCreated_IsLmsConnectedThrowsBackendApiUnreachableException_ShowsErrorMessage()
{
_presentationLogic.IsLmsConnected().Throws(x => throw new BackendApiUnreachableException());
Expand All @@ -165,6 +168,7 @@ public async Task DialogCreated_IsLmsConnectedThrowsBackendApiUnreachableExcepti
}

[Test]
// ANF-ID: [AHO21]
public async Task DialogCreated_IsLmsConnectedThrowsBackendInvalidTokenException_ShowsErrorMessageAndCallsLogout()
{
var exceptionThrown = false;
Expand Down Expand Up @@ -192,6 +196,7 @@ public async Task DialogCreated_IsLmsConnectedThrowsBackendInvalidTokenException
}

[Test]
// ANF-ID: [AHO23]
public async Task DialogCreated_LmsIsConnected_GetLmsWorldListThrowsBackendException_SetErrorInErrorService()
{
_presentationLogic.IsLmsConnected().Returns(true);
Expand All @@ -202,6 +207,7 @@ public async Task DialogCreated_LmsIsConnected_GetLmsWorldListThrowsBackendExcep
}

[Test]
// ANF-ID: [AHO21]
public async Task EnterDetailsAndClickLoginButton_MissingValue_NothingHappens()
{
_presentationLogic.IsLmsConnected().Returns(false);
Expand Down Expand Up @@ -238,6 +244,7 @@ public async Task EnterDetailsAndClickLoginButton_CallsPresentationLogic()
}

[Test]
// ANF-ID: [AHO21]
public async Task EnterDetailsAndPressEnterInPasswordField_CallsPresentationLogic()
{
_presentationLogic.IsLmsConnected().Returns(false);
Expand All @@ -255,6 +262,7 @@ public async Task EnterDetailsAndPressEnterInPasswordField_CallsPresentationLogi
}

[Test]
// ANF-ID: [AHO21, AHO23]
public async Task EnterDetailsAndClickLoginButton_CorrectCredentials_CallsGetLmsWorldListInPresentationLogic()
{
_presentationLogic.IsLmsConnected().Returns(false);
Expand Down Expand Up @@ -428,6 +436,7 @@ public async Task IsLmsConnectedTrue_LogoutButtonClicked_CallsLogout()
}

[Test]
// ANF-ID: [AHO24]
public async Task DeleteWorldButtonClicked_CancelDialog_NothingHappens()
{
var dialogReference = Substitute.For<IDialogReference>();
Expand Down Expand Up @@ -458,6 +467,7 @@ await dialogService.Received(1)
}

[Test]
// ANF-ID: [AHO24]
public async Task DeleteWorldButtonClicked_ConfirmDialog_CallsDeleteLmsWorldAndGetLmsWorldList()
{
var dialogReference = Substitute.For<IDialogReference>();
Expand Down Expand Up @@ -490,6 +500,7 @@ await dialogService.Received(1)
}

[Test]
// ANF-ID: [AHO24]
public async Task
DeleteWorldButtonClicked_ConfirmDialog_PresentationLogicThrowsBackendException_SetsErrorInErrorService()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private async Task GetDialogAsync()


[Test]
// ANF-ID: [AHO02]
public async Task ClickSubmit_NoCurrentOutcome_ShouldCallPresentationLogicAddOutcome()
{
await GetDialogAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private async Task GetDialogAsync()
}

[Test]
// ANF-ID: [AHO01]
// ANF-ID: [AHO01, AHO03]
public async Task SubmitWithOutCurrentLearningOutcome_VerbNotSet_DoesNotCallAddStructuredLearningOutcome()
{
await GetDialogAsync();
Expand Down Expand Up @@ -240,6 +240,7 @@ public async Task SubmitWithCurrentLearningOutcome_CallsEditStructuredLearningOu
}

[Test]
// ANF-ID: [AHO01, AHO03]
public async Task Reset_ResetsAllFields()
{
await GetDialogAsync();
Expand Down
3 changes: 3 additions & 0 deletions IntegrationTest/Dialogues/ReplaceCopyLmsWorldDialogIt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public void Teardown()
}

[Test]
// ANF-ID: [AHO22]
public async Task CopyButtonPressed_CallsDialogAndReturnsResult()
{
var dialog = await OpenDialogAndGetDialogReferenceAsync();
Expand All @@ -42,6 +43,7 @@ public async Task CopyButtonPressed_CallsDialogAndReturnsResult()
}

[Test]
// ANF-ID: [AHO22]
public async Task CancelButtonPressed_CallsDialogAndReturnsResult()
{
var dialog = await OpenDialogAndGetDialogReferenceAsync();
Expand All @@ -55,6 +57,7 @@ public async Task CancelButtonPressed_CallsDialogAndReturnsResult()
}

[Test]
// ANF-ID: [AHO22]
public async Task ReplaceButtonPressed_CallsDialogAndReturnsResult()
{
var dialog = await OpenDialogAndGetDialogReferenceAsync();
Expand Down
3 changes: 3 additions & 0 deletions IntegrationTest/Dialogues/UnsavedWorldDialogIt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void Render_RendersParametersCorrectly()
}

[Test]
// ANF-ID: [ASE6]
public async Task YesButtonPressed_ReturnsPositiveResponse()
{
var dialog = await OpenDialogAndGetDialogReferenceAsync();
Expand All @@ -46,6 +47,7 @@ public async Task YesButtonPressed_ReturnsPositiveResponse()
}

[Test]
// ANF-ID: [ASE6]
public async Task NoButtonPressed_ReturnsNegativeResponse()
{
var dialog = await OpenDialogAndGetDialogReferenceAsync();
Expand All @@ -56,6 +58,7 @@ public async Task NoButtonPressed_ReturnsNegativeResponse()
}

[Test]
// ANF-ID: [ASE6]
public async Task CancelButtonPressed_ReturnsCancelledResponse()
{
var dialog = await OpenDialogAndGetDialogReferenceAsync();
Expand Down
3 changes: 3 additions & 0 deletions IntegrationTest/Dialogues/UploadSuccessfulDialogIt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public void TearDown()
private IShellWrapper _shellwrapper;

[Test]
// ANF-ID: [AHO22]
public async Task OkButtonPressed_ResultNotNull()
{
var parameters = new DialogParameters
Expand All @@ -48,6 +49,7 @@ public async Task OkButtonPressed_ResultNotNull()
}

[Test]
// ANF-ID: [AHO22]
public async Task Open3DButtonPressed_CallsShellWrapperOpenUrl()
{
var parameters = new DialogParameters
Expand All @@ -66,6 +68,7 @@ public async Task Open3DButtonPressed_CallsShellWrapperOpenUrl()
}

[Test]
// ANF-ID: [AHO22]
public async Task OpenMoodleButtonPressed_CallsShellWrapperOpenUrl()
{
var parameters = new DialogParameters
Expand Down
1 change: 1 addition & 0 deletions PresentationTest/Components/CloseAppButtonUt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public void TearDown()
private IShutdownManager _shutdownManager;

[Test]
// ANF-ID: [ASN0025]
public void OnClick_CallsShutdownManager()
{
using (_context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public void Render_PresentationLogicReturnsSomeItems_ItemsAreRendered()
}

[Test]
// ANF-ID: [AWA0037, AWA0043]
public void ClickDelete_ShowsDialog_DeletesOnOkIfNotInWorlds()
{
var items = PresentationLogicSetItems().ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public void Constructor_InjectsDependencies()
}

[Test]
// ANF-ID: [ASN0031]
public void Render_RendersUnplacedItems()
{
var expectedItem1 = Substitute.For<ILearningElementViewModel>();
Expand Down Expand Up @@ -207,6 +208,7 @@ public void Render_RendersFilters()
[TestCase("")]
[TestCase("1")]
[TestCase("xyz")]
// ANF-ID: [ASN0029]
public async Task Filter_SearchText_ShowFilteredItems(string searchString)
{
var items = GetTestItems();
Expand Down Expand Up @@ -239,6 +241,7 @@ public async Task Filter_SearchText_ShowFilteredItems(string searchString)
[TestCase(new[] { "StoryElement", "LearningElement" }, 9)]
[TestCase(new[] { "AdaptivityElement", "LearningElement" }, 9)]
[TestCase(new[] { "StoryElement", "AdaptivityElement", "LearningElement" }, 11)]
// ANF-ID: [ASN0030]
public async Task Filter_ElementType_ShowFilteredItems(string[] elementTypes, int expectedCount)
{
// Arrange
Expand Down Expand Up @@ -269,6 +272,7 @@ public async Task Filter_ElementType_ShowFilteredItems(string[] elementTypes, in
}

[Test]
// ANF-ID: [ASN0030]
public async Task Filter_ElementType_AddAndRemoveFilters()
{
var items = GetTestItems();
Expand Down Expand Up @@ -331,6 +335,7 @@ public async Task Filter_ElementType_AddAndRemoveFilters()
[TestCase(new[] { "Adaptivity", "Story" }, 4)]
[TestCase(new[] { "Text", "Image", "Video", "H5P" }, 7)]
[TestCase(new[] { "Text", "Image", "Video", "H5P", "Adaptivity", "Story" }, 11)]
// ANF-ID: [ASN0030]
public async Task Filter_ContentType_ShowFilteredItems(string[] contentTypes, int expectedCount)
{
// Arrange
Expand Down Expand Up @@ -361,6 +366,7 @@ public async Task Filter_ContentType_ShowFilteredItems(string[] contentTypes, in
}

[Test]
// ANF-ID: [ASN0030]
public async Task Filter_ContentType_AddAndRemoveFilters()
{
var items = GetTestItems();
Expand Down Expand Up @@ -417,6 +423,7 @@ public async Task Filter_ContentType_AddAndRemoveFilters()
[TestCase(new[] { "Medium" }, 3)]
[TestCase(new[] { "Hard" }, 2)]
[TestCase(new[] { "Easy", "Medium", "Hard" }, 9)]
// ANF-ID: [ASN0030]
public async Task Filter_Difficulty_ShowFilteredItems(string[] contentTypes,
int expectedCount)
{
Expand Down Expand Up @@ -448,6 +455,7 @@ public async Task Filter_Difficulty_ShowFilteredItems(string[] contentTypes,
}

[Test]
// ANF-ID: [ASN0030]
public async Task Filter_Difficulty_AddAndRemoveFilters()
{
var items = GetTestItems();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void Dispose_UnregistersFromPresenterEvent()
}

[Test]
// ANF-ID: [AWA0001]
public void Render_SpaceNull_ShowsCreate()
{
Presenter.LearningSpaceVm.Returns((ILearningSpaceViewModel?)null);
Expand All @@ -76,6 +77,7 @@ public void Render_SpaceNull_ShowsCreate()
}

[Test]
// ANF-ID: [AWA0023]
public void Render_SpaceNotNull_ShowsEdit()
{
Presenter.LearningSpaceVm.Returns(Substitute.For<ILearningSpaceViewModel>());
Expand All @@ -93,6 +95,7 @@ public void Render_SpaceNotNull_ShowsEdit()
}

[Test]
// ANF-ID: [AWA0001]
public async Task OnForceNew_ForcesNew()
{
Presenter.LearningSpaceVm.Returns(Substitute.For<ILearningSpaceViewModel>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public void Dispose_UnregistersFromPresenterEvent()
}

[Test]
// ANF-ID: [ASE1]
public void Render_WorldNull_ShowsCreate()
{
Presenter.LearningWorldVm.Returns((ILearningWorldViewModel?)null);
Expand All @@ -70,6 +71,7 @@ public void Render_WorldNull_ShowsCreate()
}

[Test]
// ANF-ID: [ASE3]
public void Render_WorldNotNull_ShowsEdit()
{
Presenter.LearningWorldVm.Returns(ViewModelProvider.GetLearningWorld());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void Render_ShouldRenderLearningOutcomeItem()
}

[Test]
// ANF-ID: [AHO04]
public void ClickEdit_ManualOutcome_ShouldCallDialogProviderWithManualOutcomeDialog()
{
var collection = new LearningOutcomeCollectionViewModel();
Expand All @@ -73,6 +74,7 @@ public void ClickEdit_ManualOutcome_ShouldCallDialogProviderWithManualOutcomeDia
}

[Test]
// ANF-ID: [AHO03]
public void ClickEdit_StructuredOutcome_ShouldCallDialogProviderWithManualOutcomeDialog()
{
var collection = new LearningOutcomeCollectionViewModel();
Expand All @@ -90,6 +92,7 @@ public void ClickEdit_StructuredOutcome_ShouldCallDialogProviderWithManualOutcom
}

[Test]
// ANF-ID: [AHO05]
public void ClickDelete_ShouldCallPresentationLogic()
{
var collection = new LearningOutcomeCollectionViewModel();
Expand Down
Loading

0 comments on commit 1c303ca

Please sign in to comment.