Posts

Showing posts from May, 2021

Cool Way to Fake IConfiguration for unit testing

Image
  I was working on a project the other day and I came across a need to fake/mock an IConfigutration object. Tried MOQ I started with MOQ.  This is always quick and easy to use.  I have used this in the past but this time I needed to change the values within the configuration.  Which is totally possible but the more I dig into how to do that the more of a pain it became. Since I am lazy, I figured there has to be a better way. Simpler Method I quickly discovered, there was an easier way.  There is a class in .Net called ConfigurationBuilder.  With this class, you can easily create an in-memory configuration collection with whatever settings you want. 1. Create a dictionary of values                var inMemorySettings = new Dictionary<string, string>()             {                 { "Location", "TestLocation"}             }; 2. Create the Configuration builder, adding the settings             config = new ConfigurationBuilder()                 .AddInMemoryColl

File Upload Button Styling

Image
 I came across an article that said you can actually style the file upload button, so I decided to apply styling to my new File upload project. As it turns out, this is quite easy:      input[type=file]::file-selector-button {          border: 2px solid #6c5ce7;          padding: .2em .4em;          border-radius: .2em;          background-color: #a29bfe;          transition: 1s;      }      input[type=file]::file-selector-button:hover {          background-color: #81ecec;          border: 2px solid #00cec9;      } As you can see you just use the input[type=file] CSS selector to select the upload button.  Once you have the element selected, just like any other HTML element, you apply your styling. [source]