예제 #1
0
        public void GivenRatingIsLowerThanHalfOfRatingCeiling_ShouldContainLOW()
        {
            int rating       = 1;
            int ratingCeling = 4;

            externalRatingApprovalService.Setup(mock => mock.IsApproved(rating)).Returns(true);
            moderateClass = new ModerateClass(notificationService.Object, externalRatingApprovalService.Object);
            using (ShimsContext.Create())
            {
                String result = moderateClass.CreateRatingString(rating, ratingCeling);
                Assert.AreEqual("LOW-1", result);
                externalRatingApprovalService.Verify(mock => mock.IsApproved(rating), Times.Once());
                notificationService.Verify(mock => mock.Notify(rating), Times.Once());
            }
        }
예제 #2
0
        public void GivenRatingGreaterThanRatingCeiling_ShouldFail()
        {
            //ARRANGE AND ACT
            int rating       = 2;
            int ratingCeling = 1;

            using (ShimsContext.Create())
            {
                moderateClass = new ModerateClass(notificationService.Object, externalRatingApprovalService.Object);
                //ASSERT
                Should.Throw <ArgumentException>(() => {
                    moderateClass.CreateRatingString(rating, ratingCeling);
                }).Message.ShouldBe("Cannot be over the hard ceiling");
            }
        }
예제 #3
0
        public void GivenRatingIsEqualToRatingCeilingAndExternalRatingIsApprovedFalse_ShouldContainNOTAPP()
        {
            //ARRANGE AND ACT
            int rating       = 2;
            int ratingCeling = 2;

            using (ShimsContext.Create())
            {
                moderateClass = new ModerateClass(notificationService.Object, externalRatingApprovalService.Object);
                externalRatingApprovalService.Setup(mock => mock.IsApproved(rating)).Returns(false);
                string result = moderateClass.CreateRatingString(rating, ratingCeling);
                //ASSERT
                Assert.AreEqual("NOT-APP", result);
                externalRatingApprovalService.Verify(mock => mock.IsApproved(rating), Times.Once());
            }
        }
예제 #4
0
        public void ShouldFail_WhenExternalRatingApprovalServiceIsNotApprovedAndRatingIsLowerThanRatingCeiling()
        {
            int rating       = 1;
            int ratingCeling = 2;

            //ARRANGE
            externalRatingApprovalService.Setup(mock => mock.IsApproved(rating)).Returns(false);
            moderateClass = new ModerateClass(notificationService.Object, externalRatingApprovalService.Object);
            //ACT
            using (ShimsContext.Create())
            {
                string result = moderateClass.CreateRatingString(rating, ratingCeling);
                //ASSERT
                Assert.AreEqual("NOT-APP", result);
                externalRatingApprovalService.Verify(mock => mock.IsApproved(rating), Times.Once());
            }
        }
예제 #5
0
        public void GivenRatingIsLowerThanHalfOfRatingCeilingAndLastRatingIsEqualToRating_ShouldContainLOWAndCACHED()
        {
            int rating       = 1;
            int ratingCeling = 4;

            externalRatingApprovalService.Setup(mock => mock.IsApproved(rating)).Returns(true);
            moderateClass = new ModerateClass(notificationService.Object, externalRatingApprovalService.Object);
            using (ShimsContext.Create())
            {
                PrivateObject privSub = new PrivateObject(moderateClass, new PrivateType(typeof(ModerateClass)));
                privSub.SetField("lastRating", 1);
                String result = moderateClass.CreateRatingString(rating, ratingCeling);
                Assert.AreEqual("LOW-1-CACHED", result);
                externalRatingApprovalService.Verify(mock => mock.IsApproved(rating), Times.Once());
                notificationService.Verify(mock => mock.Notify(rating), Times.Once());
            }
        }