|
|
|
@ -1,10 +1,24 @@
|
|
|
|
|
using adminBlazor.Models;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Runtime.Serialization;
|
|
|
|
|
|
|
|
|
|
namespace TestUnit
|
|
|
|
|
{
|
|
|
|
|
public class VocabularyListModel_UT
|
|
|
|
|
{
|
|
|
|
|
public static IEnumerable<object[]> SimpleAttributes()
|
|
|
|
|
{
|
|
|
|
|
yield return new object[]
|
|
|
|
|
{
|
|
|
|
|
new byte[] { 0x00, 0x01, 0x02 },
|
|
|
|
|
42,
|
|
|
|
|
"base64encodedstring",
|
|
|
|
|
new List<TranslationModel>()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
//correct
|
|
|
|
|
[InlineData(true, 0, "name")]
|
|
|
|
@ -23,6 +37,18 @@ namespace TestUnit
|
|
|
|
|
Assert.Equal(isValid, ValidateModel(vocabularyListModel));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[MemberData(nameof(SimpleAttributes))]
|
|
|
|
|
public void SimpleAttribute_Validation(byte[] image, int aut, string imageBase64, List<TranslationModel> translations)
|
|
|
|
|
{
|
|
|
|
|
var vocabularyListModel = new VocabularyListModel { Image = image, Aut = aut, ImageBase64 = imageBase64, Translations = translations };
|
|
|
|
|
|
|
|
|
|
Assert.Equal(image, vocabularyListModel.Image);
|
|
|
|
|
Assert.Equal(aut, vocabularyListModel.Aut);
|
|
|
|
|
Assert.Equal(imageBase64, vocabularyListModel.ImageBase64);
|
|
|
|
|
Assert.Equal(translations, vocabularyListModel.Translations);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool ValidateModel(VocabularyListModel vocabularyListModel)
|
|
|
|
|
{
|
|
|
|
|
var validationContext = new ValidationContext(vocabularyListModel, serviceProvider: null, items: null);
|
|
|
|
|