initial batch
setting up sql configuration
This commit is contained in:
parent
82047e09e3
commit
fa5282b074
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TeamHobby.HobbyProjectGenerator.DAL
|
||||
{
|
||||
public interface IRepository<T>
|
||||
{
|
||||
bool Create(T model);
|
||||
|
||||
T Read();
|
||||
|
||||
bool Update(T model);
|
||||
|
||||
bool Delete(T model);
|
||||
}
|
||||
}
|
||||
48
Source Code/TeamHobby.HobbyProjectGenerator.DAL/SqlDAO.cs
Normal file
48
Source Code/TeamHobby.HobbyProjectGenerator.DAL/SqlDAO.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using TeamHobby.HobbyProjectGenerator.Models;
|
||||
|
||||
namespace TeamHobby.HobbyProjectGenerator.DAL
|
||||
{
|
||||
public class SqlDAO
|
||||
{
|
||||
public IList<Credentials> GetUserData(string username)
|
||||
{
|
||||
// Sql server connection string, needs to be changed accordingly to connect
|
||||
var connString = "server=localhost;userid=root;password=Plop20;database=users"; // Using @" " makes the string literal
|
||||
|
||||
// ADO.NET - ODBC
|
||||
using (var conn = new SqlConnection(connString))
|
||||
{
|
||||
// More complex sql commands are done in this method instead
|
||||
var sql = "Select * from roles";
|
||||
using (var command = new SqlCommand(sql, conn))
|
||||
{
|
||||
// Get the results from the query
|
||||
SqlDataReader r = command.ExecuteReader();
|
||||
|
||||
// If you wanted to get a singular value back such as a count of a certain item
|
||||
//command.ExecuteScalar();
|
||||
|
||||
// To execute something that doesn't expect results to come back
|
||||
// Use this method instead, IE. Update command
|
||||
//command.ExecuteNonQuery();
|
||||
|
||||
// Read data from query
|
||||
while (r.Read())
|
||||
{
|
||||
Console.WriteLine(r.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* this is meant for specific basic sql commands
|
||||
using (var adapter = new SqlDataAdapter())
|
||||
{
|
||||
adapter.SelectCommand
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.Models\TeamHobby.HobbyProjectGenerator.Models.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,32 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using TeamHobby.HobbyProjectGenerator.Main.Models;
|
||||
|
||||
namespace TeamHobby.HobbyProjectGenerator.Main.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
using TeamHobby.HobbyProjectGenerator;
|
||||
using TeamHobby.HobbyProjectGenerator.DAL;
|
||||
|
||||
namespace TeamHobby.HobbyProjectGenerator.Main
|
||||
{
|
||||
public class ExampleDAO : SqlDAO
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
namespace TeamHobby.HobbyProjectGenerator.Main.Models
|
||||
{
|
||||
public class ErrorViewModel
|
||||
{
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
}
|
||||
}
|
||||
29
Source Code/TeamHobby.HobbyProjectGenerator.Main/Program.cs
Normal file
29
Source Code/TeamHobby.HobbyProjectGenerator.Main/Program.cs
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
|
||||
app.Run();
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:6067",
|
||||
"sslPort": 44307
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"TeamHobby.HobbyProjectGenerator.Main": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:7023;http://localhost:5023",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.DAL\TeamHobby.HobbyProjectGenerator.DAL.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,8 @@
|
||||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Welcome</h1>
|
||||
<p>Hello World!</p>
|
||||
</div>
|
||||
@ -0,0 +1,6 @@
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
<p>Use this page to detail your site's privacy policy.</p>
|
||||
@ -0,0 +1,25 @@
|
||||
@model ErrorViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Error";
|
||||
}
|
||||
|
||||
<h1 class="text-danger">Error.</h1>
|
||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||
|
||||
@if (Model?.ShowRequestId ?? false)
|
||||
{
|
||||
<p>
|
||||
<strong>Request ID:</strong> <code>@Model?.RequestId</code>
|
||||
</p>
|
||||
}
|
||||
|
||||
<h3>Development Mode</h3>
|
||||
<p>
|
||||
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
|
||||
</p>
|
||||
<p>
|
||||
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
||||
It can result in displaying sensitive information from exceptions to end users.
|
||||
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
||||
and restarting the app.
|
||||
</p>
|
||||
@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - TeamHobby.HobbyProjectGenerator.Main</title>
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/TeamHobby.HobbyProjectGenerator.Main.styles.css" asp-append-version="true" />
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">TeamHobby.HobbyProjectGenerator.Main</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="container">
|
||||
<main role="main" class="pb-3">
|
||||
@RenderBody()
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2021 - TeamHobby.HobbyProjectGenerator.Main - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
@await RenderSectionAsync("Scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,48 @@
|
||||
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
||||
for details on configuring this project to bundle and minify static web assets. */
|
||||
|
||||
a.navbar-brand {
|
||||
white-space: normal;
|
||||
text-align: center;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #0077cc;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
color: #fff;
|
||||
background-color: #1b6ec2;
|
||||
border-color: #1861ac;
|
||||
}
|
||||
|
||||
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
|
||||
color: #fff;
|
||||
background-color: #1b6ec2;
|
||||
border-color: #1861ac;
|
||||
}
|
||||
|
||||
.border-top {
|
||||
border-top: 1px solid #e5e5e5;
|
||||
}
|
||||
.border-bottom {
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
.box-shadow {
|
||||
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
|
||||
}
|
||||
|
||||
button.accept-policy {
|
||||
font-size: 1rem;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
.footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
line-height: 60px;
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
|
||||
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>
|
||||
@ -0,0 +1,3 @@
|
||||
@using TeamHobby.HobbyProjectGenerator.Main
|
||||
@using TeamHobby.HobbyProjectGenerator.Main.Models
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@ -0,0 +1,3 @@
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
html {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
html {
|
||||
position: relative;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
@ -0,0 +1,4 @@
|
||||
// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
||||
// for details on configuring this project to bundle and minify static web assets.
|
||||
|
||||
// Write your JavaScript code.
|
||||
@ -0,0 +1,10 @@
|
||||
namespace TeamHobby.HobbyProjectGenerator.Models
|
||||
{
|
||||
public class Credentials
|
||||
{
|
||||
public string userName { get; set; }
|
||||
|
||||
// Syntactic sugar
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,12 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace TeamHobby.HobbyProjectGenerator
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TeamHobby.HobbyProjectGenerator.Contracts
|
||||
{
|
||||
internal interface IDataSource
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TeamHobby.HobbyProjectGenerator
|
||||
{
|
||||
public interface IUserService
|
||||
{
|
||||
// Public methods shouldn't be void so it can be tested
|
||||
bool User(string username);
|
||||
IList<string> GetAllUsers();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TeamHobby.HobbyProjectGenerator.Implementations
|
||||
{
|
||||
internal class Database_Users : IUserService
|
||||
{
|
||||
public IList<string> GetAllUsers()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool User(string username)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TeamHobby.HobbyProjectGenerator.Implementations
|
||||
{
|
||||
public class InMemoryUserService : IUserService
|
||||
{
|
||||
// Make it readonly so it can't be changed
|
||||
private readonly IList<string> _logstore;
|
||||
|
||||
public InMemoryUserService()
|
||||
{
|
||||
_logstore = new List<string>();
|
||||
}
|
||||
|
||||
public IList<string> GetAllUsers()
|
||||
{
|
||||
return _logstore;
|
||||
}
|
||||
|
||||
public bool User(string username)
|
||||
{
|
||||
try
|
||||
{
|
||||
//DateTime.UtcNow.ToString() + "->" + username; old way of doing it
|
||||
_logstore.Add($"{DateTime.UtcNow}->{username}"); // New way of doing it
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/*
|
||||
public bool User(DateTime timestamp, string username)
|
||||
{
|
||||
try
|
||||
{
|
||||
//DateTime.UtcNow.ToString() + "->" + username; old way of doing it
|
||||
_logstore.Add($"{timestamp.ToUniversalTime()}->{username}"); // New way of doing it
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
namespace TeamHobby.HobbyProjectGenerator
|
||||
{
|
||||
public class User_Authentication : IUserService
|
||||
{
|
||||
public IList<string> GetAllUsers()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool User(string username)
|
||||
{
|
||||
//Console.WriteLine("Hello World!");
|
||||
//Console.WriteLine("Testing console");
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TeamHobby.HobbyProjectGenerator.Implementations
|
||||
{
|
||||
public class User_Manager : IUserService
|
||||
{
|
||||
public IList<string> GetAllUsers()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool User(string username)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31919.166
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.HobbyProjectGenerator", "TeamHobby.HobbyProjectGenerator.csproj", "{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator", "TeamHobby.HobbyProjectGenerator.csproj", "{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.UserManagement.Tests", "..\TeamHobby.UserManagement.Tests\TeamHobby.UserManagement.Tests.csproj", "{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.DAL", "..\TeamHobby.HobbyProjectGenerator.DAL\TeamHobby.HobbyProjectGenerator.DAL.csproj", "{DCB0E160-1F6D-406E-8633-489CD564479B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Models", "..\TeamHobby.HobbyProjectGenerator.Models\TeamHobby.HobbyProjectGenerator.Models.csproj", "{75DED6C2-D404-4E71-A58B-0F616DB5C062}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.HobbyProjectGenerator.Main", "..\TeamHobby.HobbyProjectGenerator.Main\TeamHobby.HobbyProjectGenerator.Main.csproj", "{1D3E043F-A6EC-46D8-87ED-4164D095B83A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -15,6 +23,22 @@ Global
|
||||
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DCB0E160-1F6D-406E-8633-489CD564479B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DCB0E160-1F6D-406E-8633-489CD564479B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DCB0E160-1F6D-406E-8633-489CD564479B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DCB0E160-1F6D-406E-8633-489CD564479B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1D3E043F-A6EC-46D8-87ED-4164D095B83A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1D3E043F-A6EC-46D8-87ED-4164D095B83A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1D3E043F-A6EC-46D8-87ED-4164D095B83A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1D3E043F-A6EC-46D8-87ED-4164D095B83A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@ -0,0 +1,69 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using TeamHobby.HobbyProjectGenerator;
|
||||
using TeamHobby.HobbyProjectGenerator.Implementations;
|
||||
|
||||
namespace TeamHobby.UserManagement.Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class InMemeoryUserServiceShould
|
||||
{
|
||||
[TestMethod]
|
||||
public void GetNoLogs()
|
||||
{
|
||||
// Triple A Format
|
||||
// Arrange
|
||||
var userService = new InMemoryUserService();
|
||||
var expectedCount = 0;
|
||||
|
||||
// Act
|
||||
var actualFetch = userService.GetAllUsers();
|
||||
|
||||
// Assert
|
||||
// This is the best format
|
||||
Assert.IsTrue(actualFetch.Count == expectedCount);
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AllowValidUserInput()
|
||||
{
|
||||
// Triple A Format
|
||||
// Arrange
|
||||
var userService = new InMemoryUserService();
|
||||
var expectedCount = 1;
|
||||
var expectedUserMessage = "Test log entry";
|
||||
|
||||
// Act
|
||||
var actual = userService.User("Test log entry");
|
||||
var actualFetch = userService.GetAllUsers();
|
||||
|
||||
// Assert
|
||||
// This is the best format
|
||||
Assert.IsTrue(actualFetch.Count == expectedCount);
|
||||
Assert.IsTrue(actualFetch[0].Contains(expectedUserMessage));
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
[TestMethod]
|
||||
public void Users()
|
||||
{
|
||||
// Triple A Format
|
||||
// Arrange
|
||||
var inMemoryUserService = new InMemoryUserService();
|
||||
var expected = true;
|
||||
|
||||
// Act
|
||||
var actual = inMemoryUserService.User("Potato");
|
||||
|
||||
|
||||
// Assert
|
||||
// This is the best format
|
||||
Assert.IsTrue(expected == actual);
|
||||
// Alternate is
|
||||
//Assert.AreEqual(expected, actual);
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator\TeamHobby.HobbyProjectGenerator.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Loading…
Reference in New Issue
Block a user