Ross McNichol

I am a Solutions Architect

Ross McNichol

A hands-on IT Manager and .NET solutions architect developing desktop apps with WPF, web apps with Aurelia, and mobile apps with Xamarin. Sometimes I have found it difficult to find solutions to enterprise development patterns and solutions. This blog shares some of my favourite solutions to some difficult problems and elegant solutions I have found over the years

Me

My Professional Skills

Broad skills are listed below, most of my software development revolves around the Microsoft platform. C# is my specialty mixing in a bunch of other things like T-SQL, XAML, Typescript, HTML, CSS to get the job done

Web Development 70%
Mobile Development 75%
Desktop development 90%
Server Side Developer 99%

Aurelia Web Development

Aurelia is an elegant componentised SPA framework by Rob Eisenberg who also created Caliburn Micro which I have been using for many years. I have only been using it since late 2016 but it has worked really well for us

Xamarin/WPF desktop application development

More of a hobby at the moment and a way to contribute to the Caliburn micro project on GitHub. I have created the samples for WPF, UWP and Xamarin for official Caliburn micro GitHub repository

MS-SQL, Sqlite Database Development

I have been developing against SQL databases since 2005 and have a plenty of practice with designing building and tuning them. I have recently started using SQlite for integration testing in .NET applications

Solutions Architecture

Being involved in SMB's for my entire career I have had the opportunity to create multiple architectures to suit various needs. I take a great deal of pride in being able to discuss a business need and being able to confidently propose a solution that has a high probability of success

IT management

I am a pretty easy going and understanding manager, but I do expect a personal drive, innovation and results from my staff

Quality Assurance

I have developed over the years a comprehensive and proven quality assurance patterns. I have patterns for unit, integration, functional and manual testing to bring software solutions to their highest quality

0
years developing
0
years managing
0
completed major projects
0
current projects
  • Integration Tests with Entity Framework and SQLite in .NET Core

    Integration Tests with Entity Framework and SQLite in .NET Core



    I have recently completed a new .NET core API and created a SQLite in memory database so I could do effective integration testing. Given how complex some of the linq we write is mocking it out and just saying yeah its going to return that seems pretty unreliable to me so I built an in memory database and wrote tests against it. So far we have written 120 test that create an in memory database, perform the test and then do a tear down. I takes about 2 minutes to complete everything which I think is pretty good all things considered. The snippet below shows how I setup the creation of the DbContextOptions, this is important because any data context created using this will reference the same in memory database. That's pretty cool if you think about it. Note that I am creating and disposing of one such data context in the setup.
            private readonly DbContextOptions _dbOptions;
    
            public TestSetup()
            {         
                var optionsBuilder = new DbContextOptionsBuilder();
                optionsBuilder.UseSqlite(new SqliteConnection("DataSource=:memory:"));           
                _dbOptions = optionsBuilder.Options;
    
                 using (var setupContext = new DataContext(_dbOptions))
                {
                    var bd = new BaseData(setupContext);
                    setupContext.Database.GetDbConnection().Open();
                    setupContext.Database.EnsureCreated();
                    bd.Initialise();
                }
            }
    
            public DataContext GetDataContext()
            {
                return new DataContext(_dbOptions);
            }
    
    The bd.Initialize() method simply goes off and adds entities to the dbcontext and does a save. A couple of snippets from base data are
    
      public void Initialise()
            {
                InitialseAudit();
                InitialiseSecurity();
                InitialiseCategories();
                InitialiseGoals();
                _dbContext.SaveChanges();
            }   
    
      private void InitialiseCategories()
            {
                var workCategory = new Category { Id = (int)CategoryEnum.Work, Name = "Work" };
                _dbContext.Categories.Add(workCategory);
                var homeCategory = new Category { Id = (int)CategoryEnum.Home, Name = "Home" };
                _dbContext.Categories.Add(homeCategory);
            }
    
    
    I have also used enums for the primary keys that I am interested in. This way they are really easy to reference and reuse in teh system and the tests. Usage would be something like the following, this is just as an rudimentary example of saving a goal to a list for a user.
            public GoalServiceShould()
            {       
                var testSetup = new TestSetup();    
    
    
                var dataContext = testSetup.GetDataContext();
                _uow = new UnitOfWork(dataContext);
                _goalRepository = new Repository(dataContext);
                
                _goalService = new GoalService(_uow, _goalRepository);
            }
    
            [Fact]
            public async void AddNewGoal()
            {
                var stamp = DateTime.Now;
                var goal = new GoalDto
                {
                    UserId = 1,
                    Note = $"New Note {stamp}",
                    DueDate = new DateTime(2017, 1, 6),
                    Urgent = true,
                    ModifiedById = 1
                };
                var returnedGoal = (await _goalService.SaveGoal(goal)).Content;
                returnedGoal.Id.ShouldBeGreaterThan(0);
    
                var savedGoal = await _goalRepository.GetAsync(p => p.Id == returnedGoal.Id);
                savedGoal.Note.ShouldBe($"New Note {stamp}");           
            }
    
    
    I could share a full example if anybody is interested, send me a message or leave a comment and I will get back to you. I am using Shouldly for the asserts in the test.
  • If you've gotten this far...

    Thanks for checking out my site, get in contact below if you would like to chat.

    Located

    Brisbane, Australia

    Email

    rmcnichol@gmail.com