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 int MaximumAllowedFishesThatCanCatch(FisherMan fisherMan)
        {
            if (fisherMan.Level == Level.Professional)
            {
                return(100);
            }

            if (fisherMan.Level == Level.Amateur)
            {
                return(50);
            }

            return(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);
        }
        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);
        }
        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);
        }
示例#6
0
    public override void GrabHook(Rigidbody2D hookRb)
    {
        if (dead == true)
        {
            return;
        }
        if (useTimer == true)
        {
            UpdateMethod -= Timer;
        }
        hooked = true;

        gameObject.layer = LayerMask.NameToLayer("liftedCrate");

        joint.enabled = true;

        joint.connectedBody = hookRb;

        if (hookRb.name.Equals("Legs"))
        {
            FisherMan fm = hookRb.transform.parent.GetComponent <FisherMan>();
            if (fm.hooked == false)
            {
                return;
            }
            fm.HasDude = true;
            fm.fishermenInLegs.Add(this);
            grabLegs = true;
            joint.connectedAnchor = chainConnectedAnchor;
            joint.anchor          = chainAnchor;
            manager.chainFormed   = true;
        }
        else
        {
            joint.connectedAnchor = connectedAnchor;
            joint.anchor          = anchorWhenHooked;
        }


        legs.SetActive(true);

        _rigidbody.constraints = RigidbodyConstraints2D.None;
        floating.enabled       = false;
    }
        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);
        }
示例#8
0
        public void GoToFishing_WhenAmateurFisherman_InStormyWeather_TemperatureIsBelowZero_AlwaysCallsAlarmServiceWithArgument2()
        {
            //Arrange
            var weatherForecasterStub = new Mock <IWeatherForecaster>();

            weatherForecasterStub.Setup(forecaster => forecaster.WeatherStatus).Returns(WeatherStatus.Stormy);
            weatherForecasterStub.Setup(forecaster => forecaster.Temperature).Returns(-1);

            var alarmServiceMock = new Mock <IAlarmService>();

            var fisherMan = new FisherMan(alarmServiceMock.Object, weatherForecasterStub.Object)
            {
                Level = Level.Amateur,
                Name  = "Hasan"
            };

            //Act
            fisherMan.GoToFishing();

            //Assert
            alarmServiceMock.Verify(service => service.PlayAlarm(2));
        }