@@ -0,0 +1,153 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Eksamensopgave2017
{
public class User : IComparable
{
private static int _id = 1;
//---------------
// TODO Maybe make get only and set them in the constructor eller private
//ToDO Hvordan skal man håndtere invalide input til klassen!?!? Burde nok laves i konstruktoren
//---------------
public int UserID { get; }
public string FirstName { get; private set; }
public string LastName { get; private set; }
public string UserName { get; private set; }
public string Email { get; private set; }
public decimal Balance { get; set; }

#region Setters

public bool SetFirstName(string firstName)
{
if (firstName == null)
{
return false;
}
else
{
FirstName = firstName;
return true;
}
}
public bool SetLastName(string lastName)
{
if (lastName == null)
{
return false;
}
else
{
LastName = lastName;
return true;
}
}
// Returns false when name could not be set.
public bool SetUserName(string name)
{
//-------
// TODO Dobbelt tjek at ! er de rigtige steder
//-------
if (name == null
|| !name.All(c => Char.IsLower(c)
|| Char.IsDigit(c)
|| !c.Equals('_')))
{
return false;
}
else
{
UserName = name;
return true;
}
}

public bool SetEmail(string email)
{
string local;
string domain;
string[] emailSubstring = email.Split('@');
// Is it split in two?
if (emailSubstring.Length != 2)
{
return false;
}
local = emailSubstring[0];
domain = emailSubstring[1];
// Testing local for [A-Z][a-z][0-9][.,-,_]
if (!local.All(c => Char.IsLetterOrDigit(c)
|| (new[] {'.','_','-'}).Contains(c)))
{
// Maybe some exception that local was not correct
return false;
}
// Testing domain for [A-Z][a-z][0-9][.,_]
if (!domain.All(c => char.IsLetterOrDigit(c)
|| (new[] {'.','_'}).Contains(c)))
{
Console.WriteLine(domain);
return false;
}
if (domain.StartsWith("_")
||domain.StartsWith(".")
||domain.EndsWith("_")
||domain.EndsWith("."))
{

return false;
}
Email = email;
return true;
}
#endregion
#region Implemented methods

// TODO find bedre Icomparable der er mere hensigtmæssig (generisk)
public int CompareTo(Object obj)
{

try
{
//lav exception på det her
}
catch (Exception message)
{

}
User user = (User) obj;
return user.UserID - UserID;
}
//TODO Maybe add spaces between strings
public override string ToString()
{
return FirstName + LastName + Email;
}

public override bool Equals(object obj)
{
if (obj == null || obj.GetType() != typeof(User)) //simplificere?
{
return false;
}
User user = obj as User;

return user.UserID == this.UserID;
}

public override int GetHashCode()
{
// TODO check that the variables here is readonly so that the hashode never changes
return UserName.GetHashCode() + UserID;
}
#endregion
public User()
{
UserID = _id;
_id = ++_id;
}
}
}
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
@@ -0,0 +1 @@
855666209
@@ -0,0 +1,7 @@
c:\users\thomas\documents\visual studio 2015\Projects\Eksamensopgave2017\Eksamensopgave2017\bin\Debug\Eksamensopgave2017.exe.config
C:\Users\frederik\Documents\Eksamensopgave2017\Eksamensopgave2017\bin\Debug\Eksamensopgave2017.exe.config
C:\Users\frederik\Documents\Eksamensopgave2017\Eksamensopgave2017\bin\Debug\Eksamensopgave2017.exe
C:\Users\frederik\Documents\Eksamensopgave2017\Eksamensopgave2017\bin\Debug\Eksamensopgave2017.pdb
C:\Users\frederik\Documents\Eksamensopgave2017\Eksamensopgave2017\obj\Debug\Eksamensopgave2017.csprojResolveAssemblyReference.cache
C:\Users\frederik\Documents\Eksamensopgave2017\Eksamensopgave2017\obj\Debug\Eksamensopgave2017.exe
C:\Users\frederik\Documents\Eksamensopgave2017\Eksamensopgave2017\obj\Debug\Eksamensopgave2017.pdb
Empty file.
Empty file.
Empty file.
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{55F8479B-BA08-4B64-BCBA-0E955F7FBD4C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Eksamensopgave2017Tests</RootNamespace>
<AssemblyName>Eksamensopgave2017Tests</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Eksamensopgave2017\Eksamensopgave2017.csproj">
<Project>{E15B2E75-9F21-420E-A868-29F6D679A207}</Project>
<Name>Eksamensopgave2017</Name>
</ProjectReference>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -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("Eksamensopgave2017Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Eksamensopgave2017Tests")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[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("55f8479b-ba08-4b64-bcba-0e955f7fbd4c")]

// 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")]
Empty file.
Empty file.
Empty file.
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FABC4865-D3C3-4234-AAC7-171C5E6FC633}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Eksamensopgave2017Tests1</RootNamespace>
<AssemblyName>Eksamensopgave2017Tests1</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=3.6.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise />
</Choose>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Eksamensopgave2017\Eksamensopgave2017.csproj">
<Project>{E15B2E75-9F21-420E-A868-29F6D679A207}</Project>
<Name>Eksamensopgave2017</Name>
</ProjectReference>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -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("Eksamensopgave2017Tests1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Eksamensopgave2017Tests1")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[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("fabc4865-d3c3-4234-aac7-171c5e6fc633")]

