This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestClass] | |
public class CarServiceContextInitTests | |
{ | |
// to have the same Configuration object as in Startup | |
private IConfigurationRoot _configuration; | |
// represents database's configuration | |
private DbContextOptions<CarServiceContext> _options; | |
public CarServiceContextInitTests() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestMethod] | |
public void InitializeDatabaseWithDataTest() | |
{ | |
using (var context = new CarServiceContext(_options)) | |
{ | |
context.Database.EnsureDeleted(); | |
context.Database.EnsureCreated(); | |
var car1 = new Car() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public void two_persons_are_properly_saved_with_the_same_event() | |
{ | |
// given | |
var event1 = new Event | |
{ | |
Name = "Volleyball", | |
Date = new DateTime(2017, 06, 18), | |
Place = "Sports hall" | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET XACT_ABORT ON | |
GO | |
BEGIN TRANSACTION | |
GO | |
-- SQL object 1 (CREATE/ALTER/INSERT etc...) | |
GO | |
-- SQL object 2 (CREATE/ALTER/INSERT etc...) | |
GO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET xact_abort ON | |
GO | |
BEGIN TRANSACTION | |
GO | |
CREATE TABLE [dbo].[People] | |
( | |
[id] [INT] IDENTITY(1, 1) NOT NULL, | |
[name] [NVARCHAR](max) NOT NULL, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INssSERT INTO dbo.Persons -- syntax error - 'INssSERT' instead of 'INSERT' | |
(NAME) | |
VALUES ('Dawid') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET xact_abort ON | |
GO | |
BEGIN TRANSACTION | |
GO | |
CREATE TABLE [dbo].[People] | |
( | |
[id] [INT] IDENTITY(1, 1) NOT NULL, | |
[name] [NVARCHAR](max) NOT NULL, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INssSERT INTO dbo.Persons (NAME) VALUES ('Dawid') | |
GO | |
if @@error != 0 raiserror('Error in script execution', 20, -1) with log | |
GO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET xact_abort ON | |
GO | |
BEGIN TRANSACTION | |
GO | |
CREATE TABLE [dbo].[People] | |
( | |
[id] [INT] IDENTITY(1, 1) NOT NULL, | |
[name] [NVARCHAR](max) NOT NULL, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Msg 208, Level 16, State 1, Line 33 | |
Invalid object name 'dbo.Persons'. | |
Msg 3902, Level 16, State 1, Line 39 | |
The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. |