Exemplo n.º 1
0
        public void AbsoluteDifferenceTest()
        {
            int v1    = 123;
            int v2    = 456;
            var test1 = CreateInstance(123, "123");
            var test2 = CreateInstance(456, "456");

            Assert.AreEqual <int>(Enumeration.AbsoluteDifference(test1, test2), Math.Abs(v1 - v2));
        }
Exemplo n.º 2
0
        public void AbsoluteDifferenceShouldReturnCorrectDifference()
        {
            int zero = Enumeration.AbsoluteDifference(ExampleEnumeration.A, ExampleEnumeration.A);
            int one  = Enumeration.AbsoluteDifference(ExampleEnumeration.B, ExampleEnumeration.A);
            int two  = Enumeration.AbsoluteDifference(ExampleEnumeration.A, ExampleEnumeration.C);

            Assert.Equal(0, zero);
            Assert.Equal(1, one);
            Assert.Equal(2, two);
        }
Exemplo n.º 3
0
        public void ParseValueTest()
        {
            var predefinedType = CardType.Visa;

            var mapType = Enumeration.FromValue <CardType>(2);

            Assert.IsType <CardType>(mapType);

            Assert.Equal(predefinedType, mapType);

            var difference = Enumeration.AbsoluteDifference(predefinedType, mapType);

            Assert.Equal(0, difference);
        }
Exemplo n.º 4
0
        public void ParseNameTest()
        {
            var predefinedType = CardType.Visa;

            var mapType = Enumeration.FromDisplayName <CardType>(nameof(CardType.Visa));

            Assert.IsType <CardType>(mapType);

            Assert.Equal(predefinedType, mapType);

            var difference = Enumeration.AbsoluteDifference(predefinedType, mapType);

            Assert.Equal(0, difference);
        }
Exemplo n.º 5
0
 public void Should_correctly_determine_absolute_difference()
 {
     Assert.That(Enumeration.AbsoluteDifference(PersistenceMode.Archive, PersistenceMode.Live), Is.EqualTo(1));
 }
Exemplo n.º 6
0
 public int DetermineAbsoluteDifference(Enumeration firstValue, Enumeration secondValue)
 {
     return(Enumeration.AbsoluteDifference(firstValue, secondValue));
 }
Exemplo n.º 7
0
 public void Enumeration_AbsoluteDifference()
 {
     Assert.Equal(1, Enumeration.AbsoluteDifference(TestEnumeration.Created, TestEnumeration.Approved));
 }
Exemplo n.º 8
0
 public void AbsoluteDifferenceReturnsAbsoluteDiffenceOfEnumerationValues()
 {
     Enumeration.AbsoluteDifference(PaymentType.CreditCard, PaymentType.DebitCard).ShouldBe(1);
     Enumeration.AbsoluteDifference(PaymentType.DebitCard, PaymentType.CreditCard).ShouldBe(1);
     Enumeration.AbsoluteDifference(PaymentType.DebitCard, PaymentType.DebitCard).ShouldBe(0);
 }