public void ShouldThrowWhenInsertingDataWithExistingId()
        {
            // Arrange
            IProcessManagerData data = new TestData { CorrelationId = _correlationId, Name = "TestData" };
            IProcessManagerData dataWithDuplicateId = new TestData { CorrelationId = _correlationId, Name = "TestDataWithDuplicateId" };
            IProcessManagerFinder processManagerFinder = new InMemoryProcessManagerFinder(string.Empty, string.Empty);
            processManagerFinder.InsertData(data);

            // Act / Assert
            Assert.Throws<ArgumentException>(() => processManagerFinder.InsertData(dataWithDuplicateId));
        }
Beispiel #2
0
        public void ShouldThrowWhenInsertingDataWithExistingId()
        {
            // Arrange
            IProcessManagerData data = new TestData {
                CorrelationId = _correlationId, Name = "TestData"
            };
            IProcessManagerData dataWithDuplicateId = new TestData {
                CorrelationId = _correlationId, Name = "TestDataWithDuplicateId"
            };
            IProcessManagerFinder processManagerFinder = new InMemoryProcessManagerFinder(string.Empty, string.Empty);

            processManagerFinder.InsertData(data);

            // Act / Assert
            Assert.Throws <ArgumentException>(() => processManagerFinder.InsertData(dataWithDuplicateId));
        }
Beispiel #3
0
        public void ShouldThrowWhenUpdatingTwoInstancesOfSameDataAtTheSameTime()
        {
            // Arrange
            IProcessManagerData data1 = new TestData {
                CorrelationId = _correlationId, Name = "TestData1"
            };
            IProcessManagerFinder processManagerFinder = new InMemoryProcessManagerFinder(string.Empty, string.Empty);

            processManagerFinder.InsertData(data1);

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

            var foundData1Temp = new MemoryData <IProcessManagerData> {
                Data = foundData1.Data, Version = foundData1.Version
            };
            var foundData2Temp = new MemoryData <IProcessManagerData> {
                Data = foundData2.Data, Version = foundData2.Version
            };

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

            // Act / Assert
            Assert.Throws <ArgumentException>(() => processManagerFinder.UpdateData(foundData2Temp)); // second update should fail
        }
        public void ShouldInsertData()
        {
            // Arrange
            IProcessManagerData data = new TestData {CorrelationId = _correlationId, Name = "TestData"};
            IProcessManagerFinder processManagerFinder = new InMemoryProcessManagerFinder(string.Empty, string.Empty);

            // Act
            processManagerFinder.InsertData(data);

            // Assert
            Assert.Equal("TestData", processManagerFinder.FindData<TestData>(_mapper, new Message(_correlationId)).Data.Name);
        }
        public void ShouldDeleteData()
        {
            // Arrange
            IProcessManagerData data = new TestData { CorrelationId = _correlationId, Name = "TestData" };
            IProcessManagerFinder processManagerFinder = new InMemoryProcessManagerFinder(string.Empty, string.Empty);
            processManagerFinder.InsertData(data);

            // Act
            processManagerFinder.DeleteData(new MemoryData<IProcessManagerData> { Data = data });

            // Assert
            Assert.Null(processManagerFinder.FindData<IProcessManagerData>(_mapper, new Message(_correlationId)));
        }
Beispiel #6
0
        public void ShouldInsertData()
        {
            // Arrange
            IProcessManagerData data = new TestData {
                CorrelationId = _correlationId, Name = "TestData"
            };
            IProcessManagerFinder processManagerFinder = new InMemoryProcessManagerFinder(string.Empty, string.Empty);

            // Act
            processManagerFinder.InsertData(data);

            // Assert
            Assert.Equal("TestData", processManagerFinder.FindData <TestData>(_mapper, new Message(_correlationId)).Data.Name);
        }
Beispiel #7
0
        public void ShouldDeleteData()
        {
            // Arrange
            IProcessManagerData data = new TestData {
                CorrelationId = _correlationId, Name = "TestData"
            };
            IProcessManagerFinder processManagerFinder = new InMemoryProcessManagerFinder(string.Empty, string.Empty);

            processManagerFinder.InsertData(data);

            // Act
            processManagerFinder.DeleteData(new MemoryData <IProcessManagerData> {
                Data = data
            });

            // Assert
            Assert.Null(processManagerFinder.FindData <IProcessManagerData>(_mapper, new Message(_correlationId)));
        }
        public void ShouldThrowWhenUpdatingTwoInstancesOfSameDataAtTheSameTime()
        {
            // Arrange
            IProcessManagerData data1 = new TestData { CorrelationId = _correlationId, Name = "TestData1" };
            IProcessManagerFinder processManagerFinder = new InMemoryProcessManagerFinder(string.Empty, string.Empty);
            processManagerFinder.InsertData(data1);

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

            var foundData1Temp = new MemoryData<IProcessManagerData> { Data = foundData1.Data, Version = foundData1.Version};
            var foundData2Temp = new MemoryData<IProcessManagerData> { Data = foundData2.Data, Version = foundData2.Version };

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

            // Act / Assert
            Assert.Throws<ArgumentException>(() => processManagerFinder.UpdateData(foundData2Temp)); // second update should fail
        }