How to become a Zero to Hero in Unit Testing with C# and xUnit ?
Timeline:
Background 0:00:00
Introduction To Fluent Assertions 0:01:12
Setting Up Fluent Assertions 0:02:39
Basic Assertions with Fluent Assertions 0:09:19
Advanced Assertions with Fluent Assertions 0:20:28
Custom Assertions with Fluent Assertions 0:28:32
Test the Custom Person Assertions 0:47:56
Best Practices For Using Fluent Assertions 0:54:21
2. نفرستادن پشت سر ایمیلها به یک host خاص
3. استفاده نکردن از کلمه هایی که احتمال اسپم شناخته شدن ایمیل را افزایش میدهند در قسمت Subject Email
در لینکهای زیر لیست بعضی از این کلمات را میتوانید مشاهده کنید:
http://blog.hubspot.com/blog/tabid/6307/bid/30684/The-Ultimate-List-of-Email-SPAM-Trigger-Words.aspx
http://www.inmotionhosting.com/support/edu/everything-email/spam-prevention-techniques/common-spam-words
4. فعال نکردن high priority
با فعال شدن این گزینه ایمیل شما مورد بررسیهای بیشتری قرار میگیرد و شانس اسپم شناخته شدن آنرا افزایش میدهد.
mailMessage.Priority = MailPriority.High ; //not good
5. Set کردن Encoding صحیح
mailMessage.BodyEncoding = System.Text.Encoding.GetEncoding(“utf-8″);
6. استفاده از حداکثر سه image در متن ایمیل
7. اضافه کردن هم htmlview و هم plainview به view ایمیل ارسالی
با مثال نحوه این کار را نشان میدهم:
System.Net.Mail.AlternateView plainView = System.Net.Mail.AlternateView.CreateAlternateViewFromString System.Text.RegularExpressions.Regex.Replace(BodyText, @”<(.|\n)*?>”, string.Empty), null, “text/plain”); System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(BodyText, null, “text/html”); mailMsg.AlternateViews.Add(plainView); mailMsg.AlternateViews.Add(htmlView);
منابع:
http://stackoverflow.com/questions/5042309/email-messages-going-to-spam-folder
http://www.andreas-kraus.net/blog/tips-for-avoiding-spam-filters-with-systemnetmail/
نگاهی به آینده WebAssembly
The future of WebAssembly - A look at upcoming features and proposals
WebAssembly is a performance optimised virtual machine that was shipped in all four major browsers earlier this year. It is a nascent technology and the current version is very much an MVP (minimum viable product). This blog post takes a look at the WebAssembly roadmap and the features it might be gain in the near future.
I’ll try to keep this blog post relatively high-level, so I’ll skip over some of the more technical proposals, instead focusing on what they might mean for languages that target WebAssembly.
- Find the Code You’re Looking For: Enhanced search capabilities to help you quickly locate the code you need, even in the largest projects.
- More Meaningful Code Reviews: Improvements to code review workflows, making it easier to spot potential issues and collaborate with your team.
- Updates to pull request creation: Continual improvements to the pull request creation experience.
- Familiar keyboard shortcuts: Some common keyboard shortcuts now match those in other popular IDEs.
- AI-Generated Breakpoint Expressions: Automatically suggest breakpoints based on your code, helping you debug more efficiently.
- Understand Your Symbols: Improved symbol recognition to ensure you get the most accurate suggestions.
- Refined Suggestions: More precise and context-aware code completions, reducing the need for manual edits.
- GitHub Copilot is even more secure: GitHub Copilot Business customers to prevent specified files or repositories from being used to inform code completion suggestions made by GitHub Copilot.
تصویر فوق، یکی از تصویرهایی است که شاید از طریق ایمیلهایی تحت عنوان "فقط در ایران!" به دست شما هم رسیده باشد. تصور کاربر نهایی (که این ایمیل را با تعجب ارسال کرده) این است که در اینجا به او گفته شده مثلا "مرتضی" را جستجو نکنید و امثال آن. چون برای او تفاوتی بین ی و ی وجود ندارد. همچنین بکار بردن "اقلامی" هم کمی غلط انداز است و بیشتر ذهن را به سمت کلمه سوق میدهد تا حرف.
در ادامهی بحث آلرژی مزمن به وجود انواع "ی" و "ک" در بانک اطلاعاتی (+ و + و +)، اینبار قصد داریم این اطلاعات را به NHibernate بسط دهیم. شاید یک روش اعمال یک دست سازی "ی" و "ک" این باشد که در کل برنامه هر جایی که قرار است update یا insert ایی صورت گیرد، خواص رشتهای را یافته و تغییر دهیم. این روش "کار میکنه" ولی ایده آل نیست؛ چون حجم کار تکراری در برنامه زیاد خواهد شد و نگهداری آن هم مشکل میشود. همچنین امکان فراموش کردن اعمال آن هم وجود دارد.
در NHibernate یک سری EventListener وجود دارند که کارشان گوش فرا دادن به یک سری رخدادها مانند مثلا update یا insert است. این رخدادها میتوانند پیش یا پس از هرگونه ثبت یا ویرایشی در برنامه صادر شوند. بنابراین بهترین جایی که جهت اعمال این نوع ممیزی (Auditing) بدون بالا بردن حجم برنامه یا اضافه کردن بیش از حد یک سری کد تکراری در حین کار با NHibernate میتوان یافت، روالهای مدیریت کنندهی همین EventListener ها هستند.
کلاس YeKeAuditorEventListener نهایی با پیاده سازی IPreInsertEventListener و IPreUpdateEventListenerبه شکل زیر خواهد بود:
using NHibernate.Event;
namespace NHYeKeAuditor
{
public class YeKeAuditorEventListener : IPreInsertEventListener, IPreUpdateEventListener
{
// Represents a pre-insert event, which occurs just prior to performing the
// insert of an entity into the database.
public bool OnPreInsert(PreInsertEvent preInsertEvent)
{
var entity = preInsertEvent.Entity;
CorrectYeKe.ApplyCorrectYeKe(entity);
return false;
}
// Represents a pre-update event, which occurs just prior to performing the
// update of an entity in the database.
public bool OnPreUpdate(PreUpdateEvent preUpdateEvent)
{
var entity = preUpdateEvent.Entity;
CorrectYeKe.ApplyCorrectYeKe(entity);
return false;
}
}
}
تا اینجا فقط تعریف YeKeAuditorEventListener انجام شده است. اما NHibernate چگونه از وجود آن مطلع خواهد شد؟
برای تزریق کلاس YeKeAuditorEventListener به تنظیمات برنامه باید به شکل زیر عمل کرد:
using System;
using System.Linq;
using FluentNHibernate.Cfg;
using NHibernate.Cfg;
namespace NHYeKeAuditor
{
public static class MappingsConfiguration
{
public static FluentConfiguration InjectYeKeAuditorEventListener(this FluentConfiguration fc)
{
return fc.ExposeConfiguration(configListeners());
}
private static Action<Configuration> configListeners()
{
return
c =>
{
var listener = new YeKeAuditorEventListener();
c.EventListeners.PreInsertEventListeners =
c.EventListeners.PreInsertEventListeners
.Concat(new[] { listener })
.ToArray();
c.EventListeners.PreUpdateEventListeners =
c.EventListeners.PreUpdateEventListeners
.Concat(new[] { listener })
.ToArray();
};
}
}
}
کدهای NHYeKeAuditor را از اینجا میتوانید دریافت کنید.
آغاز کار با git در ویژوال استدیو
In this episode, Robert is joined by Paul Litwin, who shows us how to get started with Git in under an hour. Git is a free, open source and quite popular distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Starting with the command line and ending up in both VS Code and Visual Studio, Paul takes us on a tour of the how you can use Git to manage your source code.
What’s new for performance in .NET Core and ASP.NET Core 3.0 – Ben Adams
One of the biggest advantages of using .NET Core (besides cross-platform support) is the drastic improvements in performance. Because the .NET Core team was able to make minor breaking changes in the runtime and Base Class Library (BCL), lots of stuff was implemented much more efficiently. In this session Ben will dive into the performance improvements in .NET Core in the 3.0 release: runtime changes, JIT changes, intrinsics and a deep dive into some of the improvements making it the best release yet!