Esempio n. 1
0
        public void StoreYears()
        {
            //'sut' stands for: 'System Under Test'
            var sut = new LoanTerm(1);

            Assert.That(sut.Years, Is.EqualTo(1));
        }
Esempio n. 2
0
        public void RespectValueEqualityReferenceType()
        {
            var a = new LoanTerm(1);
            var b = new LoanTerm(1);

            Assert.That(a, Is.EqualTo(b));
        }
        public void ReturnTermInMonths()
        {
            var sut = new LoanTerm(1);

            //Assert that LoanTerm.ToMonths() returns 12.
            throw new NotImplementedException();
        }
Esempio n. 4
0
        public void StoreYears()
        {
            var sut = new LoanTerm(1);

            Assert.That(sut.Years, Is.EqualTo(1));
            //Assert.That(sut.Years, new EqualConstraint(1));
        }
        [Ignore("Message goes here!!!")] // prevent test from running
        public void ReturnTermInMonths()
        {
            // sut stands for system under test
            var sut = new LoanTerm(1);

            Assert.That(sut.ToMonths(), Is.EqualTo(12), "Custom Error Message");
        }
Esempio n. 6
0
        public void RespectValueEquality()
        {
            var a = new LoanTerm(1);
            var b = new LoanTerm(1);

            Assert.That(a, Is.EqualTo(b));    //loanTerms overrides Equal method in ValuObject class hence EqualTo still works for reference type too
        }
Esempio n. 7
0
        public void ReferenceEqualityExample()
        {
            var a = new LoanTerm(1);
            var b = a;
            var c = new LoanTerm(1);

            /**
             * We want to assert that the variables a and b points to the same object
             * in memory.
             */
            Assert.That(a, Is.SameAs(b));
            Assert.That(a, Is.Not.SameAs(c));

            /**
             * SameAs is only concerned with references and not values
             */
            var x = new List <string> {
                "a", "b"
            };
            var y = x;
            var z = new List <string> {
                "a", "b"
            };

            Assert.That(x, Is.SameAs(y));
            Assert.That(z, Is.Not.SameAs(x));
        }
        public void RespectValueInequality()
        {
            var a = new LoanTerm(1);
            var b = new LoanTerm(2);

            Assert.That(a, Is.Not.EqualTo(b));
        }
Esempio n. 9
0
        public void RespectValueEqality1() // Its passing bcz of override Equals in ValueObject
        {
            var a = new LoanTerm(1);
            var b = new LoanTerm(1);

            Assert.That(a, Is.EqualTo(b));
        }
        public void ReturnTermInMonths()
        {
            var longTerm = new LoanTerm(1);

            //Assert.That(sut.ToMonths(), Is.EqualTo(12));
            longTerm.ToMonths().Should().Be(12, "there are 12 months in a year");
        }
Esempio n. 11
0
        public void ReferenceEqualityExample()
        {
            var a = new LoanTerm(1);
            var b = a;
            var c = new LoanTerm(1);

            // The 'SameAs' method only compares references, not values.
            // Assert that the variables 'a' & 'b' or 'a' & 'c' point to the same object in memory.

            // This one will pass
            Assert.That(a, Is.SameAs(b));
            // This one will fail
            Assert.That(a, Is.SameAs(c));
            // This one will pass
            Assert.That(a, Is.Not.SameAs(c));

            // 'List' of '<type>' is a reference type
            var x = new List <string> {
                "a", "b"
            };
            var y = x;
            var z = new List <string> {
                "a", "b"
            };

            // This one will pass
            Assert.That(y, Is.SameAs(x));
            // This one will fail
            Assert.That(z, Is.SameAs(x));
            // This one will pass
            Assert.That(z, Is.Not.SameAs(x));
        }
        public void StoreYears()
        {
            var sut = new LoanTerm(1);

            // Similar ways of asserting if the years from the loan term
            Assert.That(sut.Years, Is.EqualTo(1));
            Assert.That(sut.Years, new EqualConstraint(1));
        }
        public void RespectValueEquality()
        {
            // Value or memory reference type (e.g. classes) comparison
            var a = new LoanTerm(1);
            var b = new LoanTerm(1);

            Assert.That(a, Is.EqualTo(b));
        }
Esempio n. 14
0
        public void ReferenceEqualityExample()
        {
            var a = new LoanTerm(1);
            var b = a;//new LoanTerm(1);
            var c = new LoanTerm(1);

            Assert.That(a, Is.SameAs(b));
            Assert.That(a, Is.Not.SameAs(c));
        }
Esempio n. 15
0
        public void ReturnTermInMonths()
        {
            // sut means 'SYSTEM UNDER TEST'
            var sut = new LoanTerm(1);

            string customErrorMsg = "[ReturnTermInMonths] Months should be 12 * numbers of years";

            Assert.That(sut.ToMonths(), Is.EqualTo(12), customErrorMsg);
        }
Esempio n. 16
0
        public void StoreYears()
        {
            var sut = new LoanTerm(1);

            /**
             * We want to check if the Years property has been set properly.
             * We are now skipping the "Act" logical phase.
             */
            Assert.That(sut.Years, Is.EqualTo(1));
        }
