Example #1
0
        public void TotalIsCorrect(int expected)
        {
            var     sut    = new BasketTotal(expected);
            decimal actual = sut;

            Assert.Equal(expected, actual);
        }
Example #2
0
        public void InitialTotalIsCorrect()
        {
            var     sut    = new BasketTotal(0);
            decimal actual = sut;

            Assert.Equal(0, actual);
        }
Example #3
0
        public void SutCorrectlyConvertsToDecimal(
            double d)
        {
            var expected = (decimal)d;
            var sut      = new BasketTotal(expected);

            decimal actual = sut;

            Assert.Equal(expected, actual);
        }
Example #4
0
        public void EqualsAnyOtherObjectReturnsCorrectResult(
            object other,
            bool expected)
        {
            var dummy = 24.8m;
            var sut   = new BasketTotal(dummy);

            var actual = sut.Equals(other);

            Assert.Equal(expected, actual);
        }
Example #5
0
        public void GetHashCodeReturnsCorrectResult(
            double total)
        {
            var d   = (decimal)total;
            var sut = new BasketTotal(d);

            var actual = sut.GetHashCode();

            var expected = d.GetHashCode();

            Assert.Equal(expected, actual);
        }
Example #6
0
        public void EqualsOtherTotalReturnsCorrectResult(
            int totalAmount,
            int otherAmount,
            bool expected)
        {
            var sut   = new BasketTotal(totalAmount);
            var other = new BasketTotal(otherAmount);

            var actual = sut.BothEquals(other);

            Assert.True(actual.All(expected.Equals));
        }
Example #7
0
        public void AcceptReturnsCorrectResponse()
        {
            var r = new MockRepository(MockBehavior.Default)
            {
                DefaultValue = DefaultValue.Mock
            };
            var expected = r.Create <IBasketVisitor>().Object;
            var sut      = new BasketTotal(0);

            var visitorStub = r.Create <IBasketVisitor>();

            visitorStub.Setup(v => v.Visit(sut)).Returns(expected);
            IBasketVisitor actual = sut.Accept(visitorStub.Object);

            Assert.Same(expected, actual);
        }
Example #8
0
 public IBasketVisitor Visit(BasketTotal basketTotal)
 {
     return(this);
 }
Example #9
0
        public void SutIsBasketElement()
        {
            var sut = new BasketTotal(0);

            Assert.IsAssignableFrom <IBasketElement>(sut);
        }
Example #10
0
        public void SutIsEquatable()
        {
            var sut = new BasketTotal(0);

            Assert.IsAssignableFrom <IEquatable <BasketTotal> >(sut);
        }