Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using PartyInvites.Entities;
- using PartyInvites.Concrete;
- using PartyInvites.Abstract;
- using PartyInvites.Controllers;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Moq;
- using PartyInvites.Models;
- namespace PartyInvites.Test
- {
- [TestClass]
- public class HomeControllerTests
- {
- [TestMethod]
- public void TestGetAllResponses()
- {
- //arrange
- List<GuestResponse> responses = new List<GuestResponse>();
- GuestResponse guestResponse = new GuestResponse()
- {
- Email = "mjwghout@avans.nl",
- Name = "Maikel",
- Phone = "0655878923",
- WillAttend = true,
- PhotoUrl = ""
- };
- responses.Add(guestResponse);
- GuestResponse guestResponse2 = new GuestResponse()
- {
- Email = "mjwghout@avans.nl",
- Name = "Maikel",
- Phone = "0655878923",
- WillAttend = false,
- PhotoUrl = ""
- };
- responses.Add(guestResponse2);
- Mock<IRepository> mock = new Mock<IRepository>();
- mock.Setup(m => m.GetAllResponses()).Returns(responses);
- HomeController controller = new HomeController(mock.Object);
- //act
- ViewResult result = controller.Registrations(null);
- //assert
- Assert.AreEqual(2, ((GuestResponseViewModel)result.Model).GuestResponses.Count());
- }
- [TestMethod]
- public void TestGetWillAttendResponses()
- {
- //arrange
- List<GuestResponse> responses = new List<GuestResponse>();
- GuestResponse guestResponse = new GuestResponse()
- {
- Email = "mjwghout@avans.nl",
- Name = "Maikel",
- Phone = "0655878923",
- WillAttend = true,
- PhotoUrl = ""
- };
- responses.Add(guestResponse);
- GuestResponse guestResponse2 = new GuestResponse()
- {
- Email = "mjwghout@avans.nl",
- Name = "Maikel",
- Phone = "0655878923",
- WillAttend = true,
- PhotoUrl = ""
- };
- responses.Add(guestResponse2);
- Mock<IRepository> mock = new Mock<IRepository>();
- mock.Setup(m => m.GetAllResponses()).Returns(responses);
- HomeController controller = new HomeController(mock.Object);
- //act
- ViewResult result = controller.Registrations("Aanwezig");
- //assert
- Assert.AreEqual(2, ((GuestResponseViewModel)result.Model).GuestResponses.Count());
- }
- [TestMethod]
- public void TestGetWillAttendResponses2()
- {
- //arrange
- List<GuestResponse> responses = new List<GuestResponse>();
- GuestResponse guestResponse = new GuestResponse()
- {
- Email = "mjwghout@avans.nl",
- Name = "Maikel",
- Phone = "0655878923",
- WillAttend = true,
- PhotoUrl = ""
- };
- responses.Add(guestResponse);
- GuestResponse guestResponse2 = new GuestResponse()
- {
- Email = "mjwghout@avans.nl",
- Name = "Maikel",
- Phone = "0655878923",
- WillAttend = false,
- PhotoUrl = ""
- };
- responses.Add(guestResponse2);
- Mock<IRepository> mock = new Mock<IRepository>();
- mock.Setup(m => m.GetAllResponses()).Returns(responses);
- HomeController controller = new HomeController(mock.Object);
- //act
- ViewResult result = controller.Registrations("Aanwezig");
- //assert
- Assert.AreEqual(1, ((GuestResponseViewModel)result.Model).GuestResponses.Count());
- }
- [TestMethod]
- public void TestGetWillNotAttendResponses()
- {
- //arrange
- List<GuestResponse> responses = new List<GuestResponse>();
- GuestResponse guestResponse = new GuestResponse()
- {
- Email = "mjwghout@avans.nl",
- Name = "Maikel",
- Phone = "0655878923",
- WillAttend = false,
- PhotoUrl = ""
- };
- responses.Add(guestResponse);
- GuestResponse guestResponse2 = new GuestResponse()
- {
- Email = "mjwghout@avans.nl",
- Name = "Maikel",
- Phone = "0655878923",
- WillAttend = false,
- PhotoUrl = ""
- };
- responses.Add(guestResponse2);
- Mock<IRepository> mock = new Mock<IRepository>();
- mock.Setup(m => m.GetAllResponses()).Returns(responses);
- HomeController controller = new HomeController(mock.Object);
- //act
- ViewResult result = controller.Registrations("Niet aanwezig");
- //assert
- Assert.AreEqual(2, ((GuestResponseViewModel)result.Model).GuestResponses.Count());
- }
- [TestMethod]
- public void TestGetWillNotAttendResponses2()
- {
- //arrange
- List<GuestResponse> responses = new List<GuestResponse>();
- GuestResponse guestResponse = new GuestResponse()
- {
- Email = "mjwghout@avans.nl",
- Name = "Maikel",
- Phone = "0655878923",
- WillAttend = false,
- PhotoUrl = ""
- };
- responses.Add(guestResponse);
- GuestResponse guestResponse2 = new GuestResponse()
- {
- Email = "mjwghout@avans.nl",
- Name = "Maikel",
- Phone = "0655878923",
- WillAttend = true,
- PhotoUrl = ""
- };
- responses.Add(guestResponse2);
- Mock<IRepository> mock = new Mock<IRepository>();
- mock.Setup(m => m.GetAllResponses()).Returns(responses);
- HomeController controller = new HomeController(mock.Object);
- //act
- ViewResult result = controller.Registrations("Niet aanwezig");
- //assert
- Assert.AreEqual(1, ((GuestResponseViewModel)result.Model).GuestResponses.Count());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement