77 lines
2.4 KiB
C#
77 lines
2.4 KiB
C#
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using Moq;
|
|
using ResourcesManager.Controllers;
|
|
using ResourcesManager.Interfaces;
|
|
using ResourcesManager.Models;
|
|
using ResourcesManagerTests.RepositoryTests;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Web.Mvc;
|
|
|
|
namespace ResourcesManager.Controllers.Tests
|
|
{
|
|
[TestClass()]
|
|
public class SubscribeControllerTests
|
|
{
|
|
SubscribeController subController;
|
|
ResourcesControllerTests resoucesContTest;
|
|
UserRepositoryTests userRepoTest;
|
|
StatisticsControllerTests statContTest;
|
|
public SubscribeControllerTests()
|
|
{
|
|
InitializeTestData();
|
|
}
|
|
|
|
[TestInitialize]
|
|
public void InitializeTestData()
|
|
{
|
|
resoucesContTest = new ResourcesControllerTests();
|
|
userRepoTest = new UserRepositoryTests();
|
|
statContTest = new StatisticsControllerTests();
|
|
subController = new SubscribeController(resoucesContTest.mockResourceRepo.Object, userRepoTest.mockUserRepo.Object, statContTest.mockStatRepo.Object);
|
|
}
|
|
|
|
[TestMethod()]
|
|
public void Subscribe_Get_Index_Test()
|
|
{
|
|
var result = subController.Index();
|
|
Assert.IsNotNull((result as ViewResult).Model);
|
|
}
|
|
|
|
[TestMethod()]
|
|
public void Subscribe_Follow_Test()
|
|
{
|
|
subController.Follow(1);
|
|
var result = resoucesContTest.expectedResources.FirstOrDefault(r => r.Id == 1);
|
|
Assert.IsNotNull(result.Users);
|
|
}
|
|
|
|
[TestMethod()]
|
|
public void Subscribe_UnFollowAll_Test()
|
|
{
|
|
subController.UnFollowAll();
|
|
var result = resoucesContTest.expectedResources.All(x => x.Users == null || x.Users.Count == 0);
|
|
Assert.IsTrue(result);
|
|
}
|
|
|
|
[TestMethod()]
|
|
public void Subscribe_Unfollow_Test()
|
|
{
|
|
subController.Unfollow(1);
|
|
var result = resoucesContTest.expectedResources.FirstOrDefault(r => r.Id == 1);
|
|
var count = result.Users.Count;
|
|
Assert.AreEqual(count, 0);
|
|
}
|
|
|
|
[TestCleanup]
|
|
public void Resources_CleanUpTestData()
|
|
{
|
|
resoucesContTest.Resources_CleanUpTestData();
|
|
userRepoTest.User_CleanUpTestData();
|
|
statContTest = null;
|
|
}
|
|
}
|
|
} |