示例#1
0
        public void SaveModule_Should_Call_AppendToStream_On_EventStore()
        {
            // Arrange
            _eventStoreMock
            .Setup(store => store.LoadStream(It.IsAny <string>()))
            .Returns(new EventStream(null, 0, new List <DomainEvent>()));
            var module = new Module(
                new CreeerModuleCommand
            {
                ModuleCode     = "IOPR",
                ModuleNaam     = "Object georienteerd programeren",
                AantalEc       = 3,
                Cohort         = "2019/2020",
                Studiefase     = new Studiefase("", new List <int>()),
                Competenties   = new Matrix(),
                Eindeisen      = new List <string>(),
                VerplichtVoor  = new List <Specialisatie>(),
                AanbevolenVoor = new List <Specialisatie>()
            });
            var repository = new ModuleRepository(_eventStoreMock.Object, _eventPublisherMock.Object);

            // Act
            repository.SaveModule(module);

            // Assert
            _eventStoreMock.Verify(store => store.AppendToStream(It.IsAny <EventStream>()), Times.Once);
        }
示例#2
0
        public void SaveModule_While_Module_Has_No_Changes_Should_Not_Call_AppendToStream()
        {
            // Arrange
            var module = new Module(new List <DomainEvent>
            {
                new ModuleGecreeerd
                {
                    ModuleCode     = "IOPR",
                    ModuleNaam     = "Object georienteerd programeren",
                    AantalEc       = 3,
                    Cohort         = "2019/2020",
                    Studiefase     = new Studiefase("", new List <int>()),
                    Competenties   = new Matrix(),
                    Eindeisen      = new List <string>(),
                    VerplichtVoor  = new List <Specialisatie>(),
                    AanbevolenVoor = new List <Specialisatie>()
                }
            });
            var repository = new ModuleRepository(_eventStoreMock.Object, _eventPublisherMock.Object);

            // Act
            repository.SaveModule(module);

            // Assert
            _eventStoreMock.Verify(store => store.AppendToStream(It.IsAny <EventStream>()), Times.Never);
        }
示例#3
0
        public void SaveModule_Should_Throw_ModuleAlreadyExistException_If_Module_Already_Exist()
        {
            // Arrange
            _eventStoreMock
            .Setup(store => store.LoadStream(It.IsAny <string>()))
            .Throws <ModuleAlreadyExistException>();
            var module = new Module(
                new CreeerModuleCommand
            {
                ModuleCode     = "IOPR",
                ModuleNaam     = "Object georienteerd programeren",
                AantalEc       = 3,
                Cohort         = "2019/2020",
                Studiefase     = new Studiefase("", new List <int>()),
                Competenties   = new Matrix(),
                Eindeisen      = new List <string>(),
                VerplichtVoor  = new List <Specialisatie>(),
                AanbevolenVoor = new List <Specialisatie>()
            });
            var repository = new ModuleRepository(_eventStoreMock.Object, _eventPublisherMock.Object);

            // Act
            var exception = Assert.ThrowsException <ModuleAlreadyExistException>(() => repository.SaveModule(module));

            // Assert
            Assert.AreEqual("Module already exist", exception.Message);
        }