Skip to main content

Posts

Showing posts from 2016

Getting Started with .Net Core and Docker

I have been working to understand .Net Core and Docker as of late. It is cool technology but a bit of a paradigm shift. I have found a few good resources here and wanted to start recording them in case I needed to come back to them a long this journey. First step to all of this is to install the .Net Core SDK . Second step is to get Docker . Once these are installed you have all the command line you need for awhile as you start moving down this road. One of the first steps for me was getting my head around what .Net Core is and how it is different then the >net world I have been living in. Here is a great walk through that help me understand this. First Steps Exploring NET Core and ASPNET Core For me that finally connected the dots of what was happening now with the .net framework. The next step was to understand what Docker is going to do for me. I had played and read about it but I needed to get hands-on. To do that I actually ran into another great article. Deploy

Powershell, XML and Visual Studio build event

Visual Studio provides a lot of capability, but sometimes you need a little Powershell. I needed to update an XML file in my solution based on the projects build configuration. If the configuration was "Release" setup a node in the XML to be value A. If the configuration was "Debug" setup a node in the XML to be value B. I actually did not realize how easy it is to work with XML within Powershell. I found a nice little start on StackOverflow . My XML was more complex of course but it is still pretty easy to work with. Here is my post-build event. "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" -file ..\..\..\..\Scripts\ToggleXMLValues.ps1 $(ConfigurationName) $(TargetDir) Then in a Powershell file I wrote some pretty simple code. param ([string]$configName, [string]$outputDir) $doc = [xml](Get-Content "$($outputDir)\config\myfile.xml") if ($configName -eq "Release") { $doc.Configuration.Global.Storages.Storage[0

Uniting Testing Expression Predicate with Moq

I recently was setting up a repository in a project with an interface on all repositories that took a predicate. As part of this I needed to mock out this call so I could unit test my code. The vast majority of samples out there for mocking an expression predicate just is It.IsAny<> which is not very helpful as it does not test anything other then verify it got a predicate. What if you actually want to test that you got a certain predicate though? It is actually pretty easy to do but not very straight forward. Here is what you do for the It.IsAny<> approach in case someone is looking for that. this .bindingRepository.Setup(c => c.Get(It.IsAny<Expression<Func<UserBinding, bool >>>())) .Returns( new List<UserBinding>() { defaultBinding }.AsQueryable()); This example just says to always return a collection of UserBindings that contain “defaultBinding” (which is an object I setup previously). Here is what it looks like when you want to pass in an exp