public void AssertContains_NotContained_ExceptionShowsCurrentValueAndValuesInDomain()
        {
            var twoThreeFour = DomainOf.Values(2, 3, 4);

            Assert.That(() => twoThreeFour.AssertContains(5),
                        Throws.InstanceOf <InvalidDomainException <int> >()
                        .With.Message.Contain("5").And
                        .Message.Contain("[2, 3, 4]"));
        }
        public void Explore()
        {
            var twoThreeFour = new DomainOfValues <int>(2, 3, 4);

            twoThreeFour = new DomainOfValues <int>(twoThreeFour);
            DomainOfValues <string> aToc = DomainOf.Values("a", "b", "c");

            Assert.That(twoThreeFour.CheckContains(2), Is.True);
            Assert.That(aToc.CheckContains("d"), Is.False);

            Assert.That(aToc.CheckContains("C"), Is.False);
            Assert.That(aToc.CheckContains("C", StringComparer.OrdinalIgnoreCase), Is.True);

            Assert.That(() => twoThreeFour.CheckContains(2), Throws.Nothing);
            Assert.That(() => aToc.AssertContains("d"), Throws.InstanceOf <InvalidDomainException <string> >());

            Assert.That(() => aToc.AssertContains("C", StringComparer.OrdinalIgnoreCase), Throws.Nothing);
        }
Exemple #3
0
 public static bool CheckAgainst <TDomain>(this TDomain actualValue, params TDomain[] expectedDomainValues)
 {
     return(DomainOf.Values <TDomain>(expectedDomainValues).CheckContains(actualValue));
 }
Exemple #4
0
 public static void AssertAgainst <TDomain>(this TDomain actualValue, IEnumerable <TDomain> expectedDomainValues)
 {
     DomainOf.Values <TDomain>(expectedDomainValues).AssertContains(actualValue);
 }
        public void TypeInferenceHelper_EmptyEnumerable_BuildsEmptyWrapper()
        {
            DomainOfValues <int> twoThreeFour = DomainOf.Values(new int[0]);

            Assert.That(twoThreeFour, Is.Empty);
        }
        public void TypeInferenceHelper_Enumerable_BuildsEnumerableWrapper()
        {
            DomainOfValues <int> twoThreeFour = DomainOf.Values(new[] { 2, 3, 4 });

            Assert.That(twoThreeFour, Is.EqualTo(new[] { 2, 3, 4 }));
        }
        public void TypeInferenceHelper_EmptyParams_BuildsEmptyWrapper()
        {
            DomainOfValues <int> twoThreeFour = DomainOf.Values <int>();

            Assert.That(twoThreeFour, Is.Empty);
        }
        public void CheckContains_ContainedValueType_True()
        {
            var twoThreeFour = DomainOf.Values(2, 3, 4);

            Assert.That(twoThreeFour.CheckContains(2), Is.True);
        }
        public void AssertContains_NotContainedValueType_Exception()
        {
            var twoThreeFour = DomainOf.Values(2, 3, 4);

            Assert.That(() => twoThreeFour.AssertContains(5), Throws.InstanceOf <InvalidDomainException <int> >());
        }
        public void AssertContains_ContainedReferenceType_True()
        {
            var twoThreeFour = DomainOf.Values("2", "3", "4");

            Assert.That(() => twoThreeFour.AssertContains("2"), Throws.Nothing);
        }
        public void AssertContains_ContainedValueType_NoException()
        {
            var twoThreeFour = DomainOf.Values(2, 3, 4);

            Assert.That(() => twoThreeFour.AssertContains(2), Throws.Nothing);
        }
        public void CheckContains_NotContainedReferenceType_False()
        {
            var twoThreeFour = DomainOf.Values("2", "3", "4");

            Assert.That(twoThreeFour.CheckContains("5"), Is.False);
        }
        public void CheckContains_NotContainedValueType_False()
        {
            var twoThreeFour = DomainOf.Values(2, 3, 4);

            Assert.That(twoThreeFour.CheckContains(5), Is.False);
        }
        public void CheckContains_ContainedReferenceType_True()
        {
            var twoThreeFour = DomainOf.Values("2", "3", "4");

            Assert.That(twoThreeFour.CheckContains("2"), Is.True);
        }
Exemple #15
0
 public static bool CheckAgainst <TDomain>(this TDomain actualValue, IEnumerable <TDomain> expectedDomainValues)
 {
     return(DomainOf.Values <TDomain>(expectedDomainValues).CheckContains(actualValue));
 }
Exemple #16
0
 public static void AssertAgainst <TDomain>(this TDomain actualValue, params TDomain[] expectedDomainValues)
 {
     DomainOf.Values <TDomain>(expectedDomainValues).AssertContains(actualValue);
 }
        public void AssertContains_NotContainedReferenceType_False()
        {
            var twoThreeFour = DomainOf.Values("2", "3", "4");

            Assert.That(() => twoThreeFour.AssertContains("5"), Throws.InstanceOf <InvalidDomainException <string> >());
        }