diff --git a/DataAccessTest/API/DataAccessUt.cs b/DataAccessTest/API/DataAccessUt.cs index e079fd3e..5d66d13c 100644 --- a/DataAccessTest/API/DataAccessUt.cs +++ b/DataAccessTest/API/DataAccessUt.cs @@ -55,6 +55,7 @@ public void Standard_AllPropertiesInitialized() } [Test] + // ANF-ID: [ASE6] public void SaveLearningWorldToFile_CallsFileSaveHandlerWorld() { var mockFileSaveHandlerWorld = Substitute.For>(); @@ -69,6 +70,7 @@ public void SaveLearningWorldToFile_CallsFileSaveHandlerWorld() } [Test] + // ANF-ID: [ASE2] public void LoadLearningWorldFromFile_CallsFileSaveHandlerWorld() { var mockFileSaveHandlerWorld = Substitute.For>(); @@ -80,6 +82,7 @@ public void LoadLearningWorldFromFile_CallsFileSaveHandlerWorld() } [Test] + // ANF-ID: [ASE2] public void LoadLearningWorldFromStream_CallsFileSaveHandlerWorld() { var mockFileSaveHandlerWorld = Substitute.For>(); @@ -330,7 +333,7 @@ public async Task ExportLearningWorldToArchive_ConstructsZipCorrectly() var expectedZip = ZipExtensions.GetZipArchive(filesystem, "C:\\export_test.zip"); Assert.That(expectedZip.Entries, Has.Count.EqualTo(3)); - + var png = expectedZip.Entries[1]; using var pngMemStream = new MemoryStream(); png.Open().CopyTo(pngMemStream); @@ -343,7 +346,7 @@ public async Task ExportLearningWorldToArchive_ConstructsZipCorrectly() using var worldMemStream = new MemoryStream(); world.Open().CopyTo(worldMemStream); var worldData = worldMemStream.ToArray(); - + Assert.Multiple(() => { Assert.That(png.Name, Is.EqualTo("adler_logo.png")); @@ -370,18 +373,17 @@ public void GetAllContent_CallsContentFileHandlerAndMapper() contentFileHandler.GetAllContent().Returns(content); mapper.Map(content[0]).Returns(contentEntities[0]); mapper.Map(content[1]).Returns(contentEntities[1]); - + var systemUnderTest = CreateTestableDataAccess(contentHandler: contentFileHandler, mapper: mapper); - + var retval = systemUnderTest.GetAllContent(); - + Assert.That(retval, Is.EquivalentTo(contentEntities)); contentFileHandler.Received().GetAllContent(); mapper.Received().Map(content[0]); mapper.Received().Map(content[1]); - } - + [Test] public void RemoveContent_CallsContentFileHandlerAndMapper() { @@ -390,11 +392,11 @@ public void RemoveContent_CallsContentFileHandlerAndMapper() var content = EntityProvider.GetFileContent(); var contentPe = PersistEntityProvider.GetFileContent(); mapper.Map(content).Returns(contentPe); - + var systemUnderTest = CreateTestableDataAccess(contentHandler: contentFileHandler, mapper: mapper); - + systemUnderTest.RemoveContent(content); - + contentFileHandler.Received().RemoveContent(contentPe); mapper.Received().Map(content); } @@ -407,11 +409,11 @@ public void SaveLink_CallsContentFileHandlerAndMapper() var link = EntityProvider.GetLinkContent(); var linkPe = PersistEntityProvider.GetLinkContent(); mapper.Map(link).Returns(linkPe); - + var systemUnderTest = CreateTestableDataAccess(contentHandler: contentFileHandler, mapper: mapper); - + systemUnderTest.SaveLink(link); - + contentFileHandler.Received().SaveLink(linkPe); mapper.Received().Map(link); } @@ -421,9 +423,9 @@ public void GetContentFilesFolderPath_CallsContentFileHandler() { var contentFileHandler = Substitute.For(); contentFileHandler.ContentFilesFolderPath.Returns("foobarbaz"); - + var systemUnderTest = CreateTestableDataAccess(contentHandler: contentFileHandler); - + Assert.That(systemUnderTest.GetContentFilesFolderPath(), Is.EqualTo("foobarbaz")); } @@ -434,9 +436,9 @@ public void GetFileInfoForPath_CallsFileSystem() var fileInfo = Substitute.For(); filesystem.FileInfo.New("foo").Returns(fileInfo); var systemUnderTest = CreateTestableDataAccess(fileSystem: filesystem); - + var actualFileInfo = systemUnderTest.GetFileInfoForPath("foo"); - + Assert.That(actualFileInfo, Is.EqualTo(fileInfo)); filesystem.FileInfo.Received().New("foo"); } @@ -446,9 +448,9 @@ public void DeleteFileByPath_CallsFileSystem() { var filesystem = Substitute.For(); var systemUnderTest = CreateTestableDataAccess(fileSystem: filesystem); - + systemUnderTest.DeleteFileByPath("foo"); - + filesystem.File.Received().Delete("foo"); } diff --git a/DataAccessTest/Persistence/LearningWorldSavePathsHandlerUt.cs b/DataAccessTest/Persistence/LearningWorldSavePathsHandlerUt.cs index dd774c03..db22fb87 100644 --- a/DataAccessTest/Persistence/LearningWorldSavePathsHandlerUt.cs +++ b/DataAccessTest/Persistence/LearningWorldSavePathsHandlerUt.cs @@ -26,15 +26,16 @@ public void Constructor_InitializesAllProperties() Assert.That(systemUnderTest.FileSystem, Is.EqualTo(fileSystem)); }); } - + [Test] + // ANF-ID: [ASE5] public void GetSavedLearningWorldPaths_ReturnsAllWorldFiles() { var fileSystem = new MockFileSystem(new Dictionary { - {ApplicationPaths.SavedWorldsFolder + "/world1.awf", new MockFileData("world1")}, - {ApplicationPaths.SavedWorldsFolder + "/world2.awf", new MockFileData("world2")}, - {ApplicationPaths.SavedWorldsFolder + "/world3.txt", new MockFileData("world3")}, + { ApplicationPaths.SavedWorldsFolder + "/world1.awf", new MockFileData("world1") }, + { ApplicationPaths.SavedWorldsFolder + "/world2.awf", new MockFileData("world2") }, + { ApplicationPaths.SavedWorldsFolder + "/world3.txt", new MockFileData("world3") }, }); var systemUnderTest = CreateTestableLearningWorldSavePathsHandler(fileSystem: fileSystem); diff --git a/DataAccessTest/Persistence/PersistenceCt.cs b/DataAccessTest/Persistence/PersistenceCt.cs index 2fa08a0a..f5b9f9f3 100644 --- a/DataAccessTest/Persistence/PersistenceCt.cs +++ b/DataAccessTest/Persistence/PersistenceCt.cs @@ -22,6 +22,7 @@ public class PersistenceCt private const string FilePath = "awesomefile.txt"; [Test] + // ANF-ID: [ASE2, ASE6] public void Persistence_SaveAndLoadWorld_Stream_ObjectsAreEquivalent() { var world = PersistEntityProvider.GetLearningWorld(); @@ -167,6 +168,7 @@ public void Persistence_SaveAndLoadElement_Stream_ObjectsAreEquivalent() } [Test] + // ANF-ID: [ASE2, AWA0022, AHO66] public void Persistence_SaveAndLoadWorld_File_ObjectsAreEquivalent() { var world = PersistEntityProvider.GetLearningWorld(); @@ -354,6 +356,7 @@ static ILearningElementPe[] GetAllLearningElementTypes() } [Test] + // ANF-ID: [ASE2, AWA0022, AWA0019] public void SaveAndLoadWorld_WithExactSameElementInTwoSpaces_ElementIsEqualObject() { var content = PersistEntityProvider.GetFileContent(); @@ -392,6 +395,7 @@ public void SaveAndLoadWorld_WithExactSameElementInTwoSpaces_ElementIsEqualObjec } [Test] + // ANF-ID: [ASE2, AWA0018] public void SaveAndLoadWorld_WithTwoEquivalentElementsInTwoSpaces_ElementIsNotEqualObject() { var content = PersistEntityProvider.GetFileContent(); @@ -431,6 +435,7 @@ public void SaveAndLoadWorld_WithTwoEquivalentElementsInTwoSpaces_ElementIsNotEq } [Test] + // ANF-ID: [ASE2, AWA0019] public void SaveAndLoadWorld_WithAdaptivityContentElement_RestoresCorrectly() { var content = PersistEntityProvider.GetAdaptivityContentFullStructure();