From 285c51e49cd9d2722c149ffbdd0240a1cd293e7a Mon Sep 17 00:00:00 2001 From: Eric Hill Date: Mon, 1 Apr 2019 14:46:07 -0400 Subject: [PATCH 1/2] add dot-net-core test --- dot-net-core/.gitignore | 240 ++++++++++++++++++ dot-net-core/README.md | 9 + .../src/DbContexts/ApplicationDbContext.cs | 17 ++ dot-net-core/src/Entities/BaseEntity.cs | 13 + dot-net-core/src/Entities/LessonEntity.cs | 6 + dot-net-core/src/Entities/UserEntity.cs | 6 + dot-net-core/src/Interviews.csproj | 11 + dot-net-core/src/Program.cs | 50 ++++ .../src/Repositories/ILessonRepository.cs | 7 + .../src/Repositories/IUserRepository.cs | 7 + .../src/Repositories/LessonRepository.cs | 25 ++ .../src/Repositories/UserRepository.cs | 25 ++ .../src/Services/AssignmentService.cs | 10 + .../src/Services/IAssignmentService.cs | 7 + dot-net-core/src/Services/ITestService.cs | 13 + dot-net-core/src/Services/TestService.cs | 27 ++ dot-net-core/test/Interviews.Tests.csproj | 15 ++ dot-net-core/test/README.md | 0 dot-net-core/test/UnitTest1.cs | 14 + 19 files changed, 502 insertions(+) create mode 100644 dot-net-core/.gitignore create mode 100644 dot-net-core/README.md create mode 100644 dot-net-core/src/DbContexts/ApplicationDbContext.cs create mode 100644 dot-net-core/src/Entities/BaseEntity.cs create mode 100644 dot-net-core/src/Entities/LessonEntity.cs create mode 100644 dot-net-core/src/Entities/UserEntity.cs create mode 100644 dot-net-core/src/Interviews.csproj create mode 100644 dot-net-core/src/Program.cs create mode 100644 dot-net-core/src/Repositories/ILessonRepository.cs create mode 100644 dot-net-core/src/Repositories/IUserRepository.cs create mode 100644 dot-net-core/src/Repositories/LessonRepository.cs create mode 100644 dot-net-core/src/Repositories/UserRepository.cs create mode 100644 dot-net-core/src/Services/AssignmentService.cs create mode 100644 dot-net-core/src/Services/IAssignmentService.cs create mode 100644 dot-net-core/src/Services/ITestService.cs create mode 100644 dot-net-core/src/Services/TestService.cs create mode 100644 dot-net-core/test/Interviews.Tests.csproj create mode 100644 dot-net-core/test/README.md create mode 100644 dot-net-core/test/UnitTest1.cs diff --git a/dot-net-core/.gitignore b/dot-net-core/.gitignore new file mode 100644 index 00000000..7b5962a8 --- /dev/null +++ b/dot-net-core/.gitignore @@ -0,0 +1,240 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +bin/ +Bin/ +obj/ +Obj/ + +# Visual Studio 2015 cache/options directory +.vs/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# OpenCover +**/coverage/** + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Microsoft Azure ApplicationInsights config file +ApplicationInsights.config + +# Windows Store app package directory +AppPackages/ +BundleArtifacts/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +orleans.codegen.cs + +/node_modules + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe + +# FAKE - F# Make +.fake/ + +# VS Code +.vscode/ + +# OpenCover +coverage/ \ No newline at end of file diff --git a/dot-net-core/README.md b/dot-net-core/README.md new file mode 100644 index 00000000..c40e96b0 --- /dev/null +++ b/dot-net-core/README.md @@ -0,0 +1,9 @@ +# .NET Coding and Thinking Challenges + +Microsoft .NET based at home tests for engineering interviews. + +Steps: + +- Fork this repo +- Modify the code as described in the README.md files inside the src and test folders. +- Send a pull request for your fork when you consider the assignment complete. \ No newline at end of file diff --git a/dot-net-core/src/DbContexts/ApplicationDbContext.cs b/dot-net-core/src/DbContexts/ApplicationDbContext.cs new file mode 100644 index 00000000..5807d039 --- /dev/null +++ b/dot-net-core/src/DbContexts/ApplicationDbContext.cs @@ -0,0 +1,17 @@ +using Interview.Entities; +using Microsoft.EntityFrameworkCore; + +namespace Interviews.DbContexts +{ + public class ApplicationDbContext : DbContext + { + public virtual DbSet Users { get; set; } + + public virtual DbSet Lessons { get; set; } + + public ApplicationDbContext(DbContextOptions options) + : base(options) + { + } + } +} \ No newline at end of file diff --git a/dot-net-core/src/Entities/BaseEntity.cs b/dot-net-core/src/Entities/BaseEntity.cs new file mode 100644 index 00000000..a53fa4e9 --- /dev/null +++ b/dot-net-core/src/Entities/BaseEntity.cs @@ -0,0 +1,13 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Interview.Entities +{ + public class BaseEntity + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public string Id { get; set; } + } +} \ No newline at end of file diff --git a/dot-net-core/src/Entities/LessonEntity.cs b/dot-net-core/src/Entities/LessonEntity.cs new file mode 100644 index 00000000..dea23212 --- /dev/null +++ b/dot-net-core/src/Entities/LessonEntity.cs @@ -0,0 +1,6 @@ +namespace Interview.Entities +{ + public class LessonEntity : BaseEntity + { + } +} \ No newline at end of file diff --git a/dot-net-core/src/Entities/UserEntity.cs b/dot-net-core/src/Entities/UserEntity.cs new file mode 100644 index 00000000..4b719a38 --- /dev/null +++ b/dot-net-core/src/Entities/UserEntity.cs @@ -0,0 +1,6 @@ +namespace Interview.Entities +{ + public class UserEntity : BaseEntity + { + } +} \ No newline at end of file diff --git a/dot-net-core/src/Interviews.csproj b/dot-net-core/src/Interviews.csproj new file mode 100644 index 00000000..95accf36 --- /dev/null +++ b/dot-net-core/src/Interviews.csproj @@ -0,0 +1,11 @@ + + + + Exe + netcoreapp2.2 + + + + + + diff --git a/dot-net-core/src/Program.cs b/dot-net-core/src/Program.cs new file mode 100644 index 00000000..8e0ca213 --- /dev/null +++ b/dot-net-core/src/Program.cs @@ -0,0 +1,50 @@ +using System; +using Interviews.Services; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace Interviews +{ + class Program + { + static void Main(string[] args) + { + var services = BuildServiceProvider(args); + + var logger = services.GetRequiredService>(); + logger.LogDebug("Starting application"); + + // coordinates test execution + var testService = services.GetService(); + + // step 1 + testService.ExecuteStep1(); + + // step 2 + testService.ExecuteStep2(); + + // step 3 + testService.ExecuteStep3(); + + // step 4 + testService.ExecuteStep4(); + + logger.LogDebug("All done!"); + + // needed to get the logger to flush + services.Dispose(); + } + + public static ServiceProvider BuildServiceProvider(string[] args) => + // setup our DI + new ServiceCollection() + .AddLogging((logging) => + { + // configure console logging + logging.AddConsole(); + logging.SetMinimumLevel(LogLevel.Debug); + }) + .AddSingleton() + .BuildServiceProvider(); + } +} diff --git a/dot-net-core/src/Repositories/ILessonRepository.cs b/dot-net-core/src/Repositories/ILessonRepository.cs new file mode 100644 index 00000000..2639c015 --- /dev/null +++ b/dot-net-core/src/Repositories/ILessonRepository.cs @@ -0,0 +1,7 @@ +namespace Interviews.Repositories +{ + public interface ILessonRepository + { + void CreateLesson(string lesson); + } +} diff --git a/dot-net-core/src/Repositories/IUserRepository.cs b/dot-net-core/src/Repositories/IUserRepository.cs new file mode 100644 index 00000000..e9b7900a --- /dev/null +++ b/dot-net-core/src/Repositories/IUserRepository.cs @@ -0,0 +1,7 @@ +namespace Interviews.Repositories +{ + public interface IUserRepository + { + void CreateUser(string user); + } +} diff --git a/dot-net-core/src/Repositories/LessonRepository.cs b/dot-net-core/src/Repositories/LessonRepository.cs new file mode 100644 index 00000000..188447e3 --- /dev/null +++ b/dot-net-core/src/Repositories/LessonRepository.cs @@ -0,0 +1,25 @@ +using System; +using Interviews.DbContexts; +using Microsoft.EntityFrameworkCore; + +namespace Interviews.Repositories +{ + public class LessonRepository : ILessonRepository + { + private readonly ApplicationDbContext _applicationDbContext; + + public LessonRepository() + { + var options = new DbContextOptionsBuilder() + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .Options; + + _applicationDbContext = new ApplicationDbContext(options); + _applicationDbContext.Database.EnsureDeleted(); + } + + public void CreateLesson(string lesson) + { + } + } +} diff --git a/dot-net-core/src/Repositories/UserRepository.cs b/dot-net-core/src/Repositories/UserRepository.cs new file mode 100644 index 00000000..62625937 --- /dev/null +++ b/dot-net-core/src/Repositories/UserRepository.cs @@ -0,0 +1,25 @@ +using System; +using Interviews.DbContexts; +using Microsoft.EntityFrameworkCore; + +namespace Interviews.Repositories +{ + public class UserRepository : IUserRepository + { + private readonly ApplicationDbContext _applicationDbContext; + + public UserRepository() + { + var options = new DbContextOptionsBuilder() + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .Options; + + _applicationDbContext = new ApplicationDbContext(options); + _applicationDbContext.Database.EnsureDeleted(); + } + + public void CreateUser(string user) + { + } + } +} \ No newline at end of file diff --git a/dot-net-core/src/Services/AssignmentService.cs b/dot-net-core/src/Services/AssignmentService.cs new file mode 100644 index 00000000..a2a805b4 --- /dev/null +++ b/dot-net-core/src/Services/AssignmentService.cs @@ -0,0 +1,10 @@ +namespace Interviews.Services +{ + public class AssignmentService + { + public void AssignLesson(string user, string lesson) + { + + } + } +} \ No newline at end of file diff --git a/dot-net-core/src/Services/IAssignmentService.cs b/dot-net-core/src/Services/IAssignmentService.cs new file mode 100644 index 00000000..83589883 --- /dev/null +++ b/dot-net-core/src/Services/IAssignmentService.cs @@ -0,0 +1,7 @@ +namespace Interviews.Services +{ + public interface IAssignmentService + { + void AssignLesson(string user, string lesson); + } +} \ No newline at end of file diff --git a/dot-net-core/src/Services/ITestService.cs b/dot-net-core/src/Services/ITestService.cs new file mode 100644 index 00000000..ed311ecf --- /dev/null +++ b/dot-net-core/src/Services/ITestService.cs @@ -0,0 +1,13 @@ +namespace Interviews.Services +{ + public interface ITestService + { + void ExecuteStep1(); + + void ExecuteStep2(); + + void ExecuteStep3(); + + void ExecuteStep4(); + } +} \ No newline at end of file diff --git a/dot-net-core/src/Services/TestService.cs b/dot-net-core/src/Services/TestService.cs new file mode 100644 index 00000000..0c32890a --- /dev/null +++ b/dot-net-core/src/Services/TestService.cs @@ -0,0 +1,27 @@ +using Interviews.Repositories; + +namespace Interviews.Services +{ + public class TestService : ITestService + { + public void ExecuteStep1() + { + // create a user + } + + public void ExecuteStep2() + { + // create a lesson + } + + public void ExecuteStep3() + { + // assign the lesson to the user + } + + public void ExecuteStep4() + { + // verify lesson is assigned + } + } +} \ No newline at end of file diff --git a/dot-net-core/test/Interviews.Tests.csproj b/dot-net-core/test/Interviews.Tests.csproj new file mode 100644 index 00000000..3e025101 --- /dev/null +++ b/dot-net-core/test/Interviews.Tests.csproj @@ -0,0 +1,15 @@ + + + + netcoreapp2.2 + + false + + + + + + + + + diff --git a/dot-net-core/test/README.md b/dot-net-core/test/README.md new file mode 100644 index 00000000..e69de29b diff --git a/dot-net-core/test/UnitTest1.cs b/dot-net-core/test/UnitTest1.cs new file mode 100644 index 00000000..efabe281 --- /dev/null +++ b/dot-net-core/test/UnitTest1.cs @@ -0,0 +1,14 @@ +using System; +using Xunit; + +namespace Interviews.Tests +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + + } + } +} From 8dfd1773a316505ba2a847603e694c473ee6219f Mon Sep 17 00:00:00 2001 From: Eric Hill Date: Mon, 1 Apr 2019 15:07:40 -0400 Subject: [PATCH 2/2] add unit tests for dot net core, update readmes, add sln file --- dot-net-core/Interviews.sln | 48 +++++++++++++++++++ dot-net-core/README.md | 2 +- dot-net-core/src/README.md | 10 ++++ .../src/Repositories/LessonRepository.cs | 3 +- .../src/Repositories/UserRepository.cs | 3 +- dot-net-core/test/Interviews.Tests.csproj | 4 ++ dot-net-core/test/README.md | 10 ++++ .../Repositories/LessonRepositoryTests.cs | 7 +++ .../test/Repositories/UserRepositoryTests.cs | 7 +++ .../test/Services/AssignmentServiceTests.cs | 7 +++ dot-net-core/test/UnitTest1.cs | 14 ------ 11 files changed, 96 insertions(+), 19 deletions(-) create mode 100644 dot-net-core/Interviews.sln create mode 100644 dot-net-core/src/README.md create mode 100644 dot-net-core/test/Repositories/LessonRepositoryTests.cs create mode 100644 dot-net-core/test/Repositories/UserRepositoryTests.cs create mode 100644 dot-net-core/test/Services/AssignmentServiceTests.cs delete mode 100644 dot-net-core/test/UnitTest1.cs diff --git a/dot-net-core/Interviews.sln b/dot-net-core/Interviews.sln new file mode 100644 index 00000000..a0a14510 --- /dev/null +++ b/dot-net-core/Interviews.sln @@ -0,0 +1,48 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interviews", "src\Interviews.csproj", "{FE1EC190-7EAA-41C7-8A24-EB3E050B3644}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interviews.Tests", "test\Interviews.Tests.csproj", "{AE33A974-69F2-40B7-8489-A4C697582EBC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FE1EC190-7EAA-41C7-8A24-EB3E050B3644}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE1EC190-7EAA-41C7-8A24-EB3E050B3644}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE1EC190-7EAA-41C7-8A24-EB3E050B3644}.Debug|x64.ActiveCfg = Debug|Any CPU + {FE1EC190-7EAA-41C7-8A24-EB3E050B3644}.Debug|x64.Build.0 = Debug|Any CPU + {FE1EC190-7EAA-41C7-8A24-EB3E050B3644}.Debug|x86.ActiveCfg = Debug|Any CPU + {FE1EC190-7EAA-41C7-8A24-EB3E050B3644}.Debug|x86.Build.0 = Debug|Any CPU + {FE1EC190-7EAA-41C7-8A24-EB3E050B3644}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE1EC190-7EAA-41C7-8A24-EB3E050B3644}.Release|Any CPU.Build.0 = Release|Any CPU + {FE1EC190-7EAA-41C7-8A24-EB3E050B3644}.Release|x64.ActiveCfg = Release|Any CPU + {FE1EC190-7EAA-41C7-8A24-EB3E050B3644}.Release|x64.Build.0 = Release|Any CPU + {FE1EC190-7EAA-41C7-8A24-EB3E050B3644}.Release|x86.ActiveCfg = Release|Any CPU + {FE1EC190-7EAA-41C7-8A24-EB3E050B3644}.Release|x86.Build.0 = Release|Any CPU + {AE33A974-69F2-40B7-8489-A4C697582EBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AE33A974-69F2-40B7-8489-A4C697582EBC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AE33A974-69F2-40B7-8489-A4C697582EBC}.Debug|x64.ActiveCfg = Debug|Any CPU + {AE33A974-69F2-40B7-8489-A4C697582EBC}.Debug|x64.Build.0 = Debug|Any CPU + {AE33A974-69F2-40B7-8489-A4C697582EBC}.Debug|x86.ActiveCfg = Debug|Any CPU + {AE33A974-69F2-40B7-8489-A4C697582EBC}.Debug|x86.Build.0 = Debug|Any CPU + {AE33A974-69F2-40B7-8489-A4C697582EBC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AE33A974-69F2-40B7-8489-A4C697582EBC}.Release|Any CPU.Build.0 = Release|Any CPU + {AE33A974-69F2-40B7-8489-A4C697582EBC}.Release|x64.ActiveCfg = Release|Any CPU + {AE33A974-69F2-40B7-8489-A4C697582EBC}.Release|x64.Build.0 = Release|Any CPU + {AE33A974-69F2-40B7-8489-A4C697582EBC}.Release|x86.ActiveCfg = Release|Any CPU + {AE33A974-69F2-40B7-8489-A4C697582EBC}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/dot-net-core/README.md b/dot-net-core/README.md index c40e96b0..98d01a55 100644 --- a/dot-net-core/README.md +++ b/dot-net-core/README.md @@ -1,4 +1,4 @@ -# .NET Coding and Thinking Challenges +# .NET Coding Challenges Microsoft .NET based at home tests for engineering interviews. diff --git a/dot-net-core/src/README.md b/dot-net-core/src/README.md new file mode 100644 index 00000000..083ab547 --- /dev/null +++ b/dot-net-core/src/README.md @@ -0,0 +1,10 @@ +# .NET Coding and Thinking Challenges + +Application Development. + +Steps: + +- Take a few minutes to familiarize yourself with the application setup +- The application uses an in-memory database for data storage +- Fill out the execution for each step in the Test Service class +- Make convention or best-practice changes as needed to get this app production-ready \ No newline at end of file diff --git a/dot-net-core/src/Repositories/LessonRepository.cs b/dot-net-core/src/Repositories/LessonRepository.cs index 188447e3..b14b4d3c 100644 --- a/dot-net-core/src/Repositories/LessonRepository.cs +++ b/dot-net-core/src/Repositories/LessonRepository.cs @@ -11,11 +11,10 @@ public class LessonRepository : ILessonRepository public LessonRepository() { var options = new DbContextOptionsBuilder() - .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .UseInMemoryDatabase("ApplicationDatabase") .Options; _applicationDbContext = new ApplicationDbContext(options); - _applicationDbContext.Database.EnsureDeleted(); } public void CreateLesson(string lesson) diff --git a/dot-net-core/src/Repositories/UserRepository.cs b/dot-net-core/src/Repositories/UserRepository.cs index 62625937..17436e42 100644 --- a/dot-net-core/src/Repositories/UserRepository.cs +++ b/dot-net-core/src/Repositories/UserRepository.cs @@ -11,11 +11,10 @@ public class UserRepository : IUserRepository public UserRepository() { var options = new DbContextOptionsBuilder() - .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .UseInMemoryDatabase("ApplicationDatabase") .Options; _applicationDbContext = new ApplicationDbContext(options); - _applicationDbContext.Database.EnsureDeleted(); } public void CreateUser(string user) diff --git a/dot-net-core/test/Interviews.Tests.csproj b/dot-net-core/test/Interviews.Tests.csproj index 3e025101..5cd063fa 100644 --- a/dot-net-core/test/Interviews.Tests.csproj +++ b/dot-net-core/test/Interviews.Tests.csproj @@ -12,4 +12,8 @@ + + + + diff --git a/dot-net-core/test/README.md b/dot-net-core/test/README.md index e69de29b..7d203c47 100644 --- a/dot-net-core/test/README.md +++ b/dot-net-core/test/README.md @@ -0,0 +1,10 @@ +# .NET Coding and Thinking Challenges + +Unit Testing. + +Steps: + +- Take a few minutes to familiarize yourself with the unit test setup +- The tests use an in-memory database for data storage +- Add the unit tests requested in the test files +- Add any additional unit tests as needed to increase code coverage \ No newline at end of file diff --git a/dot-net-core/test/Repositories/LessonRepositoryTests.cs b/dot-net-core/test/Repositories/LessonRepositoryTests.cs new file mode 100644 index 00000000..b84e66d6 --- /dev/null +++ b/dot-net-core/test/Repositories/LessonRepositoryTests.cs @@ -0,0 +1,7 @@ +namespace Interview.Tests.Repositories +{ + public class LessonRepositoryTests + { + // verify that lesson is created + } +} \ No newline at end of file diff --git a/dot-net-core/test/Repositories/UserRepositoryTests.cs b/dot-net-core/test/Repositories/UserRepositoryTests.cs new file mode 100644 index 00000000..c5ed2239 --- /dev/null +++ b/dot-net-core/test/Repositories/UserRepositoryTests.cs @@ -0,0 +1,7 @@ +namespace Interview.Tests.Repositories +{ + public class UserRepositoryTests + { + // verify that user is created + } +} \ No newline at end of file diff --git a/dot-net-core/test/Services/AssignmentServiceTests.cs b/dot-net-core/test/Services/AssignmentServiceTests.cs new file mode 100644 index 00000000..de8ff83b --- /dev/null +++ b/dot-net-core/test/Services/AssignmentServiceTests.cs @@ -0,0 +1,7 @@ +namespace Interview.Tests.Services +{ + public class AssignmentServiceTests + { + // verify that user is assigned the lesson + } +} \ No newline at end of file diff --git a/dot-net-core/test/UnitTest1.cs b/dot-net-core/test/UnitTest1.cs deleted file mode 100644 index efabe281..00000000 --- a/dot-net-core/test/UnitTest1.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using Xunit; - -namespace Interviews.Tests -{ - public class UnitTest1 - { - [Fact] - public void Test1() - { - - } - } -}