Skip to content
Open
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
36 changes: 36 additions & 0 deletions RY_UserRepoTests
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using NUnit.Framework;
using TestProject2.BL;
using Moq;

namespace ConsoleApp7
{
class UserRepoTests
{
[Test]
public void GetUserId()
{
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 ReturnNullNameOfStudent()
{
bool callFailed = false;
try
{
var repo = new UserRepository();
Assert.Throws<NullReferenceException>(() => repo.GetUserInfo(-1));
catch (NullReferenceException)
{
callFailed = true;
}
Assert.IsTrue(callFailed, "Expected call to MyMethod to fail with NullReferenceException");
}
}
}