Esempio n. 1
0
        public void Execute_ShouldThrowArgumentException_WhenStudentIsAlreadyAPartOfThatSeason()
        {
            // Arrange
            var factoryStub = new Mock <IAcademyFactory>();
            var engineMock  = new Mock <IEngine>();
            var seasonMock  = new Mock <ISeason>();
            var studentMock = new Mock <IStudent>();

            var addStudentCommand = new AddStudentToSeasonCommandFake(factoryStub.Object, engineMock.Object);

            seasonMock.SetupGet(s => s.Students).Returns(new List <IStudent>()
            {
                new Student("Student", Track.Dev)
            });
            studentMock.SetupGet(st => st.Username).Returns("Student");

            engineMock.SetupGet(e => e.Students).Returns(new List <IStudent>()
            {
                studentMock.Object
            });
            engineMock.SetupGet(e => e.Seasons).Returns(new List <ISeason>()
            {
                seasonMock.Object
            });

            // Act & Assert
            Assert.Throws <ArgumentException>(() => addStudentCommand.Execute(new List <string>()
            {
                "Student", "0"
            }));
        }
Esempio n. 2
0
        public void Execute_ShouldAddTheStudentToTheSeasonAndLogSuccessMessage_WhenProvidedValidStudent()
        {
            // Arrange
            var factoryStub = new Mock <IAcademyFactory>();
            var engineMock  = new Mock <IEngine>();
            var seasonMock  = new Mock <ISeason>();
            var studentMock = new Mock <IStudent>();

            var addStudentCommand = new AddStudentToSeasonCommandFake(factoryStub.Object, engineMock.Object);

            seasonMock.SetupGet(s => s.Students).Returns(new List <IStudent>()
            {
                new Student("AnotherStudent", Track.Dev)
            });
            studentMock.SetupGet(st => st.Username).Returns("Student");

            engineMock.SetupGet(e => e.Students).Returns(new List <IStudent>()
            {
                studentMock.Object
            });
            engineMock.SetupGet(e => e.Seasons).Returns(new List <ISeason>()
            {
                seasonMock.Object
            });

            // Act
            var command = addStudentCommand.Execute(new List <string>()
            {
                "Student", "0"
            });

            // Assert
            StringAssert.Contains("Student", command);
            StringAssert.Contains("0", command);
        }
Esempio n. 3
0
        public void Ctor_ShouldAssignEngineToField_WhenPassedValidEngine()
        {
            // Arrange
            var validFactoryStub = new Mock <IAcademyFactory>().Object;
            var validEngineStub  = new Mock <IEngine>().Object;
            // Act
            var command = new AddStudentToSeasonCommandFake(validFactoryStub, validEngineStub);

            // Assert
            Assert.AreSame(validEngineStub, command.Engine);
        }
Esempio n. 4
0
        public void CreateCommand_ShouldCorrectlyAssignPassedEngine_WhenProvdedValidParamsToTheConstructor()
        {
            // Arrange
            var factoryStub = new Mock <IAcademyFactory>();
            var engineStub  = new Mock <IEngine>();

            // Act
            var addStudent = new AddStudentToSeasonCommandFake(factoryStub.Object, engineStub.Object);

            // Assert
            Assert.AreSame(engineStub.Object, addStudent.ExposeEngine);
        }