Posts

Showing posts from 2024

ToMethodObject Refactoring

Image
I love refactoring code. To refactor code safely you need automated tests. Some code, especially code not written using Test Driven Development(TDD), make it difficult to write tests for the part of the code you are looking to change. Usually what you face are a class that has many dependencies, so in your test setup, you have to create all these dependencies to inject into the constructor even though many or perhaps all of these dependencies don't even have anything to do with the part of the code you are looking to change. Or the method that you want to write a change for is private and the calling public method has a bunch of dependencies which again many will not have anything to do with the part of the code you are looking to change. You are thinking: "If only this code was in a public method it would be so much easier to test". But you may have heard somewhere that changing the code just to make it easier to test is bad.  This is a terrible line of thought that has

Visual Studio "You are not authorized to access {username}.visualstudio.com." error

Image
 I have gotten this error once before and ended up having to call Microsoft support and have someone walk me through the steps to fix this. We went through multiple things to fix it and I didn't write them down. Now when I try to sign into Visual Studio I get this error:  I then tried to sign in with my GitHub account and got a bunch of Error Script popups. Did some googling and found the solution to my problem here . Thanks to BigOine I went to Tools -> Options -> Accounts and changed "Add and reauthenticate accounts using:" to "System web browser" and I was able to login with my regular account and the {username}.visualstudio.com error went away.