Beispiel #1
0
        public void ExecuteShouldRetrurnMessageWhenUserNotLogged()
        {
            //Arrange
            var state   = new Mock <ISessionState>();
            var builder = new Mock <IStringBuilderWrapper>();
            var service = new Mock <ICourseService>();

            var command = new CheckGradesForCourseCommand(state.Object, builder.Object, service.Object);

            state.Setup(s => s.IsLogged).Returns(false);

            var parameters = new string[] { "" };

            //Assert + Act
            Assert.AreEqual("You will need to login first", command.Execute(parameters));
        }
Beispiel #2
0
        public void ExecuteShouldThrowWhenCourseNameIsNull()
        {
            //Arrange
            var state   = new Mock <ISessionState>();
            var builder = new Mock <IStringBuilderWrapper>();
            var service = new Mock <ICourseService>();

            var command = new CheckGradesForCourseCommand(state.Object, builder.Object, service.Object);

            state.Setup(s => s.IsLogged).Returns(true);
            state.Setup(s => s.RoleId).Returns(3);

            var parameters = new string[] { "" };

            //Assert + Act
            Assert.AreEqual("The course name can`t be null", command.Execute(parameters));
        }
Beispiel #3
0
        public void ExecuteShouldReturnMessageWhenIncorrectRoleIsPassed()
        {
            //Arrange
            var state   = new Mock <ISessionState>();
            var builder = new Mock <IStringBuilderWrapper>();
            var service = new Mock <ICourseService>();

            var command = new CheckGradesForCourseCommand(state.Object, builder.Object, service.Object);

            state.Setup(s => s.IsLogged).Returns(true);
            state.Setup(s => s.RoleId).Returns(2);

            var parameters = new string[] { "Username" };

            //Assert + Act
            Assert.AreEqual("This command is available only to users with role Student", command.Execute(parameters));
        }
Beispiel #4
0
        public void ExecuteShouldReturnWhenThereAreNoGrades()
        {
            var state   = new Mock <ISessionState>();
            var builder = new Mock <IStringBuilderWrapper>();
            var service = new Mock <ICourseService>();

            var command = new CheckGradesForCourseCommand(state.Object, builder.Object, service.Object);

            state.Setup(s => s.IsLogged).Returns(true);
            state.Setup(s => s.RoleId).Returns(3);
            state.SetupGet(s => s.UserName).Returns("pesho");

            service.Setup(s => s.RetrieveGrades("pesho", "Alpha JS")).Returns(new List <GradeViewModel>());

            var parameters = new string[] { "Alpha JS" };

            Assert.AreEqual("No grades available for the course Alpha JS", command.Execute(parameters));
        }