From 2f47d5c828cf078b65e9591a0ff20a50a106034f Mon Sep 17 00:00:00 2001
From: Ming Tsai <37890026+ming-tsai@users.noreply.github.com>
Date: Wed, 14 Apr 2021 21:42:45 -0400
Subject: [PATCH] chore: moving csharp file to its project (#198)
---
algorithms/CSharp/.gitignore | 362 ++++++++++++++++++
algorithms/CSharp/.vscode/launch.json | 27 ++
algorithms/CSharp/.vscode/tasks.json | 42 ++
algorithms/CSharp/CSharp.sln | 48 +++
algorithms/CSharp/README.md | 9 +
algorithms/CSharp/src/Algorithms.csproj | 7 +
algorithms/CSharp/src/Sorts/bubble-sort.cs | 31 ++
algorithms/CSharp/src/Sorts/insertion-sort.cs | 36 ++
algorithms/CSharp/src/Sorts/selection-sort.cs | 40 ++
algorithms/CSharp/src/Strings/palindrome.cs | 28 ++
.../CSharp/test/Algorithms.Tests.csproj | 19 +
algorithms/CSharp/test/Sorts/bubble-sort.cs | 17 +
.../CSharp/test/Sorts/insertion-sort.cs | 17 +
.../CSharp/test/Sorts/selection-sort.cs | 17 +
algorithms/CSharp/test/Strings/palindrome.cs | 18 +
sorting/README.md | 8 -
sorting/csharp/bubble-sort.cs | 28 --
sorting/csharp/insertion-sort.cs | 33 --
sorting/csharp/selection-sort.cs | 37 --
strings/README.md | 5 -
strings/csharp/palindrome.cs | 24 --
21 files changed, 718 insertions(+), 135 deletions(-)
create mode 100644 algorithms/CSharp/.gitignore
create mode 100644 algorithms/CSharp/.vscode/launch.json
create mode 100644 algorithms/CSharp/.vscode/tasks.json
create mode 100644 algorithms/CSharp/CSharp.sln
create mode 100644 algorithms/CSharp/README.md
create mode 100644 algorithms/CSharp/src/Algorithms.csproj
create mode 100644 algorithms/CSharp/src/Sorts/bubble-sort.cs
create mode 100644 algorithms/CSharp/src/Sorts/insertion-sort.cs
create mode 100644 algorithms/CSharp/src/Sorts/selection-sort.cs
create mode 100644 algorithms/CSharp/src/Strings/palindrome.cs
create mode 100644 algorithms/CSharp/test/Algorithms.Tests.csproj
create mode 100644 algorithms/CSharp/test/Sorts/bubble-sort.cs
create mode 100644 algorithms/CSharp/test/Sorts/insertion-sort.cs
create mode 100644 algorithms/CSharp/test/Sorts/selection-sort.cs
create mode 100644 algorithms/CSharp/test/Strings/palindrome.cs
delete mode 100644 sorting/csharp/bubble-sort.cs
delete mode 100644 sorting/csharp/insertion-sort.cs
delete mode 100644 sorting/csharp/selection-sort.cs
delete mode 100644 strings/csharp/palindrome.cs
diff --git a/algorithms/CSharp/.gitignore b/algorithms/CSharp/.gitignore
new file mode 100644
index 00000000..3a8542dc
--- /dev/null
+++ b/algorithms/CSharp/.gitignore
@@ -0,0 +1,362 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# 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
+# Note: 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
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# 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
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# 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
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# 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
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
\ No newline at end of file
diff --git a/algorithms/CSharp/.vscode/launch.json b/algorithms/CSharp/.vscode/launch.json
new file mode 100644
index 00000000..15f08e94
--- /dev/null
+++ b/algorithms/CSharp/.vscode/launch.json
@@ -0,0 +1,27 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ // Use IntelliSense to find out which attributes exist for C# debugging
+ // Use hover for the description of the existing attributes
+ // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
+ "name": ".NET Core Launch (console)",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ // If you have changed target frameworks, make sure to update the program path.
+ "program": "${workspaceFolder}/test/bin/Debug/netcoreapp3.1/Algorithms.Tests.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}/test",
+ // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
+ "console": "internalConsole",
+ "stopAtEntry": false
+ },
+ {
+ "name": ".NET Core Attach",
+ "type": "coreclr",
+ "request": "attach",
+ "processId": "${command:pickProcess}"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/algorithms/CSharp/.vscode/tasks.json b/algorithms/CSharp/.vscode/tasks.json
new file mode 100644
index 00000000..17a32f2e
--- /dev/null
+++ b/algorithms/CSharp/.vscode/tasks.json
@@ -0,0 +1,42 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build",
+ "${workspaceFolder}/test/Algorithms.Tests.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "publish",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "publish",
+ "${workspaceFolder}/test/Algorithms.Tests.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "watch",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "watch",
+ "run",
+ "${workspaceFolder}/test/Algorithms.Tests.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/algorithms/CSharp/CSharp.sln b/algorithms/CSharp/CSharp.sln
new file mode 100644
index 00000000..b1f09671
--- /dev/null
+++ b/algorithms/CSharp/CSharp.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}") = "Algorithms", "src\Algorithms.csproj", "{EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Algorithms.Tests", "test\Algorithms.Tests.csproj", "{8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}"
+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
+ {EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Debug|x64.Build.0 = Debug|Any CPU
+ {EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Debug|x86.Build.0 = Debug|Any CPU
+ {EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Release|x64.ActiveCfg = Release|Any CPU
+ {EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Release|x64.Build.0 = Release|Any CPU
+ {EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Release|x86.ActiveCfg = Release|Any CPU
+ {EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Release|x86.Build.0 = Release|Any CPU
+ {8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Debug|x64.Build.0 = Debug|Any CPU
+ {8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Debug|x86.Build.0 = Debug|Any CPU
+ {8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Release|x64.ActiveCfg = Release|Any CPU
+ {8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Release|x64.Build.0 = Release|Any CPU
+ {8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Release|x86.ActiveCfg = Release|Any CPU
+ {8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Release|x86.Build.0 = Release|Any CPU
+ EndGlobalSection
+EndGlobal
diff --git a/algorithms/CSharp/README.md b/algorithms/CSharp/README.md
new file mode 100644
index 00000000..43795628
--- /dev/null
+++ b/algorithms/CSharp/README.md
@@ -0,0 +1,9 @@
+# C#
+## Strings
+- [Palindrome](src/Strings/palindrome.cs)
+
+## Sorts
+
+1. [Bubble Sort](src/Sorts/bubble-sort.cs)
+2. [Insertion Sort](src/Sorts/insertion-sort.cs)
+3. [Selection Sort](src/Sorts/selection-sort.cs)
\ No newline at end of file
diff --git a/algorithms/CSharp/src/Algorithms.csproj b/algorithms/CSharp/src/Algorithms.csproj
new file mode 100644
index 00000000..cb631906
--- /dev/null
+++ b/algorithms/CSharp/src/Algorithms.csproj
@@ -0,0 +1,7 @@
+
+
+
+ netcoreapp3.1
+
+
+
diff --git a/algorithms/CSharp/src/Sorts/bubble-sort.cs b/algorithms/CSharp/src/Sorts/bubble-sort.cs
new file mode 100644
index 00000000..b16248fb
--- /dev/null
+++ b/algorithms/CSharp/src/Sorts/bubble-sort.cs
@@ -0,0 +1,31 @@
+using System;
+
+namespace Algorithms.Sorts
+{
+ public class BubbleSort
+ {
+ public static void Main()
+ {
+ int[] arr = { 800, 11, 50, 771, 649, 770, 240, 9 };
+ Sort(arr);
+ var result = string.Join(" ", arr);
+ Console.WriteLine(result);
+ }
+
+ public static void Sort(int[] source)
+ {
+ for (int write = 0; write < source.Length; write++)
+ {
+ for (int sort = 0; sort < source.Length - 1; sort++)
+ {
+ if (source[sort] > source[sort + 1])
+ {
+ var temp = source[sort + 1];
+ source[sort + 1] = source[sort];
+ source[sort] = temp;
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/algorithms/CSharp/src/Sorts/insertion-sort.cs b/algorithms/CSharp/src/Sorts/insertion-sort.cs
new file mode 100644
index 00000000..c7c14982
--- /dev/null
+++ b/algorithms/CSharp/src/Sorts/insertion-sort.cs
@@ -0,0 +1,36 @@
+using System;
+
+namespace Algorithms.Sorts
+{
+ public class InsertionSort
+ {
+ public static void Main()
+ {
+ int[] arr = { 800, 11, 50, 771, 649, 770, 240, 9 };
+ Sort(arr);
+ var result = string.Join(" ", arr);
+ Console.WriteLine(result);
+ }
+
+ public static void Sort(int[] source)
+ {
+ int n = source.Length;
+ for (int i = 1; i < n; ++i)
+ {
+ int key = source[i];
+ int j = i - 1;
+
+ // Move elements of arr[0..i-1],
+ // that are greater than key,
+ // to one position ahead of
+ // their current position
+ while (j >= 0 && source[j] > key)
+ {
+ source[j + 1] = source[j];
+ j = j - 1;
+ }
+ source[j + 1] = key;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/algorithms/CSharp/src/Sorts/selection-sort.cs b/algorithms/CSharp/src/Sorts/selection-sort.cs
new file mode 100644
index 00000000..6dd53654
--- /dev/null
+++ b/algorithms/CSharp/src/Sorts/selection-sort.cs
@@ -0,0 +1,40 @@
+using System;
+
+namespace Algorithms.Sorts
+{
+ public class SelectionSort
+ {
+ public static void Main()
+ {
+ int[] arr = { 800, 11, 50, 771, 649, 770, 240, 9 };
+ Sort(arr);
+ var result = string.Join(" ", arr);
+ Console.WriteLine(result);
+ }
+
+ public static void Sort(int[] source)
+ {
+ int n = source.Length;
+
+ // One by one move boundary of unsorted subarray
+ for (int i = 0; i < n - 1; i++)
+ {
+ // Find the minimum element in unsorted array
+ int min_idx = i;
+ for (int j = i + 1; j < n; j++)
+ {
+ if (source[j] < source[min_idx])
+ {
+ min_idx = j;
+ }
+ }
+
+ // Swap the found minimum element with the first
+ // element
+ int temp = source[min_idx];
+ source[min_idx] = source[i];
+ source[i] = temp;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/algorithms/CSharp/src/Strings/palindrome.cs b/algorithms/CSharp/src/Strings/palindrome.cs
new file mode 100644
index 00000000..3c30ad33
--- /dev/null
+++ b/algorithms/CSharp/src/Strings/palindrome.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Linq;
+using System.Text.RegularExpressions;
+
+namespace Algorithms.Strings
+{
+ public class Palindrome
+ {
+ public static void Main()
+ {
+ bool result = false;
+ result = IsPalindrome("abba");
+ Console.WriteLine(result);
+ result = IsPalindrome("abbccbbA");
+ Console.WriteLine(result);
+ result = IsPalindrome("Mr. Owl ate my metal worm");
+ Console.WriteLine(result);
+ }
+
+ public static bool IsPalindrome(string source)
+ {
+ source = source.ToLower();
+ source = Regex.Replace(source, @"[^0-9A-Za-z]", "");
+ string reverse = new string(Enumerable.Range(1, source.Length).Select(i => source[source.Length - i]).ToArray());
+ return reverse == source;
+ }
+ }
+}
\ No newline at end of file
diff --git a/algorithms/CSharp/test/Algorithms.Tests.csproj b/algorithms/CSharp/test/Algorithms.Tests.csproj
new file mode 100644
index 00000000..e26afb5b
--- /dev/null
+++ b/algorithms/CSharp/test/Algorithms.Tests.csproj
@@ -0,0 +1,19 @@
+
+
+
+ netcoreapp3.1
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/algorithms/CSharp/test/Sorts/bubble-sort.cs b/algorithms/CSharp/test/Sorts/bubble-sort.cs
new file mode 100644
index 00000000..4da77fc1
--- /dev/null
+++ b/algorithms/CSharp/test/Sorts/bubble-sort.cs
@@ -0,0 +1,17 @@
+using NUnit.Framework;
+
+namespace algorithms.CSharp.Test.Sorts
+{
+ [TestFixture]
+ internal class BubbleSort
+ {
+ [Test]
+ public void SortTheArray_ShouldGetExpectedString()
+ {
+ int[] array = { 800, 11, 50, 771, 649, 770, 240, 9 };
+ Algorithms.Sorts.BubbleSort.Sort(array);
+ var result = string.Join(" ", array);
+ Assert.AreEqual("9 11 50 240 649 770 771 800", result);
+ }
+ }
+}
\ No newline at end of file
diff --git a/algorithms/CSharp/test/Sorts/insertion-sort.cs b/algorithms/CSharp/test/Sorts/insertion-sort.cs
new file mode 100644
index 00000000..f8f8fa9c
--- /dev/null
+++ b/algorithms/CSharp/test/Sorts/insertion-sort.cs
@@ -0,0 +1,17 @@
+using NUnit.Framework;
+
+namespace algorithms.CSharp.Test.Sorts
+{
+ [TestFixture]
+ internal class InsertionSort
+ {
+ [Test]
+ public void SortTheArray_ShouldGetExpectedString()
+ {
+ int[] array = { 800, 11, 50, 771, 649, 770, 240, 9 };
+ Algorithms.Sorts.InsertionSort.Sort(array);
+ var result = string.Join(" ", array);
+ Assert.AreEqual("9 11 50 240 649 770 771 800", result);
+ }
+ }
+}
\ No newline at end of file
diff --git a/algorithms/CSharp/test/Sorts/selection-sort.cs b/algorithms/CSharp/test/Sorts/selection-sort.cs
new file mode 100644
index 00000000..5cb558b6
--- /dev/null
+++ b/algorithms/CSharp/test/Sorts/selection-sort.cs
@@ -0,0 +1,17 @@
+using NUnit.Framework;
+
+namespace algorithms.CSharp.Test.Sorts
+{
+ [TestFixture]
+ internal class SelectionSort
+ {
+ [Test]
+ public void SortTheArray_ShouldGetExpectedString()
+ {
+ int[] array = { 800, 11, 50, 771, 649, 770, 240, 9 };
+ Algorithms.Sorts.SelectionSort.Sort(array);
+ var result = string.Join(" ", array);
+ Assert.AreEqual("9 11 50 240 649 770 771 800", result);
+ }
+ }
+}
\ No newline at end of file
diff --git a/algorithms/CSharp/test/Strings/palindrome.cs b/algorithms/CSharp/test/Strings/palindrome.cs
new file mode 100644
index 00000000..800074ee
--- /dev/null
+++ b/algorithms/CSharp/test/Strings/palindrome.cs
@@ -0,0 +1,18 @@
+using NUnit.Framework;
+
+namespace Algorithms.CSharp.Test.Strings
+{
+ [TestFixture]
+ internal class Palindrome
+ {
+ [TestCase("abba", true)]
+ [TestCase("abbccbbA", true)]
+ [TestCase("Mr. Owl ate my metal worm", true)]
+ [TestCase("asdfgasdfg", false)]
+ public void PassString_ShouldGetExpectedResult(string text, bool expected)
+ {
+ var result = Algorithms.Strings.Palindrome.IsPalindrome(text);
+ Assert.AreEqual(expected, result);
+ }
+ }
+}
\ No newline at end of file
diff --git a/sorting/README.md b/sorting/README.md
index 63a1761f..8d53fc78 100644
--- a/sorting/README.md
+++ b/sorting/README.md
@@ -15,14 +15,6 @@
11. [Comb Sort](c-or-cpp/comb-sort.cpp)
12. [3 Way Quick Sort](c-or-cpp/3way_quick_sort.cpp)
-
-
-### C#
-
-1. [Bubble Sort](csharp/bubble-sort.cs)
-2. [Insertion Sort](csharp/insertion-sort.cs)
-3. [Selection Sort](csharp/selection-sort.cs)
-
### Python
1. [Bubble Sort](python/bubble-sort.py)
diff --git a/sorting/csharp/bubble-sort.cs b/sorting/csharp/bubble-sort.cs
deleted file mode 100644
index 7346933c..00000000
--- a/sorting/csharp/bubble-sort.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System;
-
-public class Program
-{
- public static void Main()
- {
- int[] arr = { 800, 11, 50, 771, 649, 770, 240, 9 };
- Sort(arr);
- var result = string.Join(" ", arr);
- Console.WriteLine(result);
- }
-
- public static void Sort(int[] source)
- {
- for (int write = 0; write < source.Length; write++)
- {
- for (int sort = 0; sort < source.Length - 1; sort++)
- {
- if (source[sort] > source[sort + 1])
- {
- var temp = source[sort + 1];
- source[sort + 1] = source[sort];
- source[sort] = temp;
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/sorting/csharp/insertion-sort.cs b/sorting/csharp/insertion-sort.cs
deleted file mode 100644
index 02e4184f..00000000
--- a/sorting/csharp/insertion-sort.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System;
-
-public class Program
-{
- public static void Main()
- {
- int[] arr = { 800, 11, 50, 771, 649, 770, 240, 9 };
- Sort(arr);
- var result = string.Join(" ", arr);
- Console.WriteLine(result);
- }
-
- private static void Sort(int[] source)
- {
- int n = source.Length;
- for (int i = 1; i < n; ++i)
- {
- int key = source[i];
- int j = i - 1;
-
- // Move elements of arr[0..i-1],
- // that are greater than key,
- // to one position ahead of
- // their current position
- while (j >= 0 && source[j] > key)
- {
- source[j + 1] = source[j];
- j = j - 1;
- }
- source[j + 1] = key;
- }
- }
-}
\ No newline at end of file
diff --git a/sorting/csharp/selection-sort.cs b/sorting/csharp/selection-sort.cs
deleted file mode 100644
index 8a44bac9..00000000
--- a/sorting/csharp/selection-sort.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System;
-
-public class Program
-{
- public static void Main()
- {
- int[] arr = { 800, 11, 50, 771, 649, 770, 240, 9 };
- Sort(arr);
- var result = string.Join(" ", arr);
- Console.WriteLine(result);
- }
-
- private static void Sort(int[] source)
- {
- int n = source.Length;
-
- // One by one move boundary of unsorted subarray
- for (int i = 0; i < n - 1; i++)
- {
- // Find the minimum element in unsorted array
- int min_idx = i;
- for (int j = i + 1; j < n; j++)
- {
- if (source[j] < source[min_idx])
- {
- min_idx = j;
- }
- }
-
- // Swap the found minimum element with the first
- // element
- int temp = source[min_idx];
- source[min_idx] = source[i];
- source[i] = temp;
- }
- }
-}
\ No newline at end of file
diff --git a/strings/README.md b/strings/README.md
index 093af2aa..db502f05 100644
--- a/strings/README.md
+++ b/strings/README.md
@@ -9,11 +9,6 @@
5. [String Tokeniser](c-or-cpp/string-tokeniser.cpp)
6. [String Reversal](c-or-cpp/string-reverse.cpp)
7. [Permutation of String](c-or-cpp/Permutation-of-String.c)
-
-### C#
-
-1. [Palindrome Check](csharp/palindrome.cs)
-
### JavaScript
1. [Palindrome Check](js/palindrome.js)
diff --git a/strings/csharp/palindrome.cs b/strings/csharp/palindrome.cs
deleted file mode 100644
index b01d70cb..00000000
--- a/strings/csharp/palindrome.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using System.Linq;
-using System.Text.RegularExpressions;
-
-public class Program
-{
- public static void Main()
- {
- bool result = false;
- result = IsPalindrome("abba");
- Console.WriteLine(result);
- result = IsPalindrome("abbccbbA");
- Console.WriteLine(result);
- result = IsPalindrome("Mr. Owl ate my metal worm");
- Console.WriteLine(result);
- }
-
- private static bool IsPalindrome(string source) {
- source = source.ToLower();
- source = Regex.Replace(source, @"[^0-9A-Za-z]", "");
- string reverse = new string(Enumerable.Range(1, source.Length).Select(i => source[source.Length - i]).ToArray());
- return reverse == source;
- }
-}
\ No newline at end of file