C# Xunit Mocking Db Context (For Testing)

So in my App I use Repositories like. public class CommentRepository { AppDBContext context; public List Comments { get { return this.context.Comments.ToList(); } } public CommentRepository(AppDBContext context) { this.context = context; } } The AppDbContext inherits DbContext (part of Entity Framework). Then in the startup.cs in the ConfigureServices method I add services.AddDbContext(options => options.UseSqlServer(Configuration[“ConnectionStrings:Local”])); Ok […]

Using Android Device Monitor in Visual Studio to access locked folders

First you have to have your android emulator running Then to open up the Android Device Monitor you click on the icon on the icon in visual studio When it opens up it should look like The Problem When I click the icon next to data to look at the user data, I can’t see […]

ASP Core C# Entity Framework Cheat Sheet

Step 1) Create Models – example namespace Project.Models{ public class Product{ public int ID { get; set;} public string Name { get; set;} public string Description { get; set;} public decimal Price { get; set;} public string Category { get; set;} } } Entity framework looks for properties with ID in it and makes that […]

C# Newtonsoft JSON Serialize and Deserialize of Objects

So after abit of headache. I figured out how to serialize nested objects and deserialize them. This is especially useful for doing Android Development with C#. So for starters! Here are the Objects/Models public class Game public class Game { public Player currentPlayer; public Player player1; public Player player2; public Die die; public int currentRound; […]