public void ShouldPassOnTheSameLogic()
                {
                    // Arrange
                    var collection = GetRandomCollection <string>(4, 7)
                                     .Distinct()
                                     .ToArray();
                    var seek = collection.Randomize().First();

                    // Pre-Assert

                    // Act
                    Assert.That(() =>
                                AssertionHelper.Expect(
                                    collection,
                                    AssertionHelper.Exactly(1).EqualTo(seek)
                                    ),
                                Throws.Nothing
                                );

                    Assert.That(() =>
                                Expectations.Expect(
                                    collection,
                                    Expectations.Exactly(1).EqualTo(seek)
                                    ),
                                Throws.Nothing
                                );

                    // Assert
                }
Beispiel #2
0
        public static void ExpectOnlyHasThisClaim(this IdentityUser user, Claim expectedClaim)
        {
            AssertionHelper.Expect(user.Claims.Count, Is.EqualTo(1));
            var actualClaim = user.Claims.Single();

            AssertionHelper.Expect(actualClaim.Type, Is.EqualTo(expectedClaim.Type));
            AssertionHelper.Expect(actualClaim.Value, Is.EqualTo(expectedClaim.Value));
        }
                public void ShouldFailSimilarly()
                {
                    // Arrange
                    var collection = new[] { 1, 2, 3 };

                    // Pre-assert
                    // Act
                    Assert.That(
                        () => AssertionHelper.Expect(collection, Has.Member(4)),
                        Throws.Exception.InstanceOf <AssertionException>());
                    Assert.That(
                        () => Expectations.Expect(collection, Has.Member(4)),
                        Throws.Exception.InstanceOf <AssertionException>());
                    // Assert
                }
                public void ShouldPassOnTheSameLogic()
                {
                    // Arrange
                    var collection = new[] { 1, 2, 3 };

                    // Pre-assert
                    // Act
                    Assert.That(
                        () => AssertionHelper.Expect(collection, Has.Member(1)),
                        Throws.Nothing
                        );
                    Assert.That(
                        () => Expectations.Expect(collection, Has.Member(1)),
                        Throws.Nothing
                        );
                    // Assert
                }
                public void ShouldFailSimilarly()
                {
                    // Arrange
                    var min   = GetRandomInt(1, 5);
                    var max   = GetRandomInt(10, 15);
                    var check = GetRandomInt(16, 21);

                    // Pre-Assert

                    // Act
                    var ex1 = Assert.Throws <AssertionException>(() =>
                                                                 AssertionHelper.Expect(check, (new AssertionHelper()).InRange(min, max)));
                    var ex2 = Assert.Throws <AssertionException>(() =>
                                                                 Expectations.Expect(check, Expectations.InRange(min, max)));

                    // Assert
                    Assert.That(ex1.Message, Is.EqualTo(ex1.Message));
                    Assert.That(ex1.Message, Is.EqualTo(ex2.Message));
                }
                public void ShouldPassOnTheSameLogic()
                {
                    // Arrange
                    var min   = GetRandomInt(0, 5);
                    var max   = GetRandomInt(10, 15);
                    var check = GetRandomInt(6, 9);

                    // Pre-Assert

                    // Act
                    Assert.That(() =>
                                AssertionHelper.Expect(check, (new AssertionHelper()).InRange(min, max)),
                                Throws.Nothing);
                    Assert.That(() =>
                                Expectations.Expect(check, Expectations.InRange(min, max)),
                                Throws.Nothing);


                    // Assert
                }
                public void ShouldFailSimilarly()
                {
                    // Arrange
                    var collection = GetRandomCollection <string>(4, 7)
                                     .Distinct()
                                     .ToArray();
                    var seek = GetAnother <string>(collection);

                    // Pre-Assert
                    var ex1 = Assert.Throws <AssertionException>(
                        () => AssertionHelper.Expect(collection, AssertionHelper.Exactly(1).EqualTo(seek))
                        );
                    var ex2 = Assert.Throws <AssertionException>(
                        () => Expectations.Expect(collection, Expectations.Exactly(1).EqualTo(seek))
                        );

                    // Act

                    // Assert
                    Assert.That(ex1.Message, Is.EqualTo(ex1.Message));
                    Assert.That(ex1.Message, Is.EqualTo(ex2.Message));
                }
 public static void NoMatch(Regex regex, string input, string message)
 {
     AssertionHelper.Expect(!regex.IsMatch(input), "The string matches the given regex"
                            + (message.Length == 0 ? "" : ": " + message));
 }