-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
91 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
87 changes: 87 additions & 0 deletions
87
Rdmp.Core.Tests/CommandExecution/ExecuteCommandChangeExtractionCategoryTests.cs
This file contains 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,87 @@ | ||
// Copyright (c) The University of Dundee 2024-2024 | ||
// This file is part of the Research Data Management Platform (RDMP). | ||
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
// You should have received a copy of the GNU General Public License along with RDMP. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
using NUnit.Framework; | ||
using Rdmp.Core.CommandExecution; | ||
using Rdmp.Core.CommandExecution.AtomicCommands; | ||
using Rdmp.Core.Curation.Data; | ||
using Rdmp.Core.Repositories; | ||
using System.Linq; | ||
using Tests.Common; | ||
using NSubstitute; | ||
using NSubstitute.Extensions; | ||
using Rdmp.Core.DataExport.Data; | ||
using Rdmp.Core.Curation.Data.Aggregation; | ||
using static Org.BouncyCastle.Math.EC.ECCurve; | ||
namespace Rdmp.Core.Tests.CommandExecution; | ||
|
||
public class ExecuteCommandChangeExtractionCategoryTests : DatabaseTests | ||
{ | ||
private Catalogue _cata1; | ||
private Catalogue _cata2; | ||
private TableInfo _t1; | ||
private TableInfo _t2; | ||
private ColumnInfo _c1; | ||
private ColumnInfo _c2; | ||
private CatalogueItem _ci1; | ||
private CatalogueItem _ci2; | ||
private Project _project; | ||
|
||
private ExtractionInformation _extractionInfo1; | ||
private ExtractionInformation _extractionInfo2; | ||
|
||
[Test] | ||
public void TestProjectSpecificCatalogueChangeToSuplemental() | ||
{ | ||
//change project specific to supplemental | ||
_cata1 =new Catalogue(CatalogueRepository, "Dataset1"); | ||
_t1 = new TableInfo(CatalogueRepository, "T1"); | ||
|
||
_c1 = new ColumnInfo(CatalogueRepository, "PrivateIdentifierA", "varchar(10)", _t1); | ||
|
||
_ci1 = new CatalogueItem(CatalogueRepository, _cata1, "PrivateIdentifierA"); | ||
|
||
_extractionInfo1 = new ExtractionInformation(CatalogueRepository, _ci1, _c1, _c1.ToString()) | ||
{ | ||
Order = 123, | ||
ExtractionCategory = ExtractionCategory.ProjectSpecific, | ||
IsExtractionIdentifier = true | ||
}; | ||
_extractionInfo1.CatalogueItem.Catalogue.InjectKnown(new CatalogueExtractabilityStatus(true, true)); | ||
|
||
ExtractionInformation[] eid = { _extractionInfo1 }; | ||
var cmd = new ExecuteCommandChangeExtractionCategory(new ThrowImmediatelyActivator(RepositoryLocator), eid, ExtractionCategory.Supplemental); | ||
Assert.DoesNotThrow(() => cmd.Execute()); | ||
Assert.That(_extractionInfo1.ExtractionCategory, Is.EqualTo(ExtractionCategory.Supplemental)); | ||
} | ||
|
||
[Test] | ||
public void TestExtractionCategoryCatalogueChangeFromSupplementalToCore() | ||
{ | ||
//change a project specific column to core | ||
_cata1 = new Catalogue(CatalogueRepository, "Dataset1"); | ||
_t1 = new TableInfo(CatalogueRepository, "T1"); | ||
|
||
_c1 = new ColumnInfo(CatalogueRepository, "PrivateIdentifierA", "varchar(10)", _t1); | ||
|
||
_ci1 = new CatalogueItem(CatalogueRepository, _cata1, "PrivateIdentifierA"); | ||
|
||
|
||
_extractionInfo1 = new ExtractionInformation(CatalogueRepository, _ci1, _c1, _c1.ToString()) | ||
{ | ||
Order = 123, | ||
ExtractionCategory = ExtractionCategory.Supplemental, | ||
IsExtractionIdentifier = true | ||
}; | ||
_extractionInfo1.CatalogueItem.Catalogue.InjectKnown(new CatalogueExtractabilityStatus(true, true)); | ||
|
||
ExtractionInformation[] eid = { _extractionInfo1 }; | ||
var cmd = new ExecuteCommandChangeExtractionCategory(new ThrowImmediatelyActivator(RepositoryLocator), eid, ExtractionCategory.Core); | ||
Assert.DoesNotThrow(() => cmd.Execute()); | ||
var x = CatalogueRepository.GetAllObjects<ExtractionInformation>(); | ||
Check warning Code scanning / CodeQL Useless assignment to local variable Warning test
This assignment to
x Error loading related location Loading |
||
Assert.That(_extractionInfo1.ExtractionCategory, Is.EqualTo(ExtractionCategory.ProjectSpecific)); | ||
} | ||
} |
This file contains 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