Esempio n. 17
0
 public void ReferenceEqualityExample()
 {
     var a = new LoanTerm(1);
     var b = a;
     var c = new LoanTerm(2);
     //Same checks references, not values.
     Assert.That(a, Is.SameAs(b)); //Passes
     //Assert.That(a, Is.SameAs(c)); //Fails
     Assert.That(a, Is.Not.SameAs(c));
 }
Esempio n. 18
0
        public void RespectValueInequality()
        {
            //Arrange
            var a = new LoanTerm(1);
            var b = new LoanTerm(2);
            //Act

            //Assert
            Assert.That(a, Is.Not.EqualTo(b));
        }
Esempio n. 19
0
        //[Ignore("Need to complete update work.")]
        public void ReturnTermInMonths()
        {
            //Constraint method of assertion is the new feature
            //Assert.That(*test result, *constraint instance);
            //vs. Classic method of assertion which would look like this:
            //Assert.AreEqual(1, sut.Years);
            var sut = new LoanTerm(1);

            Assert.That(sut.ToMonths(), Is.EqualTo(12), "Months should be 12* number of years.");
        }
Esempio n. 20
0
        public void StoreYears()
        {
            //Arrange
            var sut = new LoanTerm(1);


            //Assert
            Assert.That(sut.Years, Is.EqualTo(1));
            sut.Years.Should().Be(1);
        }
Esempio n. 21
0
        public void StoreYears()
        {
            //Arrage
            var sut = new LoanTerm(1);

            //Act
            var result = sut.Years;

            //Assert
            Assert.That(result, Is.EqualTo(1));
        }
Esempio n. 22
0
        public void ReturnTermInMonths()
        {
            //Arrange : Initialise test data
            var sut = new LoanTerm(1);

            //Act :  Call methods
            var numberofmonths = sut.ToMonths();

            //Assert
            Assert.That(numberofmonths, Is.EqualTo(12), "Months should be 12* number of Years");
        }
        public void RespectValueEquality()
        {
            //var a = 1;
            //var b = 1;

            var a = new LoanTerm(1);
            var b = new LoanTerm(1);

            // EqualTo 调用的是 Equal()方法
            Assert.That(a, Is.EqualTo(b));
        }
Esempio n. 24
0
        public void ReturnTermInMonths()
        {
            //Arrange
            var sut = new LoanTerm(1);

            //Act
            var result = sut.ToMonths();

            //Assert
            Assert.That(result, Is.EqualTo(12), "Months should be 12 * number of years");
        }
Esempio n. 25
0
        public void StoreYears()
        {
            // Arrange
            var sut = new LoanTerm(1);

            // Act
            var years = sut.Years;

            // Assert
            Assert.That(years, Is.EqualTo(1));
        }
Esempio n. 26
0
        public void ReturnTermInMonths()
        {
            // Arrange
            var sut = new LoanTerm(1);

            // Act
            var monthsYear = sut.ToMonths();

            // Assert
            Assert.That(monthsYear, Is.EqualTo(12));
        }
Esempio n. 27
0
        public void RespectValueEqualityRef()
        {
            var a = new LoanTerm(1);
            var b = new LoanTerm(1);

            // In C#, classes are reference types, not value types
            // Two reference types, even if they have the same values, won't be considered equal by the 'Is.EqualTo()' method.
            // Because in 'ValueObject.cs', the Equals method has been overridden with custom logic, it makes use of the 'GetAtomicValues()' method
            // In 'LoanTerm.cs' the 'GetAtomicValues()' method has been overridden and it returns the 'Years'
            // So in this assert, if both 'LoanTerm()' have the same values for 'Years', they will be considered equal.
            Assert.That(a, Is.EqualTo(b));
        }
Esempio n. 28
0
        public void ReferenceEqualityExample()
        {
            var a = new LoanTerm(1);
            var b = a;

            Assert.That(a, Is.SameAs(b));

            var x = new List <string> {
                "a", "b"
            };
            var y = x;

            Assert.That(x, Is.SameAs(y));
        }
Esempio n. 29
0
        public void ReturnTermInMonths()
        {
            //Arrange
            var sut = new LoanTerm(1);


            //Act
            //Assert.That(sut.ToMonths(),Is.EqualTo(12));
            var numberOfMonth = sut.ToMonths();

            //Assert
            // numberOfMonth.Should().Be(12);
            Assert.That(numberOfMonth, Is.EqualTo(12), "months should 12* number of years");
        }
Esempio n. 30
0
        public void ReturnTermInMonths()
        {
            //sut = system under test
            //hiding default cnstrctr of
            //LoanTerm causes red squiggly
            //see line 12 of LoanTerm.cs
            LoanTerm sut = new LoanTerm(2); //Arrange

            //constraint model of assertions
            //Assert.That(test result, constraint instance)
            //You may also add custom Throw Error Messages
            Assert.That(sut.ToMonths(), Is.EqualTo(12), "Months should be 12 * Number of Years!");  //Assert

            //Arrange: set up test object(s), initialize test data, thing
            //we want to test
        }