Ejemplo n.º 1
0
        public void ShouldReturnNullWhenDataNotFound()
        {
            // Arrange
            IProcessManagerFinder processManagerFinder = new MongoDbSslProcessManagerFinder(_connectionString, _dbName);

            // Act
            var result = processManagerFinder.FindData <TestDataSsl>(_mapper, new Message(_correlationId));

            // Assert
            Assert.Null(result);
        }
Ejemplo n.º 2
0
        public void ShouldThrowWhenUpdatingTwoInstancesOfSameDataAtTheSameTime()
        {
            // Arrange
            var testRepo = new MongoDbSslRepository(_connectionString, _dbName);
            IProcessManagerData data1 = new TestDataSsl {
                CorrelationId = _correlationId, Name = "TestData1"
            };
            var collection = testRepo.MongoDatabase.GetCollection <MongoDbSslData <IProcessManagerData> >(_testCollectionName);

            collection.InsertOne(new MongoDbSslData <IProcessManagerData> {
                Data = data1
            });
            IProcessManagerFinder processManagerFinder = new MongoDbSslProcessManagerFinder(_connectionString, _dbName);

            var foundData1 = processManagerFinder.FindData <TestDataSsl>(_mapper, new Message(_correlationId));
            var foundData2 = processManagerFinder.FindData <TestDataSsl>(_mapper, new Message(_correlationId));

            processManagerFinder.UpdateData(foundData1); // first update should be fine

            // Act / Assert
            Assert.Throws <ArgumentException>(() => processManagerFinder.UpdateData(foundData2)); // second update should fail
        }
Ejemplo n.º 3
0
        public void ShouldFindData()
        {
            // Arrange
            var testRepo             = new MongoDbSslRepository(_connectionString, _dbName);
            IProcessManagerData data = new TestDataSsl {
                CorrelationId = _correlationId, Name = "TestData"
            };
            IMongoCollection <MongoDbSslData <IProcessManagerData> > collection = testRepo.MongoDatabase.GetCollection <MongoDbSslData <IProcessManagerData> >(_testCollectionName);

            collection.InsertOne(new MongoDbSslData <IProcessManagerData> {
                Data = data
            });
            IProcessManagerFinder processManagerFinder = new MongoDbSslProcessManagerFinder(_connectionString, _dbName);

            // Act
            var result = processManagerFinder.FindData <TestDataSsl>(_mapper, new Message(_correlationId));

            // Assert
            Assert.Equal("TestData", result.Data.Name);
        }