aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Tests/DevHive.Web.Tests/FeedController.Tests.cs
diff options
context:
space:
mode:
authorKamen Mladenov <kamen.d.mladenov@protonmail.com>2021-04-09 19:51:35 +0300
committerGitHub <noreply@github.com>2021-04-09 19:51:35 +0300
commit233f38915ba0079079233eff55434ef349c05c45 (patch)
tree6c5f69017865bcab87355e910c87339453da1406 /src/DevHive.Tests/DevHive.Web.Tests/FeedController.Tests.cs
parentf4a70c6430db923af9fa9958a11c2d6612cb52cc (diff)
parenta992357efcf1bc1ece81b95ecee5e05a0b73bfdc (diff)
downloadDevHive-heroku/main.tar
DevHive-heroku/main.tar.gz
DevHive-heroku/main.zip
Merge pull request #28 from Team-Kaleidoscope/devHEADv0.2mainheroku/main
Second stage: Complete
Diffstat (limited to 'src/DevHive.Tests/DevHive.Web.Tests/FeedController.Tests.cs')
-rw-r--r--src/DevHive.Tests/DevHive.Web.Tests/FeedController.Tests.cs98
1 files changed, 0 insertions, 98 deletions
diff --git a/src/DevHive.Tests/DevHive.Web.Tests/FeedController.Tests.cs b/src/DevHive.Tests/DevHive.Web.Tests/FeedController.Tests.cs
deleted file mode 100644
index 01f67e5..0000000
--- a/src/DevHive.Tests/DevHive.Web.Tests/FeedController.Tests.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using AutoMapper;
-using DevHive.Services.Interfaces;
-using DevHive.Services.Models;
-using DevHive.Web.Controllers;
-using DevHive.Web.Models.Comment;
-using DevHive.Web.Models.Feed;
-using DevHive.Web.Models.Post;
-using Microsoft.AspNetCore.Mvc;
-using Moq;
-using NUnit.Framework;
-
-namespace DevHive.Web.Tests
-{
- [TestFixture]
- public class FeedControllerTests
- {
- private Mock<IFeedService> FeedServiceMock { get; set; }
- private Mock<IMapper> MapperMock { get; set; }
- private FeedController FeedController { get; set; }
-
- #region SetUp
- [SetUp]
- public void SetUp()
- {
- this.FeedServiceMock = new Mock<IFeedService>();
- this.MapperMock = new Mock<IMapper>();
- this.FeedController = new FeedController(this.FeedServiceMock.Object, this.MapperMock.Object);
- }
- #endregion
-
- #region GetPosts
- [Test]
- public async Task GetPosts_ReturnsOkObjectResultWithCorrectReadPageWebModel_WhenPostsExist()
- {
- GetPageWebModel getPageWebModel = new GetPageWebModel { };
- GetPageServiceModel getPageServiceModel = new GetPageServiceModel { };
- ReadPageServiceModel readPageServiceModel = new ReadPageServiceModel { };
- ReadPageWebModel readPageWebModel = new ReadPageWebModel
- {
- Posts = new List<ReadPostWebModel>
- {
- new ReadPostWebModel(),
- new ReadPostWebModel(),
- new ReadPostWebModel()
- }
- };
-
- this.FeedServiceMock.Setup(p => p.GetPage(It.IsAny<GetPageServiceModel>())).Returns(Task.FromResult(readPageServiceModel));
- this.MapperMock.Setup(p => p.Map<GetPageServiceModel>(It.IsAny<GetPageWebModel>())).Returns(getPageServiceModel);
- this.MapperMock.Setup(p => p.Map<ReadPageWebModel>(It.IsAny<ReadPageServiceModel>())).Returns(readPageWebModel);
-
- IActionResult result = await this.FeedController.GetPosts(Guid.Empty, getPageWebModel);
-
- Assert.IsInstanceOf<OkObjectResult>(result);
-
- OkObjectResult okObjectResult = result as OkObjectResult;
- ReadPageWebModel resultModel = okObjectResult.Value as Models.Comment.ReadPageWebModel;
-
- Assert.AreEqual(3, resultModel.Posts.Count);
- }
- #endregion
-
- #region GetUserPosts
- [Test]
- public async Task GetUserPosts_GetsPostsOfUser_WhenTheyExist()
- {
- GetPageWebModel getPageWebModel = new GetPageWebModel { };
- GetPageServiceModel getPageServiceModel = new GetPageServiceModel { };
- ReadPageServiceModel readPageServiceModel = new ReadPageServiceModel { };
- ReadPageWebModel readPageWebModel = new ReadPageWebModel
- {
- Posts = new List<ReadPostWebModel>
- {
- new ReadPostWebModel(),
- new ReadPostWebModel(),
- new ReadPostWebModel()
- }
- };
-
- this.FeedServiceMock.Setup(p => p.GetUserPage(It.IsAny<GetPageServiceModel>())).Returns(Task.FromResult(readPageServiceModel));
- this.MapperMock.Setup(p => p.Map<GetPageServiceModel>(It.IsAny<GetPageWebModel>())).Returns(getPageServiceModel);
- this.MapperMock.Setup(p => p.Map<ReadPageWebModel>(It.IsAny<ReadPageServiceModel>())).Returns(readPageWebModel);
-
- IActionResult result = await this.FeedController.GetUserPosts(null, getPageWebModel);
-
- Assert.IsInstanceOf<OkObjectResult>(result);
-
- OkObjectResult okObjectResult = result as OkObjectResult;
- ReadPageWebModel resultModel = okObjectResult.Value as Models.Comment.ReadPageWebModel;
-
- Assert.AreEqual(3, resultModel.Posts.Count);
- }
- #endregion
- }
-}