Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stephen Flynn #62

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
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
21 changes: 21 additions & 0 deletions RestarauntReviews.Test/RestarauntReviews.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
<PackageReference Include="coverlet.collector" Version="1.3.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\RestarauntReviews\RestarauntReviews.csproj" />
</ItemGroup>

</Project>
97 changes: 97 additions & 0 deletions RestarauntReviews.Test/RestaurantReviews.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using RestarauntReviews.Controllers;
using RestarauntReviews.Service;
using RestarauntReviews.Service.Interface;
using RestaurantReviews.DAL.DTO;
using System.Collections.Generic;

namespace RestarauntReviews.Test
{
[TestClass]
public class RestaurantReviews
{
[TestMethod]
public void RestaurantReviewService_GetRestaraunts()
{
//arrange
var list = new List<Restaurant>();
list.Add(new Restaurant() { BusinessName = "Tai Pei", PriceRatings = "Economical", RestaurantId = 1 });
var moq = new Moq.Mock<IRestaurantReviewService>();
object p = moq.Setup((a) => a.GetRestaraunts(It.IsAny<string>())).Returns(list);

//act
var controller = new RestaurantReviewsController(null, moq.Object);
var restaurants = (List<Restaurant>)controller.GetRestaurants("Pittsburgh");

//assert
Assert.AreEqual(1, restaurants.Count);
}

[TestMethod]
public void RestaurantReviewService_GetReview()
{
//arrange
var list = new List<Review>();
list.Add(new Review() { RatingScore = "1", ReviewDescription = "Delicious!", ReviewId = 1 });
var moq = new Moq.Mock<IRestaurantReviewService>();
object p = moq.Setup((a) => a.GetReviews(It.IsAny<string>())).Returns(list);

//act
var controller = new RestaurantReviewsController(null, moq.Object);
var reviews = (List<Review>)controller.GetReviews("testuser");

//assert
Assert.AreEqual(1, reviews.Count);
}

[TestMethod]
public void RestaurantReviewService_AddReview()
{
//arrange
var review = new Review() { RatingScore = "1", ReviewDescription = "Delicious!", ReviewId = 1 };
var moq = new Moq.Mock<IRestaurantReviewService>();
object p = moq.Setup((a) => a.AddReview(review)).Returns(200);

//act
var controller = new RestaurantReviewsController(null, moq.Object);
var result = controller.AddReview(review);

//assert
Assert.AreEqual(200, result);
}

[TestMethod]
public void RestaurantReviewService_DeleteReview()
{
//arrange
var moq = new Moq.Mock<IRestaurantReviewService>();
object p = moq.Setup((a) => a.DeleteReview(1)).Returns(200);

//act
var controller = new RestaurantReviewsController(null, moq.Object);
var result = controller.DeleteReview(1);

//assert
Assert.AreEqual(200, result);
}

[TestMethod]
public void RestaurantReviewService_AddRestaurant()
{
//arrange
var restaurant = new Restaurant() { BusinessName = "Burgatory", PriceRatings = "2", RestaurantId = 2 };
var moq = new Moq.Mock<IRestaurantReviewService>();
object p = moq.Setup((a) => a.AddRestaurant(restaurant)).Returns(200);

//act
var controller = new RestaurantReviewsController(null, moq.Object);
var result = controller.AddRestaurant(restaurant);

//assert
Assert.AreEqual(200, result);
}
}
}

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading