Menu

Skip to content
  • Home
  • About
  • Color Coder
Hamid Mosalla
Twitter Email LinkedIn GitHub Stack Overflow RSS

Hamid Mosalla

Programming Adventures

C#

August 30, 2018 by Hamid Mosalla on .Net, C#, Unit Test

xUnit BeforeAfterTestAttribute: How to Run Code Before And After Test

Sometimes we need to run a piece of custom code before and after a test and set of tests. One example of this might be when we want to change the thread culture. In this case we change it before test start to run and restore it to its original after test is finished. One … →

 
August 24, 2018 by Hamid Mosalla on .Net, Asynchronous And Parallel Programming, C#

More Robust Asynchrony and Parallelism With TPL Dataflow ActionBlock

.In my previous post, I explained what TPL Dataflow is and when we should and shouldn’t use it. But I haven’t got into much detail about how it can help us solve real world scenarios. Since my last post, thanks to a comment on my previous post, I went though different Stackoverflow questions. I saw … →

 
August 16, 2018 by Hamid Mosalla on .Net, C#, Unit Test

xUnit: Control the Test Execution Order

Sometime in our tests, we need to control the test execution order. This mostly happens in our integration test and not as often as our unit tests. Some people might even argue that controlling the execution order of unit test is bad practice. You can read more about it here. The main reason to not … →

 
August 4, 2018 by Hamid Mosalla on .Net, Asynchronous And Parallel Programming, C#

What is TPL Dataflow in .Net and When Should We Use It

There are various ways to write a concurrent or parallel program in .Net but they’re often don’t have the flexibility and robustness needed. That’s where TPL Dataflow comes in, it helps us build a more robust concurrent program and it can helps us reduce a lot of complexity. For example when we use other paradigms … →

 
July 31, 2018 by Hamid Mosalla on .Net, C#, Unit Test

xUnit: Share an SUT Instance Between Two Class Using Collection

In my previous post I talked about how we can Share Expensive Object Between Tests By Using IClassFixture. My previous post is about situations when we want to share a class instance between all test methods. Because a test class is created once per test method so its constructor is executed per test methods. But … →

 
July 21, 2018 by Hamid Mosalla on .Net, C#, Unit Test

Share Expensive Object Between Tests By IClassFixture

When XUnit run a test method, it’s going to create a new object of our test class for each and everyone of our test method. This can create a problem when the creation of the object is expensive and slow our tests down. But there’s a solution to it, we can use IClassFixture to share … →

 
July 17, 2018 by Hamid Mosalla on .Net, Asynchronous And Parallel Programming, C#

Asynchronous Programming Series

Recently I wrote a series of posts regarding asynchronous programming. You can find the links to this series down below. In these series of posts I started from the definition of concurrency and how it’s different with parallelism. Then I moved on deeper into the subject by each post. My 10th post in this series … →

 
July 9, 2018 by Hamid Mosalla on .Net, Asynchronous And Parallel Programming, C#

Thread Safety

There a lot of things that can go wrong in our code. But when we introduce concurrency or parallelism in our code, we potentially could experience different set of bugs. These are race conditions, deadlocks and data corruption to name a few. This happens because there might be a share piece of data between different … →

 
June 30, 2018 by Hamid Mosalla on .Net, Asp.Net Core, C#

Dependency Injection: Conditional Resolving of Multiple Implementation of Interface

Sometimes we need to resolve a dependency but not with one implementation, but with multiple. There are couple of scenarios that calls for conditional resolving of types. Such as when using a generic class and methods with a dependency on another class. Now imagine the aforementioned class is an abstract one, and we need to … →

 
June 24, 2018 by Hamid Mosalla on .Net, Asynchronous And Parallel Programming, C#

What Is SynchronizationContext

SynchronizationContext is one of those topics that deserves a better understanding if we want to fully know how asynchorony works in .Net. It’s true that most of these concerns handled behind the scene. But we can benefit by understanding what exactly happens when we offload a task to a worker thread or release the thread … →

 
Older Posts →
Page 3 of 7
← Newer Posts

Archives

Categories

 
Subscribe!
Copyright © 2022 Hamid Mosalla
Casper Theme By Lacy Morrow