Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TestProject1/TestProject1.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
27 changes: 27 additions & 0 deletions TestProject1/TimeZoneConverterTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using NUnit.Framework;
using TestProject1.TimeConverter;

namespace TestProject1
{
public class TimeZoneConverterTest
{
[Test]
public void TimeZone_Is_Converted_To_EasternTimeZone()
{
var timeShouldBe = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, "Eastern Standard Time");
var timeIs = TimeZoneConverter.ConvertToEst(DateTime.Now);

Assert.AreEqual(timeShouldBe.Second, timeIs.Second);
}

[Test]
public void TimeZone_Is_Converted_To_UTC()
{
var timeShouldBe = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now);
var timeIs = TimeZoneConverter.ConvertToUtc(DateTime.Now);
Assert.AreEqual(timeShouldBe.Second, timeIs.Second);
}
}

}
2 changes: 1 addition & 1 deletion TestProject2/TestProject2.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
28 changes: 28 additions & 0 deletions TestProject2/UserRepositoryTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using TestProject2.BL;
using System.Linq;

namespace TestProject2
{
public class UserRepositoryTest
{
UserRepository userRepo = new UserRepository();

[Test]
public void Returns_User_By_Id_Equals_1()
{
var user = TestData.LocalUsers1.FirstOrDefault();
var userReturnedByMethod = userRepo.GetUserInfo(1);
Assert.AreEqual(user, userReturnedByMethod);
}

[Test]
public void Throws_Exception_When_Id_Equals_7()
{
Assert.Throws<NullReferenceException>(() => userRepo.GetUserInfo(7));
}
}
}
34 changes: 34 additions & 0 deletions TestProject2/UserValidityTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Text;
using TestProject2.BL;
using NUnit.Framework;
using System.Linq;

namespace TestProject2
{
class UserValidityTest
{
[Test]
public void User_Exists()
{
var user = new User() { Id = 3, UserName = "test3", CreatedAt = DateTime.UtcNow, CompanyId = 1, ContactId = 6 };
var exists = TestData.LocalUsers1.Any(x => x.Id == user.Id
&& x.UserName.Equals(user.UserName)
&& x.CompanyId == user.CompanyId
&& x.ContactId == user.ContactId);
Assert.AreEqual(true, exists);
}

[Test]
public void User_Does_Not_Exist()
{
var user = new User() { Id = 3, UserName = "test10", CreatedAt = DateTime.UtcNow, CompanyId = 1, ContactId = 6 };
var exists = TestData.LocalUsers1.Any(x => x.Id == user.Id
&& x.UserName.Equals(user.UserName)
&& x.CompanyId == user.CompanyId
&& x.ContactId == user.ContactId);
Assert.AreEqual(false, exists);
}
}
}