-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c72e511
commit a28bf56
Showing
13 changed files
with
210 additions
and
39 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Shouldly; | ||
using SqlSchemaCompare.Core.DbStructures; | ||
using Xunit; | ||
|
||
namespace SqlSchemaCompare.Test | ||
{ | ||
public class Miscellaneous | ||
{ | ||
[Fact] | ||
public void DbObjectEquals_TwoObjectsNull() | ||
{ | ||
DbObject dbObject1 = null; | ||
DbObject dbObject2 = null; | ||
|
||
(dbObject1 == dbObject2).ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void DbObjectEquals_OneObjectNull() | ||
{ | ||
DbObject dbObject1 = new StoreProcedure(); | ||
DbObject dbObject2 = null; | ||
|
||
(dbObject2 != dbObject1).ShouldBeTrue(); | ||
(dbObject1 != dbObject2).ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void DbObjectEquals_TwoDifferentObjectsEquals() | ||
{ | ||
DbObject dbObject1 = new StoreProcedure(); | ||
DbObject dbObject2 = new StoreProcedure(); | ||
(dbObject1 == dbObject2).ShouldBeTrue(); | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using Shouldly; | ||
using SqlSchemaCompare.Core.Common; | ||
using SqlSchemaCompare.Core.DbStructures; | ||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
namespace SqlSchemaCompare.Test.TSql | ||
{ | ||
public class CreateDatabaseTest | ||
{ | ||
private IList<DbObjectType> SelectedObjects; | ||
public CreateDatabaseTest() | ||
{ | ||
RelatedDbObjectsConfiguration relatedDbObjectsConfiguration = new(); | ||
SelectedObjects = relatedDbObjectsConfiguration.GetRelatedDbObjects(DbObjectType.StoreProcedure); | ||
} | ||
|
||
[Fact] | ||
public void DatabaseEquals_UpdateSchemaIsEmpty() | ||
{ | ||
const string origin = | ||
@"CREATE DATABASE [db] | ||
CONTAINMENT = NONE | ||
ON PRIMARY | ||
( NAME = N'db', FILENAME = N'C:\Data\DB.mdf' , SIZE = 1902592KB , MAXSIZE = UNLIMITED, FILEGROWTH = 524288KB ) | ||
LOG ON | ||
( NAME = N'db_log', FILENAME = N'C:\Data\db_log.ldf' , SIZE = 2098432KB , MAXSIZE = 2048GB , FILEGROWTH = 524288KB ) | ||
GO | ||
CREATE PROCEDURE [dbo].[proc] | ||
@par as bit = 0 | ||
AS | ||
BEGIN | ||
SELECT * from [DBO].[TBL1] | ||
END | ||
GO"; | ||
|
||
(string updateSchema, string errors) = UtilityTest.UpdateSchema(origin, origin, SelectedObjects); | ||
|
||
updateSchema.ShouldBeEmpty(); | ||
errors.ShouldBeEmpty(); | ||
} | ||
|
||
[Fact] | ||
public void DatabaseDifferent_UpdateContainsUseStatement() | ||
{ | ||
const string origin = | ||
@"CREATE DATABASE [db] | ||
CONTAINMENT = NONE | ||
ON PRIMARY | ||
( NAME = N'db', FILENAME = N'C:\Data\DB.mdf' , SIZE = 1902592KB , MAXSIZE = UNLIMITED, FILEGROWTH = 524288KB ) | ||
LOG ON | ||
( NAME = N'db_log', FILENAME = N'C:\Data\db_log.ldf' , SIZE = 2098432KB , MAXSIZE = 2048GB , FILEGROWTH = 524288KB ) | ||
GO | ||
CREATE PROCEDURE [dbo].[proc] | ||
@par as bit = 0 | ||
AS | ||
BEGIN | ||
SELECT * from [DBO].[TBL] | ||
END | ||
GO"; | ||
const string destination = | ||
@"CREATE DATABASE [db] | ||
CONTAINMENT = NONE | ||
ON PRIMARY | ||
( NAME = N'db', FILENAME = N'C:\Data\DB.mdf' , SIZE = 1902592KB , MAXSIZE = UNLIMITED, FILEGROWTH = 524288KB ) | ||
LOG ON | ||
( NAME = N'db_log', FILENAME = N'C:\Data\db_log.ldf' , SIZE = 2098432KB , MAXSIZE = 2048GB , FILEGROWTH = 524288KB ) | ||
GO | ||
CREATE PROCEDURE [dbo].[proc] | ||
@par as bit = 0 | ||
AS | ||
BEGIN | ||
SELECT * from [DBO].[TBL1] | ||
END | ||
GO"; | ||
|
||
(string updateSchema, string errors) = UtilityTest.UpdateSchema(origin, destination, SelectedObjects); | ||
|
||
updateSchema.ShouldBe( | ||
@"USE [db] | ||
GO | ||
ALTER PROCEDURE [dbo].[proc] | ||
@par as bit = 0 | ||
AS | ||
BEGIN | ||
SELECT * from [DBO].[TBL] | ||
END | ||
GO | ||
"); | ||
errors.ShouldBeEmpty(); | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Shouldly; | ||
using SqlSchemaCompare.Core.DbStructures; | ||
using Xunit; | ||
|
||
namespace SqlSchemaCompare.Test.TSql | ||
{ | ||
public class ErrorWriterTest | ||
{ | ||
[Fact] | ||
public void OrderStatement() | ||
{ | ||
string sql = | ||
@"CREATE TABLE [dbo].[tbl_Z]([ID] [int] IDENTITY(0,1) NOT NU) | ||
GO"; | ||
var (file1, file2, errors) = UtilityTest.Compare(sql, sql, new DbObjectType[] { DbObjectType.Table }); | ||
|
||
errors.ShouldBe( | ||
@"**************** ORIGIN **************** | ||
---------------------------------------- | ||
Offending token: NU | ||
Line: 1, CharPosition: 56 | ||
no viable alternative at input 'NOTNU' | ||
**************** DESTINATION **************** | ||
---------------------------------------- | ||
Offending token: NU | ||
Line: 1, CharPosition: 56 | ||
no viable alternative at input 'NOTNU' | ||
"); | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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