11// Copyright (c) Six Labors.
22// Licensed under the Apache License, Version 2.0.
33
4+ using System ;
45using System . Collections . Generic ;
56using SixLabors . ImageSharp . Web . Commands ;
67using Xunit ;
@@ -17,6 +18,15 @@ public void CanAddCommands()
1718 Assert . Single ( collection ) ;
1819 }
1920
21+ [ Fact ]
22+ public void CannotAddDuplicateCommands ( )
23+ {
24+ CommandCollection collection = new ( ) ;
25+ collection . Add ( new ( "a" , "b" ) ) ;
26+ Assert . Throws < ArgumentException > ( ( ) => collection . Add ( new ( "a" , "b" ) ) ) ;
27+ Assert . Single ( collection ) ;
28+ }
29+
2030 [ Fact ]
2131 public void CanReadCommands ( )
2232 {
@@ -48,6 +58,15 @@ public void CanInsertCommands()
4858 Assert . Equal ( 0 , collection . IndexOf ( kv2 ) ) ;
4959 }
5060
61+ [ Fact ]
62+ public void CannotInsertDuplicateCommands ( )
63+ {
64+ CommandCollection collection = new ( ) ;
65+ collection . Add ( new ( "a" , "b" ) ) ;
66+ Assert . Throws < ArgumentException > ( ( ) => collection . Insert ( 0 , new ( "a" , "b" ) ) ) ;
67+ Assert . Single ( collection ) ;
68+ }
69+
5170 [ Fact ]
5271 public void CanInsertCommandsViaKey ( )
5372 {
@@ -68,6 +87,15 @@ public void CanInsertCommandsViaKey()
6887 Assert . Equal ( 0 , collection . IndexOf ( kv2 ) ) ;
6988 }
7089
90+ [ Fact ]
91+ public void CannotInsertDuplicateCommandsViaKey ( )
92+ {
93+ CommandCollection collection = new ( ) ;
94+ collection . Add ( new ( "a" , "b" ) ) ;
95+ Assert . Throws < ArgumentException > ( ( ) => collection . Insert ( 0 , "a" , "b" ) ) ;
96+ Assert . Single ( collection ) ;
97+ }
98+
7199 [ Fact ]
72100 public void CanSetCommandsViaIndex ( )
73101 {
0 commit comments