public void GetAllByUserNameShouldReturnAllModsDependingOnSortType() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "GetAllByUserNameShouldReturnAllModsDependingOnSortType_DB") .Options; var dbContext = new ApplicationDbContext(options); var modService = new ModService(dbContext); var user = new ApplicationUser { UserName = "******", }; dbContext.Users.Add(user); var mod1 = new Mod { UserId = user.Id, Views = 100, TotalDownloadCount = 25, VoteCount = 50, }; var mod2 = new Mod { UserId = user.Id, Views = 25, TotalDownloadCount = 100, VoteCount = 50, }; var mod3 = new Mod { UserId = user.Id, Views = 25, TotalDownloadCount = 50, VoteCount = 100, }; dbContext.Mods.Add(mod1); dbContext.Mods.Add(mod2); dbContext.Mods.Add(mod3); dbContext.SaveChanges(); var viewsSort = modService.GetAllByUserName(user.UserName, "Views").First(); var votesSort = modService.GetAllByUserName(user.UserName, "Votes").First(); var downloadsSort = modService.GetAllByUserName(user.UserName, "Downloads").First(); Assert.Equal(mod1.Views, viewsSort.Views); Assert.Equal(mod2.TotalDownloadCount, downloadsSort.TotalDownloadCount); Assert.Equal(mod3.VoteCount, votesSort.VoteCount); }