diff --git a/ContentConsole.Test.Unit/ContentConsole.Test.Unit.csproj b/ContentConsole.Test.Unit/ContentConsole.Test.Unit.csproj
index f1b05c0..4ef0993 100644
--- a/ContentConsole.Test.Unit/ContentConsole.Test.Unit.csproj
+++ b/ContentConsole.Test.Unit/ContentConsole.Test.Unit.csproj
@@ -52,6 +52,12 @@
+
+
+ {70da2b36-ebf3-4438-9f95-ecc828a64527}
+ ContentConsole
+
+
+
\ No newline at end of file
diff --git a/ContentConsole.Tests/Properties/AssemblyInfo.cs b/ContentConsole.Tests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..9f0096f
--- /dev/null
+++ b/ContentConsole.Tests/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ContentConsole.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ContentConsole.Tests")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("f8d3e313-8fc4-4143-ad7b-b24ad1baee32")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/ContentConsole.Tests1/ConsoleOutputTests.cs b/ContentConsole.Tests1/ConsoleOutputTests.cs
new file mode 100644
index 0000000..d51eddb
--- /dev/null
+++ b/ContentConsole.Tests1/ConsoleOutputTests.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ContentConsole;
+using NUnit.Framework;
+namespace ContentConsole.Tests
+{
+ [TestFixture()]
+ public class ConsoleOutputTests
+ {
+ int expected;
+ string[] badWords;
+ string content;
+ ConsoleOutput twoBad;
+ [SetUp]
+ public void initailise()
+ {
+ badWords = new string[] { "swine", "bad", "nasty", "horrible" };
+ content =
+ "The weather in Manchester in winter is bad. It rains all the time - it must be horrible for people visiting.";
+ twoBad = new ConsoleOutput(badWords, content, false);
+ }
+
+ [Test(), ExpectedException(typeof(ArgumentException))]
+ public void ConsoleOutputTest()
+ {
+ throw new ArgumentException();
+ }
+
+ [Test()]
+ public void CheckWordsTest()
+ {
+ expected = 2;
+ int actual = twoBad.CheckWords();
+ Assert.AreEqual(expected, actual);
+ }
+
+ [Test()]
+ public void HideBadWordsTest()
+ {
+
+ }
+
+ [Test()]
+ public void ShowBadWordsTest()
+ {
+
+ }
+
+ [Test()]
+ public void SpaceText()
+ {
+
+ }
+ [TearDown]
+ public void CleanUp()
+ {
+ twoBad = null;
+ }
+ }
+}
diff --git a/ContentConsole.Tests1/ContentConsole.NUnitTests.csproj b/ContentConsole.Tests1/ContentConsole.NUnitTests.csproj
new file mode 100644
index 0000000..e00d4ee
--- /dev/null
+++ b/ContentConsole.Tests1/ContentConsole.NUnitTests.csproj
@@ -0,0 +1,92 @@
+
+
+
+ Debug
+ AnyCPU
+ {E14F22B5-9439-417A-BDD2-32751CE0340A}
+ Library
+ Properties
+ ContentConsole.Tests1
+ ContentConsole.Tests1
+ v4.5
+ 512
+ {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 10.0
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+ $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
+ False
+ UnitTest
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\packages\NUnit.2.6.2\lib\nunit.framework.dll
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {70DA2B36-EBF3-4438-9F95-ECC828A64527}
+ ContentConsole
+
+
+
+
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ContentConsole.Tests1/Properties/AssemblyInfo.cs b/ContentConsole.Tests1/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..b402644
--- /dev/null
+++ b/ContentConsole.Tests1/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ContentConsole.Tests1")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ContentConsole.Tests1")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("926260d9-fcb1-4d32-8c41-7834a53b2ead")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/ContentConsole.Tests1/packages.config b/ContentConsole.Tests1/packages.config
new file mode 100644
index 0000000..62adf5a
--- /dev/null
+++ b/ContentConsole.Tests1/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/ContentConsole.sln b/ContentConsole.sln
index a148483..73684cf 100644
--- a/ContentConsole.sln
+++ b/ContentConsole.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
-VisualStudioVersion = 12.0.21005.1
+VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ContentConsole", "ContentConsole\ContentConsole.csproj", "{70DA2B36-EBF3-4438-9F95-ECC828A64527}"
EndProject
@@ -14,6 +14,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{D50987
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ContentConsole.Tests", "ContentConsole.Tests\ContentConsole.Tests.csproj", "{32031290-CEE0-44F6-AC97-0A2A58DBFF6D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ContentConsole.NUnitTests", "ContentConsole.Tests1\ContentConsole.NUnitTests.csproj", "{E14F22B5-9439-417A-BDD2-32751CE0340A}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -28,6 +32,14 @@ Global
{0F4BB904-F47A-405B-84C1-8D1332B1A781}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F4BB904-F47A-405B-84C1-8D1332B1A781}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F4BB904-F47A-405B-84C1-8D1332B1A781}.Release|Any CPU.Build.0 = Release|Any CPU
+ {32031290-CEE0-44F6-AC97-0A2A58DBFF6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {32031290-CEE0-44F6-AC97-0A2A58DBFF6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {32031290-CEE0-44F6-AC97-0A2A58DBFF6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {32031290-CEE0-44F6-AC97-0A2A58DBFF6D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E14F22B5-9439-417A-BDD2-32751CE0340A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E14F22B5-9439-417A-BDD2-32751CE0340A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E14F22B5-9439-417A-BDD2-32751CE0340A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E14F22B5-9439-417A-BDD2-32751CE0340A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/ContentConsole/ConsoleOutput.cs b/ContentConsole/ConsoleOutput.cs
new file mode 100644
index 0000000..b1e2fb3
--- /dev/null
+++ b/ContentConsole/ConsoleOutput.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ContentConsole
+{
+ public class ConsoleOutput
+ {
+
+ private string[] words;
+ private string text;
+ private bool showHide;
+ public ConsoleOutput(string[] args, string content, bool trueShow)//controls the output to the console
+ {
+ words = args;
+ text = content;
+ showHide = trueShow;
+ CheckWords();
+ if (showHide == true)
+ {
+ ShowBadWords();
+ }
+ else
+ {
+ HideBadWords();
+ }
+
+ }
+ public int CheckWords()// counts and displays the number of banned words
+ {
+ int badWords = 0;
+
+ foreach (string bannedWord in words)
+ {
+ if (text.Contains(bannedWord))
+ {
+ badWords = badWords + 1;
+ }
+ }
+ Console.WriteLine("The program scanned the text:");
+ Console.WriteLine(text);
+ Console.WriteLine("Total Number of negative words found: " + badWords);
+ return badWords;//just for testing
+ }
+
+ private void HideBadWords()
+ {
+ string modified = text;
+ foreach (string bannedWord in words)
+ {
+
+ char[] temporaryWord = bannedWord.ToCharArray();
+ int l = bannedWord.Length -1;//as the array is zero indexed
+ for (int i = 1; i < l; i++)//leaves only the first and last letters intact
+ {
+ temporaryWord[i] = '#';
+ }
+ string cleanedWord = new string(temporaryWord);
+ modified = modified.Replace(bannedWord, cleanedWord);
+ }
+
+ Console.WriteLine();
+ Console.WriteLine();
+ Console.WriteLine("Cleaned Text: ");
+ Console.WriteLine(modified);
+
+ }
+
+ private void ShowBadWords()
+ {
+ Console.WriteLine();
+ Console.WriteLine();
+ Console.WriteLine("The original text with Bad Words:");
+ Console.WriteLine(text);
+
+ }
+
+ public void SpaceText()
+ {
+ Console.WriteLine();
+ Console.WriteLine();
+ }
+ }
+
+
+}
diff --git a/ContentConsole/ContentConsole.csproj b/ContentConsole/ContentConsole.csproj
index 113bcb7..985b430 100644
--- a/ContentConsole/ContentConsole.csproj
+++ b/ContentConsole/ContentConsole.csproj
@@ -42,6 +42,7 @@
+
diff --git a/ContentConsole/Program.cs b/ContentConsole/Program.cs
index af4df25..293a1f3 100644
--- a/ContentConsole/Program.cs
+++ b/ContentConsole/Program.cs
@@ -6,39 +6,38 @@ public static class Program
{
public static void Main(string[] args)
{
- string bannedWord1 = "swine";
- string bannedWord2 = "bad";
- string bannedWord3 = "nasty";
- string bannedWord4 = "horrible";
-
- string content =
- "The weather in Manchester in winter is bad. It rains all the time - it must be horrible for people visiting.";
+ string[] badWords = new string[] { "swine", "bad", "nasty", "horrible" };//can be obtained from datastore getBadWords() would call a stored procedure to return the latest set of bad words
+ /*Along these line sorry this one happens to be MySql, but they are pretty similar
+ public DataTable getQuestions(int categoryID)
+ {
+ DataTable dt = new DataTable();
+ string query = "sp_getQuestions";
- int badWords = 0;
- if (content.Contains(bannedWord1))
- {
- badWords = badWords + 1;
- }
- if (content.Contains(bannedWord2))
- {
- badWords = badWords + 1;
- }
- if (content.Contains(bannedWord3))
+ using (MySqlConnection con = new MySqlConnection(cGlobal.CatsConnectionString))
{
- badWords = badWords + 1;
- }
- if (content.Contains(bannedWord4))
- {
- badWords = badWords + 1;
- }
-
- Console.WriteLine("Scanned the text:");
- Console.WriteLine(content);
- Console.WriteLine("Total Number of negative words: " + badWords);
+ con.Open();
+ MySqlCommand cmd = new MySqlCommand(query, con);
+ cmd.CommandType = CommandType.StoredProcedure;
+ cmd.Parameters.AddWithValue("category", categoryID);
+ cmd.ExecuteNonQuery();
+ MySqlDataAdapter da = new MySqlDataAdapter(cmd);
+ da.Fill(dt);
+ con.Close();
+ }
+ return dt;
+ }*/
+ string content =
+ "The weather in Manchester in winter is bad. It rains all the time - it must be horrible for people visiting.";
+ ConsoleOutput noBad = new ConsoleOutput(badWords, content, false);//The trueShow boolean could be provided from a datastore
+ noBad.SpaceText();
+ ConsoleOutput withBad = new ConsoleOutput(badWords, content, true);//You wouldn't normally call them both!
+ Console.WriteLine();
+ Console.WriteLine();
Console.WriteLine("Press ANY key to exit.");
Console.ReadKey();
}
+
}
}