Пример #1
0
        private void CalculateMemberShipCostTest(int source, double expected, string message)
        {
            var manager = new MemberManager(); //here we depends on the implementation of MemberManager. Error may occure inside MemberManager,but
            //not in LibraryCore
            var libraryCore = new LibraryCore(manager);
            var actual      = libraryCore.CalculateMemberShipCost(source);

            Assert.AreEqual(actual, expected, message);
        }
Пример #2
0
        public void CalculateMemberShipCost_Should_Return_Right_Results()
        {
            Mock <IMemberManager> myMock = new Mock <IMemberManager>();

            myMock.Setup(x => x.GetMember(It.IsAny <int>())).Returns(new Member {
                MemberID = 1, MaximumBookCanBorrow = 10
            });

            var libraryCore = new LibraryCore(myMock.Object);

            var actual   = libraryCore.CalculateMemberShipCost(1);
            var expected = 105;

            Assert.AreEqual(actual, expected);
        }
Пример #3
0
        public void CalculateMemberShipCostTest()
        {
            _mock   = new Mock <IMemberManager>();
            _target = new LibraryCore(_mock.Object);
            Member member = new Member()
            {
                MemberID             = 1,
                FirstName            = "Erandika",
                SecondName           = "Sandaruwan",
                Age                  = 25,
                MaximumBookCanBorrow = 4,
            };

            _mock.Setup(x => x.GetMember(It.IsAny <int>())).Returns(member);

            int    memberID = 1;  // TODO: Initialize to an appropriate value
            double expected = 12; // TODO: Initialize to an appropriate value
            double actual;

            actual = _target.CalculateMemberShipCost(memberID);
            Assert.AreEqual(expected, actual);
        }
Пример #4
0
        public void CalculateMemberShipCostTest()
        {
            _mock   = new Mock <IMemberManager>();
            _target = new LibraryCore(_mock.Object);

            //Arrange
            Member member = new Member()
            {
                MemberID             = 1,
                FirstName            = "Tang",
                SecondName           = "Tuan",
                Age                  = 27,
                MaximumBookCanBorrow = 4
            };

            //Act
            _mock.Setup(x => x.GetMember(It.IsAny <int>())).Returns(member);

            //Assert
            double expected = 12;
            double actual   = _target.CalculateMemberShipCost(member.MemberID);;

            Assert.AreEqual(expected, actual);
        }