Skip to content

Commit bd46c37

Browse files
Merge pull request #59 from TransactionProcessing/bug/#56_silenthandleduplicatefilecreate
Silently handle duplicate file creates
2 parents a865ad1 + aa5b84c commit bd46c37

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

FileProcessor.FileAggregate.Tests/FileAggregateTests.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,23 @@ public void FileAggregate_CreateFile_FileIsCreated()
5353
}
5454

5555
[Fact]
56-
public void FileAggregate_CreateFile_FileAlreadyCreated_ErrorThrown()
56+
public void FileAggregate_CreateFile_FileAlreadyCreated_NoErrorThrown()
5757
{
5858
FileAggregate fileAggregate = FileAggregate.Create(TestData.FileId);
5959
fileAggregate.CreateFile(TestData.FileImportLogId, TestData.EstateId, TestData.MerchantId, TestData.UserId,
6060
TestData.FileProfileId, TestData.FileLocation, TestData.FileUploadedDateTime);
6161

62-
Should.Throw<InvalidOperationException>(() =>
63-
{
64-
65-
fileAggregate.CreateFile(TestData.FileImportLogId, TestData.EstateId, TestData.MerchantId, TestData.UserId,
66-
TestData.FileProfileId, TestData.FileLocation, TestData.FileUploadedDateTime);
67-
});
62+
Should.NotThrow(() =>
63+
{
64+
65+
fileAggregate.CreateFile(TestData.FileImportLogId,
66+
TestData.EstateId,
67+
TestData.MerchantId,
68+
TestData.UserId,
69+
TestData.FileProfileId,
70+
TestData.FileLocation,
71+
TestData.FileUploadedDateTime);
72+
});
6873
}
6974

7075
[Fact]

FileProcessor.FileAggregate/FileAggregate.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,7 @@ private void PlayEvent(FileProcessingCompletedEvent domainEvent)
247247
public void CreateFile(Guid fileImportLogId, Guid estateId, Guid merchantId, Guid userId, Guid fileProfileId, String fileLocation, DateTime fileReceivedDateTime)
248248
{
249249
if (this.IsCreated)
250-
{
251-
throw new InvalidOperationException($"File Id {this.AggregateId} has already been created");
252-
}
250+
return;
253251

254252
FileCreatedEvent fileCreatedEvent = new FileCreatedEvent(this.AggregateId, fileImportLogId, estateId, merchantId, userId, fileProfileId, fileLocation, fileReceivedDateTime);
255253

0 commit comments

Comments
 (0)