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
41 changes: 41 additions & 0 deletions ADS_TimeZoneConverterTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using NUnit.Framework;
using System;
using TestProject1.TimeConverter;


namespace TestProject1
{
[TestFixture]
public class TimeZoneConverterTest
{

[Test]
public void ConvertToEstTest()
{
// Arrange
var actualDateTime = DateTime.Now;
var estTime = TimeZoneConverter.ConvertToEst(actualDateTime);

// Act
TimeZoneInfo easternZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
var dt = TimeZoneInfo.ConvertTime(actualDateTime, TimeZoneInfo.Local, easternZone);

// Assert
Assert.AreEqual(dt, estTime);
}

[Test]
public void ConvertToUtcTest()
{
// Arrange
var actualDateTime = DateTime.Now;
var utcTime = TimeZoneInfo.ConvertTimeToUtc(actualDateTime);

// Act
var actual = TimeZoneConverter.ConvertToUtc(actualDateTime);

// Assert
Assert.AreEqual(utcTime, actual);
}
}
}
42 changes: 42 additions & 0 deletions AK_TimeZoneConverterTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Text;

namespace TestProject1.TimeConverter
{
[TestFixture]
class TimeZoneConverterTest
{
[Test]
public void CheckConvertToEst()
{
//Arrange
var dateTimeNow = DateTime.Now;
var expected = TimeZoneInfo.ConvertTime(dateTimeNow, TimeZoneInfo.Local, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));

//Act
var converted = TimeZoneConverter.ConvertToEst(dateTimeNow);

//Assert
Assert.AreEqual(expected.Day, converted.Day);
Assert.AreEqual(expected.Hour, converted.Hour);
Assert.AreEqual(expected.Minute, converted.Minute);
}
[Test]
public void CheckConvertToUtc()
{
//Arrange
var dateTimeNow = DateTime.Now;
var expected = TimeZoneInfo.ConvertTimeToUtc(dateTimeNow);

//Act
var converted = TimeZoneConverter.ConvertToUtc(dateTimeNow);
//Assert

Assert.AreEqual(expected.Day, converted.Day);
Assert.AreEqual(expected.Hour, converted.Hour);
Assert.AreEqual(expected.Minute, converted.Minute);
}
}
}
5 changes: 5 additions & 0 deletions Homework!!!
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Write three classes: Student, Course and School. Students should have name and unique number (inside the entire School). Name can not be empty and the unique number is between 10000 and 99999. Each course contains a set of students. Students in a course should be less than 30 and can join and leave courses.
Write following unit tests:
1. Verify max number of students in group.
2. Check whether number entire School is unique.
3. Student Name cannot be empty.
30 changes: 30 additions & 0 deletions KhromiakTimeZoneConverterTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using NUnit.Framework;

namespace Tests
{
public class TimeZoneConverterTest
{
[Test]
public void ConvertToEstTest()
{
DateTime dataTime = new DateTime(2008, 5, 1, 8, 30, 52);
DateTime expectedDataTime = new DateTime(2008, 5, 1, 1, 30, 52);

dataTime = TimeZoneConverter.ConvertToEst(dataTime);

Assert.AreEqual(expectedDataTime, dataTime);
}

[Test]
public void ConvertToUtcTest()
{
DateTime dataTime = new DateTime(2008, 5, 1, 8, 30, 52);
DateTime expectedDataTime = new DateTime(2008, 5, 1, 6, 30, 52);

dataTime = TimeZoneConverter.ConvertToUtc(dataTime);

Assert.AreEqual(expectedDataTime, dataTime);
}
}
}
37 changes: 37 additions & 0 deletions PP_TimeZoneConverterTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using NUnit.Framework;
using System;
using TestProject1.TimeConverter;

namespace TestProject1
{
[TestFixture]
public class TimeConverterTest
{
[Test]
public void Check_Convert_To_Est()
{
//Arrange
var date = DateTime.Now;
var timeZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");

//Act
var expectedEst = TimeZoneInfo.ConvertTime(date, TimeZoneInfo.Local, timeZone);

//Assert
Assert.AreEqual(expectedEst, TimeZoneConverter.ConvertToEst(date));
}

[Test]
public void Check_Convert_To_Utc()
{
//Arrange
var date = DateTime.Now;

//Act
var expectedEst = TimeZoneInfo.ConvertTimeToUtc(date);

//Assert
Assert.AreEqual(expectedEst, TimeZoneConverter.ConvertToUtc(date));
}
}
}
31 changes: 31 additions & 0 deletions PP_UserRepositoryTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using NUnit.Framework;
using System;
using TestProject2.BL;
using Moq;

namespace TestProject2
{
[TestFixture]
public class MockUserRepoTest
{
[Test]
public void Get_User_By_Id_Returns_User()
{
var mock = new Mock<IUserRepository>();

mock.Setup(x => x.GetUserInfo(It.IsAny<int>())).Returns(new User());

var actualUser = mock.Object.GetUserInfo(1);

Assert.NotNull(actualUser);
}

[Test]
public void ThrowsWhenUserNotExist()
{
var repo = new UserRepository();

Assert.Throws<NullReferenceException>(() => repo.GetUserInfo(-1));
}
}
}
38 changes: 38 additions & 0 deletions RO_TimeZoneConverterTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace TestProject1
{
using NUnit.Framework;
using System;
using TestProject1.TimeConverter;

public class TimeZoneConverterTest
{
[Test]
public void ConvertsToUtc()
{
//Arrange
DateTime currentDateTime = DateTime.Now;
DateTime expectedUtcDateTime = TimeZoneInfo.ConvertTimeToUtc(currentDateTime);

//Act
DateTime actualUtcDateTime = TimeZoneConverter.ConvertToUtc(currentDateTime);

//Assert
Assert.AreEqual(expectedUtcDateTime, actualUtcDateTime);
}

[Test]
public void ConvertsToEst()
{
//Arrange
DateTime currentDateTime = DateTime.Now;
TimeZoneInfo easternZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
DateTime expectedEstDateTime = TimeZoneInfo.ConvertTime(currentDateTime, TimeZoneInfo.Local, easternZone);

//Act
DateTime actualEstDateTime = TimeZoneConverter.ConvertToEst(currentDateTime);

//Assert
Assert.AreEqual(expectedEstDateTime, actualEstDateTime);
}
}
}