@@ -725,6 +725,60 @@ public void DropForeignKey()
725725 Assert . AreEqual ( NewLineEnd ( @"ALTER TABLE ""People"" DROP CONSTRAINT ""FK_People_Principal"";" ) , batch [ 0 ] . CommandText ) ;
726726 }
727727
728+ [ Test ]
729+ public void AddUniqueConstraintOneColumn ( )
730+ {
731+ var operation = new AddUniqueConstraintOperation ( )
732+ {
733+ Table = "People" ,
734+ Name = "UNQ_People_Foo" ,
735+ Columns = new [ ] { "Foo" } ,
736+ } ;
737+ var batch = Generate ( new [ ] { operation } ) ;
738+ Assert . AreEqual ( 1 , batch . Count ( ) ) ;
739+ Assert . AreEqual ( NewLineEnd ( @"ALTER TABLE ""People"" ADD CONSTRAINT ""UNQ_People_Foo"" UNIQUE (""Foo"");" ) , batch [ 0 ] . CommandText ) ;
740+ }
741+
742+ [ Test ]
743+ public void AddUniqueConstraintTwoColumns ( )
744+ {
745+ var operation = new AddUniqueConstraintOperation ( )
746+ {
747+ Table = "People" ,
748+ Name = "UNQ_People_Foo_Bar" ,
749+ Columns = new [ ] { "Foo" , "Bar" } ,
750+ } ;
751+ var batch = Generate ( new [ ] { operation } ) ;
752+ Assert . AreEqual ( 1 , batch . Count ( ) ) ;
753+ Assert . AreEqual ( NewLineEnd ( @"ALTER TABLE ""People"" ADD CONSTRAINT ""UNQ_People_Foo_Bar"" UNIQUE (""Foo"", ""Bar"");" ) , batch [ 0 ] . CommandText ) ;
754+ }
755+
756+ [ Test ]
757+ public void AddUniqueConstraintNoName ( )
758+ {
759+ var operation = new AddUniqueConstraintOperation ( )
760+ {
761+ Table = "People" ,
762+ Columns = new [ ] { "Foo" } ,
763+ } ;
764+ var batch = Generate ( new [ ] { operation } ) ;
765+ Assert . AreEqual ( 1 , batch . Count ( ) ) ;
766+ Assert . AreEqual ( NewLineEnd ( @"ALTER TABLE ""People"" ADD UNIQUE (""Foo"");" ) , batch [ 0 ] . CommandText ) ;
767+ }
768+
769+ [ Test ]
770+ public void DropUniqueConstraint ( )
771+ {
772+ var operation = new DropUniqueConstraintOperation ( )
773+ {
774+ Table = "People" ,
775+ Name = "UNQ_People_Foo" ,
776+ } ;
777+ var batch = Generate ( new [ ] { operation } ) ;
778+ Assert . AreEqual ( 1 , batch . Count ( ) ) ;
779+ Assert . AreEqual ( NewLineEnd ( @"ALTER TABLE ""People"" DROP CONSTRAINT ""UNQ_People_Foo"";" ) , batch [ 0 ] . CommandText ) ;
780+ }
781+
728782 IReadOnlyList < MigrationCommand > Generate ( IReadOnlyList < MigrationOperation > operations )
729783 {
730784 using ( var db = GetDbContext < FbTestDbContext > ( ) )
0 commit comments