public void WorksWithCollectionsOfArrays()
        {
            byte[] array1 = new byte[] { 0x20, 0x44, 0x56, 0x76, 0x1e, 0xff };
            byte[] array2 = new byte[] { 0x42, 0x52, 0x72, 0xef };
            byte[] array3 = new byte[] { 0x20, 0x44, 0x56, 0x76, 0x1e, 0xff };
            byte[] array4 = new byte[] { 0x42, 0x52, 0x72, 0xef };

            ICollection set1 = new SimpleObjectCollection(array1, array2);
            ICollection set2 = new SimpleObjectCollection(array3, array4);

            Constraint constraint = new CollectionEquivalentConstraint(set1);

            Assert.That(constraint.ApplyTo(set2).IsSuccess);

            set2 = new SimpleObjectCollection(array4, array3);
            Assert.That(constraint.ApplyTo(set2).IsSuccess);
        }
        public void WorksWithArrayAndHashSet()
        {
            var hash  = new HashSet <string>(new string[] { "presto", "abracadabra", "hocuspocus" });
            var array = new string[] { "abracadabra", "presto", "hocuspocus" };

            var constraint = new CollectionEquivalentConstraint(array);

            Assert.That(constraint.ApplyTo(hash).IsSuccess);
        }
        public void HonorsIgnoreCase(IEnumerable expected, IEnumerable actual)
        {
            var constraint       = new CollectionEquivalentConstraint(expected).IgnoreCase;
            var constraintResult = constraint.ApplyTo(actual);

            if (!constraintResult.IsSuccess)
            {
                MessageWriter writer = new TextMessageWriter();
                constraintResult.WriteMessageTo(writer);
                Assert.Fail(writer.ToString());
            }
        }
        public void FailureMessageWithHashSetAndArray()
        {
            var hash  = new HashSet <string>(new string[] { "presto", "abracadabra", "hocuspocus" });
            var array = new string[] { "abracadabra", "presto", "hocusfocus" };

            var constraint       = new CollectionEquivalentConstraint(hash);
            var constraintResult = constraint.ApplyTo(array);

            Assert.IsFalse(constraintResult.IsSuccess);

            TextMessageWriter writer = new TextMessageWriter();

            constraintResult.WriteMessageTo(writer);

            var expectedMessage =
                "  Expected: equivalent to < \"presto\", \"abracadabra\", \"hocuspocus\" >" + Environment.NewLine +
                "  But was:  < \"abracadabra\", \"presto\", \"hocusfocus\" >" + Environment.NewLine +
                "  Missing (1): < \"hocuspocus\" >" + Environment.NewLine +
                "  Extra (1): < \"hocusfocus\" >" + Environment.NewLine;

            Assert.That(writer.ToString(), Is.EqualTo(expectedMessage));
        }