コード例 #1
0
        public void MaximumAllowedFishesThatCanCatch_WhenFishermanIsNull_ThrowsArgumentNullException()
        {
            FisherMan fisherMan       = null;
            var       fishingCapacity = new FishingCapacity();

            // Require an ArgumentNullException - derived types fail!
            Assert.Throws <ArgumentNullException>(() => fishingCapacity.MaximumAllowedFishesThatCanCatch(fisherMan));

            // Allow both ArgumentNullException and any derived type
            Assert.Catch <ArgumentNullException>(() => fishingCapacity.MaximumAllowedFishesThatCanCatch(fisherMan));

            // Allow any kind of exception
            Assert.Catch(() => fishingCapacity.MaximumAllowedFishesThatCanCatch(fisherMan));
        }
コード例 #2
0
        public void MaximumAllowedFishesThatCanCatch_FishermanIsAmateur_Return_50()
        {
            //Arrange
            var fisherMan = new FisherMan()
            {
                Level = Level.Amateur, Name = "Hamid"
            };
            var fishingCapacity = new FishingCapacity();

            //Act
            var result = fishingCapacity.MaximumAllowedFishesThatCanCatch(fisherMan);

            //Assert
            Assert.AreEqual(50, result);
        }
コード例 #3
0
        public void MaximumAllowedFishesThatCanCatch_FishermanIsProfessional_Return_100()
        {
            //Arrange
            var fisherMan = new FisherMan()
            {
                Level = Level.Professional, Name = "Hamid"
            };
            var fishingCapacity = new FishingCapacity();

            //Act
            var result = fishingCapacity.MaximumAllowedFishesThatCanCatch(fisherMan);

            //Assert
            Assert.AreEqual(100, result);
        }
コード例 #4
0
        public void MaximumAllowedFishesThatCanCatch_FishermanIsInBlacklist_Return_0()
        {
            //Arrange
            var fisherMan = new FisherMan()
            {
                Level = Level.Professional, Name = "Hasan", Banned = true
            };
            var fishingCapacity = new FishingCapacity();

            fishingCapacity.BlakListRepository = new StubBlackListRepository();

            //Act
            var result = fishingCapacity.MaximumAllowedFishesThatCanCatch(fisherMan);

            //Assert
            Assert.AreEqual(0, result);
        }
コード例 #5
0
        public void MaximumAllowedFishesThatCanCatch_FishermanIsProfessional_Return_100()
        {
            //Arrange
            var fisherMan = new FisherMan()
            {
                Level = Level.Professional, Name = "Hamid"
            };
            var fishingCapacity         = new FishingCapacity();
            var blackListRepositoryStub = new Mock <IBlackListRepository>();

            blackListRepositoryStub.Setup(x => x.GetAllNames()).Returns(() => new string[] { "Ahmad" });
            fishingCapacity.BlakListRepository = blackListRepositoryStub.Object;

            //Act
            var result = fishingCapacity.MaximumAllowedFishesThatCanCatch(fisherMan);

            //Assert
            Assert.AreEqual(100, result);
        }