示例#1
0
        public void TestGoldfish1NewTrait()
        {
            Goldfish Bill = new Goldfish();

            Bill.Shiney = true;
            Assert.True(Bill.Shiney);
        }
示例#2
0
        public void TestGoldfish2Inherited()
        {
            Goldfish Bill = new Goldfish();

            Bill.OnlyLiveInWater = true;
            Assert.True(Bill.OnlyLiveInWater);
        }
示例#3
0
        private static void Animals()
        {
            var cat     = new Cat();
            var dog     = new Dog();
            var fish    = new Goldfish();
            var animals = new List <Animal>()
            {
                cat, dog, dog, fish
            };

            Console.WriteLine(animals.ToUniform().Histogram());
            Console.WriteLine(animals.ToUniform().ShowWeights());

            Console.WriteLine(WeightedInteger.Distribution(10, 0, 0, 11, 5).Histogram());
        }
示例#4
0
        public ActionResult AddFish(string name, string type)
        {
            Fish NewFish;

            try
            {
                switch (type)
                {
                case "Goldfish":
                    NewFish = new Goldfish()
                    {
                        Name = name
                    };
                    break;

                case "Angelfish":
                    NewFish = new Angelfish()
                    {
                        Name = name
                    };
                    break;

                case "Babelfish":
                    NewFish = new Babelfish()
                    {
                        Name = name
                    };
                    break;

                default:
                    throw new Exception("Invalid Type OF Fish");
                }

                FishTank.AddFishToTank(NewFish);
            }
            catch (Exception ex)
            {
                //Log Invalid fish type
                //Return to user there has been an errror
            }
            return(View("Index", FishTank));
        }
示例#5
0
        static void Main(string[] args)
        {
            BrownBear BoBo   = new BrownBear();
            Peacock   Jane   = new Peacock();
            Goldfish  Bill   = new Goldfish();
            Salmon    Jasper = new Salmon();
            Turtle    Molly  = new Turtle();
            Snake     Kathy  = new Snake();

            Console.WriteLine("Brownbear Speaks: ");
            BoBo.Speak();

            Console.WriteLine("Peacock Sleeps: ");
            Jane.Sleep();
            Console.WriteLine("Peacock interface Play: ");
            Console.WriteLine(Jane.PlayInterface());
            Console.WriteLine("Peacock interface Potty: ");
            Console.WriteLine(Jane.PottyInterface());

            Console.WriteLine("Goldfish Moves: ");
            Bill.Move();
            Console.WriteLine("Goldfish interface Potty: ");
            Console.WriteLine(Bill.PottyInterface());

            Console.WriteLine("Salmon NumOfBabies");
            Jasper.NumOfBabies = 5;
            Console.WriteLine(Jasper.NumOfBabies);

            Console.WriteLine("Turtle HasShell: ");
            Molly.HasShell = true;
            Console.WriteLine(Molly.HasShell);
            Console.WriteLine("Turtle interface Play: ");
            Console.WriteLine(Molly.PlayInterface());

            Console.WriteLine("Snake HasSpine");
            Kathy.HasSpine = true;
            Console.WriteLine(Kathy.HasSpine);

            Console.ReadLine(); //to stop it from auto exit
        }
示例#6
0
        public void TestInterfaceGoldfish2()
        {
            Goldfish Peppa = new Goldfish();

            Assert.NotEqual("blah", Peppa.PottyInterface());
        }
示例#7
0
        public void TestInterfaceGoldfish1()
        {
            Goldfish Peppa = new Goldfish();

            Assert.Equal("Hello from PottyInterface IPotty Goldfish", Peppa.PottyInterface());
        }
		/// <summary>
		/// Default constructor.
		/// </summary>
		/// <param name="api">The api object</param>
		public FeedController(Goldfish.IApi api) {
			Api = api;
		}
		/// <summary>
		/// Default constructor.
		/// </summary>
		/// <param name="api">The api object</param>
		public BlogController(Goldfish.IApi api) {
			Api = api;
		}
示例#10
0
		public async Task<ActionResult> AddComment(Goldfish.Models.Comment model) {
			if (ModelState.IsValid) {
				model.IP = HttpContext.Request.UserHostAddress;
				model.SessionID = Session.SessionID;
				model.IsApproved = true;
				if (User.Identity.IsAuthenticated)
					model.UserId = User.Identity.Name;

				if (User.Identity.IsAuthenticated && Config.Blog.Comments.ModerateAuthorized)
					model.IsApproved = false;
				else if (!User.Identity.IsAuthenticated && Config.Blog.Comments.ModerateAnonymous)
					model.IsApproved = false;

				Api.Comments.Add(model);
				Api.SaveChanges();

				var post = await Api.Posts.GetByIdAsync(model.PostId);

				return RedirectToAction("Post", new { slug = post.Slug });
			}
			return null;
		}