29 Nisan 2015 Çarşamba
Unit Testte Mock kullanmanın amacı
Eğer servise yeni metot yazılacak ve döneceği değer belli ama metot yazılmadıysa o servisin interface'ine o metot eklenir ve o metot üzerinden birim testi yapılır.
Model property doğrulama
// Arrange
var propertyInfo = typeof(TEntity).GetProperty("PropertyName");
// Act
var attribute = propertyInfo.GetCustomAttributes(typeof(RequiredAttribute))
.Cast<RequiredAttribute>()
.FirstOrDefault();
attribute null değilse PropertyName özelliği [Required]'dır
var propertyInfo = typeof(TEntity).GetProperty("PropertyName");
// Act
var attribute = propertyInfo.GetCustomAttributes(typeof(RequiredAttribute))
.Cast<RequiredAttribute>()
.FirstOrDefault();
attribute null değilse PropertyName özelliği [Required]'dır
Model doğrulama
private IList<ValidationResult> ValidateModel(object model)
{
var validationResults = new List<ValidationResult>();
var ctx = new ValidationContext(model);
Validator.TryValidateObject(model, ctx, validationResults, true);
return validationResults;
}
içine aldığı modelin [Required] attributelerinden girilmeyenleri yakalıyor.
{
var validationResults = new List<ValidationResult>();
var ctx = new ValidationContext(model);
Validator.TryValidateObject(model, ctx, validationResults, true);
return validationResults;
}
içine aldığı modelin [Required] attributelerinden girilmeyenleri yakalıyor.
Kaydol:
Yorumlar (Atom)
.net 6 mapget kullanımı
app.UseEndpoints(endpoints => { endpoints.MapGet("/", async context => { var response = JsonConvert.Seriali...
-
var dataProperties = Object.getOwnPropertyNames(responseStart.data); for(let i=0;i<datapProperties.length;i++){ localStorage.setItem(pr...
-
XAMPP Apache MySQL PHP 5 PHP 4 1.8.3 2.4.9 5.6.16 5.5.11 1.8.2 2.4.9 5.5.36 5.4.27 1.8.1 2.4.3 5.5.27 5.4.7 1...
-
SELECT * INTO [new_BK] FROM [old_table]