Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

-add: retrieving information from QUERY_STRING environment variable

  • Loading branch information...
commit f35f9778f9bf31a35d9a02ec379b9a7c6eb34bfa 1 parent 62a4aaa
@yas4891 authored
View
10 GSTConsole/GSTConsole.csproj
@@ -37,6 +37,14 @@
<Reference Include="Antlr3.Runtime">
<HintPath>..\ThirdPartyLibs\Antlr3.Runtime.dll</HintPath>
</Reference>
+ <Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.mocks, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\nunit.mocks.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@@ -46,8 +54,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="GeneralHelper.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="test\GeneralHelperTest.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CTokenizer\CTokenizer.csproj">
View
30 GSTConsole/GeneralHelper.cs
@@ -7,8 +7,38 @@ namespace GSTConsole
{
static class GeneralHelper
{
+ /// <summary>
+ /// extracts the student identifier from the query string
+ /// </summary>
+ /// <param name="queryString"></param>
+ /// <returns></returns>
internal static string GetStudentIdentifier(string queryString)
{
+ var firstPart = queryString.Substring(0, queryString.IndexOf('&'));
+ var afterSecondSlash = firstPart.Substring(firstPart.IndexOf('/', firstPart.IndexOf('/') + 1) + 1);
+ return afterSecondSlash.Substring(0, afterSecondSlash.IndexOf('/'));
+ }
+
+ /// <summary>
+ /// extracts the assignment identifier from the query string
+ /// </summary>
+ /// <param name="queryString"></param>
+ /// <returns></returns>
+ internal static string GetAssignmentIdentifier(string queryString)
+ {
+ var middlePart = queryString.Substring(queryString.IndexOf('&') + 1);
+ middlePart = middlePart.Substring(0, middlePart.IndexOf('&'));
+
+ return middlePart.Substring(middlePart.LastIndexOf('/') + 1);
+ }
+
+ /// <summary>
+ /// extracts the path from the query string
+ /// </summary>
+ /// <param name="queryString"></param>
+ /// <returns></returns>
+ internal static string GetPath(string queryString)
+ {
return queryString.Substring(0, queryString.IndexOf('&'));
}
}
View
7 GSTConsole/Program.cs
@@ -1,10 +1,6 @@
using System;
using System.IO;
-using CTokenizer;
-using DataRepository;
using GSTAppLogic.app;
-using GSTAppLogic.app.model;
-using GSTAppLogic.test.model;
namespace GSTConsole
{
@@ -19,7 +15,10 @@ static void Main(string[] args)
if(!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("QUERY_STRING")))
{
var queryString = Environment.GetEnvironmentVariable("QUERY_STRING");
+
+ assignment = GeneralHelper.GetAssignmentIdentifier(queryString);
student = GeneralHelper.GetStudentIdentifier(queryString);
+ path = GeneralHelper.GetPath(queryString);
}
else if(3 == args.Length)
{
View
8 GSTConsole/test/GeneralHelperTest.cs
@@ -7,7 +7,7 @@
namespace GSTConsole.test
{
[TestFixture]
- class GeneralHelperTest
+ public class GeneralHelperTest
{
private const string EXAMPLE_1 = "UPLOAD/mop/Pawelczak+Dieter/59067/V1/aufgabe2_10.c&HTML/mop/_plag/V1/aufgabe2_10&main";
@@ -16,5 +16,11 @@ public void GetStudentIdentifier()
{
Assert.AreEqual("Pawelczak+Dieter", GeneralHelper.GetStudentIdentifier(EXAMPLE_1));
}
+
+ [Test]
+ public void GetAssignmentIdentifier()
+ {
+ Assert.AreEqual("aufgabe2_10", GeneralHelper.GetAssignmentIdentifier(EXAMPLE_1));
+ }
}
}
View
8 GSTTests.VisualState.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<VisualState xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ShowCheckBoxes="true">
- <TopNode>[0-1000]D:\wissen\csharp\GreedyStringTiling\GSTTests.nunit</TopNode>
- <SelectedNode>[0-1000]D:\wissen\csharp\GreedyStringTiling\GSTTests.nunit</SelectedNode>
+ <TopNode>[0-1014]GSTLibrary.test.tile.GSTAlgorithmTest.MatchesTwoDifferentTiles</TopNode>
+ <SelectedNode>[0-1036]GSTConsole.test.GeneralHelperTest.GetStudentIdentifier</SelectedNode>
<ExcludeCategories>false</ExcludeCategories>
<Nodes>
<Node UniqueName="[0-1000]D:\wissen\csharp\GreedyStringTiling\GSTTests.nunit" Expanded="true" />
@@ -20,5 +20,9 @@
<Node UniqueName="[0-1032]GSTAppLogic" Expanded="true" />
<Node UniqueName="[0-1033]GSTAppLogic.test" Expanded="true" />
<Node UniqueName="[0-1034]GSTAppLogic.test.model" Expanded="true" />
+ <Node UniqueName="[0-1038]D:\wissen\csharp\GreedyStringTiling\GSTConsole\bin\Debug\GSTConsole.exe" Expanded="true" />
+ <Node UniqueName="[0-1039]GSTConsole" Expanded="true" />
+ <Node UniqueName="[0-1040]GSTConsole.test" Expanded="true" />
+ <Node UniqueName="[0-1035]GSTConsole.test.GeneralHelperTest" Expanded="true" />
</Nodes>
</VisualState>
View
1  GSTTests.nunit
@@ -4,6 +4,7 @@
<assembly path="GSTLibrary\bin\Debug\GSTLibrary.dll" />
<assembly path="CTokenizer\bin\Debug\CTokenizer.dll" />
<assembly path="GSTAppLogic\bin\Debug\GSTAppLogic.dll" />
+ <assembly path="GSTConsole\bin\Debug\GSTConsole.exe" />
</Config>
<Config name="Release" binpathtype="Auto" />
</NUnitProject>
Please sign in to comment.
Something went wrong with that request. Please try again.