// 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")]
@@ -0,0 +1,79 @@
using NUnit.Framework;
using Eksamensopgave2017;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Eksamensopgave2017.Tests
{
[TestFixture()]
public class UserTests
{
User a = new User();
[Test()]
public void SetFirstNameTest()
{
a.SetFirstName(null);
Assert.IsNotNull(a.FirstName);
}

[Test()]
public void SetLastNameTest()
{
Assert.Fail();
}

[Test()]
public void SetUserNameTest()
{
Assert.Fail();
}

[Test()]
public void SetEmailTest()
{
Assert.Fail();
}

[Test()]
public void CompareToTest()
{
Assert.Fail();
}

[Test()]
public void ToStringTest()
{
Assert.Fail();
}

[Test()]
public void EqualsTest()
{
Assert.Fail();
}

[Test()]
public void GetHashCodeTest()
{
Assert.Fail();
}

[Test()]
public void UserTest()
{

a.SetLastName(null);
a.SetUserName(null);
a.SetEmail(null);

Assert.IsNotNull(a.LastName);
Assert.IsNotNull(a.UserName);
Assert.IsNotNull(a.Email);
Assert.AreEqual(1, a.UserID);

}
}
}

Large diffs are not rendered by default.

@@ -0,0 +1,9 @@
C:\Users\frederik\Documents\Eksamensopgave2017\Eksamensopgave2017Tests1\bin\Debug\Eksamensopgave2017Tests1.dll
C:\Users\frederik\Documents\Eksamensopgave2017\Eksamensopgave2017Tests1\bin\Debug\Eksamensopgave2017Tests1.pdb
C:\Users\frederik\Documents\Eksamensopgave2017\Eksamensopgave2017Tests1\bin\Debug\Eksamensopgave2017.exe
C:\Users\frederik\Documents\Eksamensopgave2017\Eksamensopgave2017Tests1\bin\Debug\nunit.framework.dll
C:\Users\frederik\Documents\Eksamensopgave2017\Eksamensopgave2017Tests1\bin\Debug\Eksamensopgave2017.pdb
C:\Users\frederik\Documents\Eksamensopgave2017\Eksamensopgave2017Tests1\bin\Debug\nunit.framework.xml
C:\Users\frederik\Documents\Eksamensopgave2017\Eksamensopgave2017Tests1\obj\Debug\Eksamensopgave2017Tests1.csprojResolveAssemblyReference.cache
C:\Users\frederik\Documents\Eksamensopgave2017\Eksamensopgave2017Tests1\obj\Debug\Eksamensopgave2017Tests1.dll
C:\Users\frederik\Documents\Eksamensopgave2017\Eksamensopgave2017Tests1\obj\Debug\Eksamensopgave2017Tests1.pdb
Empty file.
Empty file.
Empty file.
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.6.1" targetFramework="net452" />
</packages>

Large diffs are not rendered by default.

@@ -0,0 +1,20 @@
Copyright (c) 2017 Charlie Poole

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

@@ -0,0 +1,5 @@
NUnit 3.0 is based on earlier versions of NUnit, with Portions

Copyright (c) 2002-2014 Charlie Poole or
Copyright (c) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov or
Copyright (c) 2000-2002 Philip A. Craig
Binary file not shown.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.