Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 8 additions & 32 deletions src/DocumentDbTests/Indexes/UniqueIndexTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,8 @@ public void
session.Store(secondDocument);

//3. Unique Exception Was thrown
try
{
session.SaveChanges();
}
catch (DocumentAlreadyExistsException exception)
{
((PostgresException)exception.InnerException)?.SqlState.ShouldBe(UniqueSqlState);
}
var exception = Should.Throw<DocumentAlreadyExistsException>(() => session.SaveChanges());
((PostgresException)exception.InnerException)?.SqlState.ShouldBe(UniqueSqlState);
}

[Fact]
Expand All @@ -109,14 +103,8 @@ public void
session.Store(secondDocument);

//3. Unique Exception Was thrown
try
{
session.SaveChanges();
}
catch (DocumentAlreadyExistsException exception)
{
((PostgresException)exception.InnerException)?.SqlState.ShouldBe(UniqueSqlState);
}
var exception = Should.Throw<DocumentAlreadyExistsException>(() => session.SaveChanges());
((PostgresException)exception.InnerException)?.SqlState.ShouldBe(UniqueSqlState);
}

[Fact]
Expand All @@ -139,14 +127,8 @@ public void
session.Events.Append(secondEvent.UserId, secondEvent);

//3. Unique Exception Was thrown
try
{
session.SaveChanges();
}
catch (MartenCommandException exception)
{
((PostgresException)exception.InnerException)?.SqlState.ShouldBe(UniqueSqlState);
}
var exception = Should.Throw<MartenCommandException>(() => session.SaveChanges());
((PostgresException)exception.InnerException)?.SqlState.ShouldBe(UniqueSqlState);
}

[Fact]
Expand All @@ -166,13 +148,7 @@ public void
session.Events.Append(secondEvent.UserId, secondEvent);

//3. Unique Exception Was thrown
try
{
session.SaveChanges();
}
catch (DocumentAlreadyExistsException exception)
{
((PostgresException)exception.InnerException)?.SqlState.ShouldBe(UniqueSqlState);
}
var exception = Should.Throw<DocumentAlreadyExistsException>(() => session.SaveChanges());
((PostgresException)exception.InnerException)?.SqlState.ShouldBe(UniqueSqlState);
}
}