-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix namespace typo; add corpus service tests
- Loading branch information
Showing
12 changed files
with
67 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Serval.Corpora.Contracts; | ||
namespace Serval.DataFiles.Contracts; | ||
|
||
public record CorpusConfigDto | ||
{ | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Serval.Corpora.Contracts; | ||
namespace Serval.DataFiles.Contracts; | ||
|
||
public record CorpusDto | ||
{ | ||
|
2 changes: 1 addition & 1 deletion
2
src/Serval/src/Serval.DataFiles/Contracts/CorpusFileConfigDto.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Serval.Corpora.Contracts; | ||
namespace Serval.DataFiles.Contracts; | ||
|
||
public record CorpusFileConfigDto | ||
{ | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Serval.Corpora.Contracts; | ||
namespace Serval.DataFiles.Contracts; | ||
|
||
public record CorpusFileDto | ||
{ | ||
|
2 changes: 1 addition & 1 deletion
2
src/Serval/src/Serval.DataFiles/Controllers/CorporaController.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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Serval.Corpora.Models; | ||
namespace Serval.DataFiles.Models; | ||
|
||
public record Corpus : IOwnedEntity | ||
{ | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Serval.Corpora.Contracts; | ||
namespace Serval.DataFiles.Models; | ||
|
||
public record CorpusFile | ||
{ | ||
|
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Serval.Corpora.Services; | ||
namespace Serval.DataFiles.Services; | ||
|
||
public interface ICorpusService | ||
{ | ||
|
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
2 changes: 1 addition & 1 deletion
2
src/Serval/src/Serval.Translation/Models/ParallelCorpusSubcorpus.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
57 changes: 57 additions & 0 deletions
57
src/Serval/test/Serval.DataFiles.Tests/Services/CorpusServiceTests.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,57 @@ | ||
namespace Serval.DataFiles.Services; | ||
|
||
[TestFixture] | ||
public class CorpusServiceTests | ||
{ | ||
private const string CorpusId = "c00000000000000000000001"; | ||
|
||
private static readonly DataFile DefaultDataFile = | ||
new() | ||
{ | ||
Id = "df0000000000000000000001", | ||
Owner = "owner1", | ||
Name = "file1", | ||
Filename = "file1.txt", | ||
Format = FileFormat.Text | ||
}; | ||
private static readonly Corpus DefaultCorpus = | ||
new() | ||
{ | ||
Id = CorpusId, | ||
Owner = "owner1", | ||
Name = "corpus1", | ||
Language = "en", | ||
Files = new List<CorpusFile>() { new() { File = DefaultDataFile } } | ||
}; | ||
|
||
[Test] | ||
public async Task CreateAsync() | ||
{ | ||
var env = new TestEnvironment(); | ||
Corpus corpus = await env.Service.CreateAsync(DefaultCorpus); | ||
Assert.That(corpus.Name, Is.EqualTo((await env.Service.GetAsync(CorpusId)).Name)); | ||
} | ||
|
||
[Test] | ||
public async Task UpdateAsync() | ||
{ | ||
var env = new TestEnvironment(); | ||
await env.Service.CreateAsync(DefaultCorpus); | ||
await env.Service.UpdateAsync(CorpusId, new List<CorpusFile>()); | ||
Corpus corpus = await env.Service.GetAsync(CorpusId); | ||
Assert.That(corpus.Files, Has.Count.EqualTo(0)); | ||
} | ||
|
||
private class TestEnvironment | ||
{ | ||
public TestEnvironment() | ||
{ | ||
Corpora = new MemoryRepository<Corpus>(); | ||
Service = new CorpusService(Corpora); | ||
} | ||
|
||
public MemoryRepository<Corpus> Corpora { get; } | ||
|
||
public CorpusService Service { get; } | ||
} | ||
} |