voc list factory UT
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
0663a0357a
commit
ca708a5c0b
@ -0,0 +1,92 @@
|
||||
using adminBlazor.Factories;
|
||||
using adminBlazor.Models;
|
||||
|
||||
namespace TestUnit
|
||||
{
|
||||
public class VocListFactory_UT
|
||||
{
|
||||
public static IEnumerable<object[]> Dataset()
|
||||
{
|
||||
yield return new object[]
|
||||
{
|
||||
new VocabularyListModel[]
|
||||
{
|
||||
new ()
|
||||
{
|
||||
Id = 0,
|
||||
Name = "name",
|
||||
Image = new byte[] { 0x00 },
|
||||
Aut = 42,
|
||||
Translations = new List<TranslationModel>()
|
||||
},
|
||||
new()
|
||||
{
|
||||
Id = 1,
|
||||
Name = "name2",
|
||||
Image = new byte[] { 0x00, 0x01 },
|
||||
Aut = 50,
|
||||
Translations = new List<TranslationModel>()
|
||||
},
|
||||
new()
|
||||
{
|
||||
Id = 1,
|
||||
Name = "name3",
|
||||
Image = new byte[] { 0x00, 0x01, 0x02 },
|
||||
Aut = 60,
|
||||
Translations = new List<TranslationModel>()
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
[Theory]
|
||||
[MemberData(nameof(Dataset))]
|
||||
public void Create_Validation(VocabularyListModel[] vocabListMdls)
|
||||
{
|
||||
foreach (var vocabListMdl in vocabListMdls)
|
||||
{
|
||||
var vocabList = VocListFactory.Create(vocabListMdl);
|
||||
|
||||
Assert.Equal(vocabListMdl.Id, vocabList.Id);
|
||||
Assert.Equal(vocabListMdl.Name, vocabList.Name);
|
||||
Assert.Equal(vocabListMdl.Aut, vocabList.Aut);
|
||||
Assert.Equal(vocabListMdl.Image, vocabList.Image);
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(Dataset))]
|
||||
public void Update_Validation(VocabularyListModel[] vocabListMdls)
|
||||
{
|
||||
foreach (var vocabListMdl in vocabListMdls)
|
||||
{
|
||||
var vocabList = VocListFactory.Create(vocabListMdl);
|
||||
|
||||
vocabListMdl.Name = "a";
|
||||
vocabListMdl.Aut = 100;
|
||||
vocabListMdl.Image = new byte[] { 1, 2, 3 };
|
||||
|
||||
VocListFactory.Update(vocabList, vocabListMdl);
|
||||
|
||||
Assert.Equal(vocabListMdl.Id, vocabList.Id);
|
||||
Assert.Equal(vocabListMdl.Name, vocabList.Name);
|
||||
Assert.Equal(vocabListMdl.Aut, vocabList.Aut);
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(Dataset))]
|
||||
public void ToModel_Validation(VocabularyListModel[] vocabListMdls)
|
||||
{
|
||||
foreach (var vocabListMdl in vocabListMdls)
|
||||
{
|
||||
var vocabList = VocListFactory.Create(vocabListMdl);
|
||||
var vocabListMdl2 = VocListFactory.ToModel(vocabList, Array.Empty<byte>());
|
||||
|
||||
Assert.Equal(vocabListMdl.Id, vocabListMdl2.Id);
|
||||
Assert.Equal(vocabListMdl.Name, vocabListMdl2.Name);
|
||||
Assert.Equal(vocabListMdl.Aut, vocabListMdl2.Aut);
|
||||
Assert.Equal(vocabListMdl.Image, vocabListMdl2.Image);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue