Beispiel #1
0
        public void GetAllSportsOkSportsController()
        {
            var expectedSports = new List <SportDTO>()
            {
                football, tennis
            };

            sportServicesMock.Setup(s => s.GetAllSports()).Returns(expectedSports);

            var encounterQueryServicesMock = new Mock <IEncounterQueryServices>();

            ILoginServices login = new LoginServicesMock(mariano);

            var httpContext = new DefaultHttpContext();

            httpContext.Request.Headers["Authorization"] = "";
            var controllerContext = new ControllerContext()
            {
                HttpContext = httpContext,
            };
            var controller = new SportsController(login, sportServicesMock.Object, encounterServicesMock.Object, encounterQueryServicesMock.Object, positionServicesMock.Object, teamServicesMock.Object)
            {
                ControllerContext = controllerContext,
            };

            var obtainedResult = controller.GetAllSports() as ActionResult <List <SportModelOut> >;
            var val            = obtainedResult.Value;

            sportServicesMock.Verify(s => s.GetAllSports(), Times.AtMostOnce);

            Assert.IsNotNull(obtainedResult);
            Assert.IsNotNull(obtainedResult.Value);
            Assert.AreEqual(expectedSports[0].Name, obtainedResult.Value[0].Name);
        }
Beispiel #2
0
        public void Get_ReturnsAllMembers()
        {
            var sports = GetTestSports();

            _sportServiceMock.Setup(x => x.GetAllSports())
            .Returns(sports);

            var actionResult = _sportsController.GetAllSports();

            var objectResult      = Assert.IsType <OkObjectResult>(actionResult.Result);
            var objectResultValue = Assert.IsAssignableFrom <List <SportDto> >(objectResult.Value);

            Assert.Equal(sports.Count, objectResultValue.Count);
        }