public void ActualSinError(
            [Frozen]Mock<HttpContextBase> httpContextMock,
            [Frozen]Mock<IIdentity> identityMock,
            [Frozen]Mock<IJornadaService> serviceMock,
            [Frozen]Mock<IJornadaQueries> queriesMock,
            string usuario,
            Jornada jornada)
        {
            identityMock.Setup(x => x.Name).Returns(usuario);
            queriesMock.Setup(x => x.ObtenerUltimaJornada(usuario)).Returns(jornada);

            var sut = new SituacionController(serviceMock.Object, queriesMock.Object);
            sut.ControllerContext = new ControllerContext(httpContextMock.Object, new RouteData(), sut);

            var response = sut.Actual();

            response.Model.Should().BeOfType<JornadaViewModel>();
            var model = (JornadaViewModel)response.Model;
            model.Jornada.Should().Be(jornada);
            model.Error.Should().BeNull();
        }
        public void IniciarJornadaConError(
            [Frozen]Mock<HttpContextBase> httpContextMock,
            [Frozen]Mock<IIdentity> identityMock,
            [Frozen]Mock<IJornadaService> serviceMock,
            [Frozen]Mock<IJornadaQueries> queriesMock,
            string usuario,
            InvalidOperationException exception)
        {
            identityMock.Setup(x => x.Name).Returns(usuario);
            serviceMock.Setup(s => s.IniciarJornada(usuario)).Throws(exception);

            var sut = new SituacionController(serviceMock.Object, queriesMock.Object);
            sut.ControllerContext = new ControllerContext(httpContextMock.Object, new RouteData(), sut);

            var response = sut.IniciarJornada();

            response.RouteValues["action"].Should().Be("Actual");
            sut.TempData.Should().ContainKey("error");
            sut.TempData["error"].Should().Be(exception.Message);
        }
        public void TerminarPausaSinError(
            [Frozen]Mock<HttpContextBase> httpContextMock,
            [Frozen]Mock<IIdentity> identityMock,
            [Frozen]Mock<IJornadaService> serviceMock,
            [Frozen]Mock<IJornadaQueries> queriesMock,
            string usuario)
        {
            identityMock.Setup(x => x.Name).Returns(usuario);

            var sut = new SituacionController(serviceMock.Object, queriesMock.Object);
            sut.ControllerContext = new ControllerContext(httpContextMock.Object, new RouteData(), sut);

            var response = sut.TerminarPausa();

            response.RouteValues["action"].Should().Be("Actual");
            sut.TempData.Should().BeEmpty();
        }
        public void JornadaNoIniciada(
            [Frozen]Mock<HttpContextBase> httpContextMock,
            [Frozen]Mock<IIdentity> identityMock,
            [Frozen]Mock<IJornadaService> serviceMock,
            [Frozen]Mock<IJornadaQueries> queriesMock,
            IEnumerable<DateTime> jornadas,
            string usuario,
            int max)
        {
            identityMock.Setup(x => x.Name).Returns(usuario);
            queriesMock.Setup(s => s.ObtenerDiasUltimasJornadasRegistradas(usuario, max)).Returns(jornadas);

            var sut = new SituacionController(serviceMock.Object, queriesMock.Object);
            sut.ControllerContext = new ControllerContext(httpContextMock.Object, new RouteData(), sut);

            var response = sut.UltimasJornadas();

            response.Model.Should().BeOfType<JornadaNoIniciadaViewModel>();
            var model = (JornadaNoIniciadaViewModel)response.Model;
            model.UltimasJornadasRegistradas.Should().BeEquivalentTo(jornadas);
        }