public void ShouldThrowWhenUpdatingTwoInstancesOfSameDataAtTheSameTime() { // Arrange IProcessManagerData data1 = new TestData { CorrelationId = _correlationId, Name = "TestData1" }; _collection.Save(new MongoDbData<IProcessManagerData> { Data = data1 }); IProcessManagerFinder processManagerFinder = new MongoDbProcessManagerFinder(_connectionString, _dbName); var foundData1 = processManagerFinder.FindData<TestData>(_mapper, new Message(_correlationId)); var foundData2 = processManagerFinder.FindData<TestData>(_mapper, new Message(_correlationId)); processManagerFinder.UpdateData(foundData1); // first update should be fine // Act / Assert Assert.Throws<ArgumentException>(() => processManagerFinder.UpdateData(foundData2)); // second update should fail }
public void ShouldUpdateData() { // Arrange IProcessManagerData data = new TestData { CorrelationId = _correlationId, Name = "TestData" }; var versionData = new MongoDbData<IProcessManagerData> { Data = data }; _collection.Save(versionData); ((TestData) data).Name = "TestDataUpdated"; IProcessManagerFinder processManagerFinder = new MongoDbProcessManagerFinder(_connectionString, _dbName); // Act processManagerFinder.UpdateData(versionData); // Assert var updatedData = _collection.FindOneAs<MongoDbData<TestData>>(Query<MongoDbData<TestData>>.Where(i => i.Data.CorrelationId == _correlationId)); Assert.Equal("TestDataUpdated", updatedData.Data.Name); Assert.Equal(1, updatedData.Version); }
public void UpdateData <T>(IPersistanceData <T> data) where T : class, IProcessManagerData { Finder.UpdateData(data); }