예제 #1
0
 public void Test_AddOneSamuraiTwice()
 {
     EfMethods.AddOneSamurai("Zelda");
     EfMethods.AddOneSamurai("Link");
     string[] result = EfMethods.GetAllSamuraiNames();
     CollectionAssert.AreEqual(new[] { "Zelda", "Link" }, result);
 }
예제 #2
0
        public void Test_AddSecretIdentity()
        {
            int samuraiId = EfMethods.AddOneSamurai("Papa Smurf");

            EfMethods.UpdateSamuraiSetSecretIdentity(samuraiId, "Tomas");
            // NOTE to students: The following static method, EfTddMethods, is NOT the same as the one above!
            SecretIdentity result = EfTddMethods.ReadSecretIdentityOfSpecificSamurai(samuraiId);

            Assert.AreEqual("Papa Smurf", result.Samurai.Name);
            Assert.AreEqual("Tomas", result.RealName);
        }
예제 #3
0
        public void Test_AddOneSamuraiWithSecretIdentity()
        {
            var samurai = new Samurai()
            {
                Name      = "Ganondorf Dragmire",
                HairStyle = HairStyle.Western,
            };
            int samuraiId = EfMethods.AddOneSamurai(samurai);

            EfMethods.UpdateSamuraiSetSecretIdentity(samuraiId, "Ganon");
            Samurai actualSamurai = EfMethods.GetSamurai(samuraiId);

            Assert.AreEqual("Ganondorf Dragmire", actualSamurai.Name);
            Assert.AreEqual(HairStyle.Western, actualSamurai.HairStyle);
            Assert.AreEqual("Ganon", actualSamurai.SecretIdentity.RealName);
        }
예제 #4
0
        public void Test_SamuraiBattlesCount()
        {
            var samurai = new Samurai()
            {
                Name           = "Zelda",
                Hairstyle      = Hairstyle.Chonmage,
                SamuraiBattles = new List <Samurai_Battle>()
                {
                    new Samurai_Battle()
                    {
                        Battle = new Battle()
                        {
                            Name        = "Fight with Bokoblins",
                            Description = "3 bokoblins defeated",
                            IsBrutal    = false
                        }
                    },
                    new Samurai_Battle()
                    {
                        Battle = new Battle()
                        {
                            Name        = "Fight with Silver Moblins",
                            Description = "Difficult..",
                            IsBrutal    = true
                        }
                    },
                    new Samurai_Battle()
                    {
                        Battle = new Battle()
                        {
                            Name        = "Fight with Ganon",
                            Description = "To be continued..",
                            IsBrutal    = true
                        }
                    }
                }
            };
            int  samuraiId          = EfMethods.AddOneSamurai(samurai);
            int  countBattles       = EfMethods.CountBattlesForOneSamurai(samuraiId);
            int  countBrutalBattles = EfMethods.CountBrutalBattlesForOneSamurai(samuraiId);
            bool IsBrutalOver50     = EfMethods.BrutalBattlesOver50Percent(countBattles, countBrutalBattles);

            Assert.AreEqual(3, countBattles);
            Assert.AreEqual(2, countBrutalBattles);
            Assert.IsTrue(IsBrutalOver50);
        }
예제 #5
0
        public void Test_AddThreeSamuraisListNamesOfThoseWithWesternHairstyles()
        {
            EfMethods.AddOneSamurai(new Samurai()
            {
                Name = "Williams Adams", HairStyle = HairStyle.Western
            });
            EfMethods.AddOneSamurai(new Samurai()
            {
                Name = "Tokugawa Leyasu", HairStyle = HairStyle.Oicho
            });
            EfMethods.AddOneSamurai(new Samurai()
            {
                Name = "Jan Joosten", HairStyle = HairStyle.Western
            });
            // NOTE to students: The following static method, EfTddMethods, is NOT the same as the one above!
            List <string> result = EfTddMethods.ReadAlphabeticallyAllSamuraiNamesWithSpecificHairstyle(HairStyle.Western);

            CollectionAssert.AreEqual(new[] { "Jan Joosten", "Williams Adams" }, result.ToArray());
        }
예제 #6
0
        public void Test_AddThreeSamuraisWithQuotesReadCheesyQuotes()
        {
            EfMethods.AddOneSamurai(new Samurai()
            {
                Name = "Himura Kenshin", QuotesCollection = new List <Quote>()
                {
                    new Quote()
                    {
                        Text = "You can always die. It's living that takes real courage.", QuoteStyle = QuoteStyle.Awesome
                    }
                }
            });
            EfMethods.AddOneSamurai(new Samurai()
            {
                Name = "Watsuki Nobuhiro", QuotesCollection = new List <Quote>()
                {
                    new Quote()
                    {
                        Text = "New eras don't come about because of swords, they're created by the people who wield them.", QuoteStyle = QuoteStyle.Cheesy
                    }
                }
            });
            EfMethods.AddOneSamurai(new Samurai()
            {
                Name = "Laini Taylor", QuotesCollection = new List <Quote>()
                {
                    new Quote()
                    {
                        Text = "Be a Samurai. Because you just never know what's behind the freaking sky.", QuoteStyle = QuoteStyle.Lame
                    }
                }
            });
            // NOTE to students: The following static method, EfTddMethods, is NOT the same as the one above!
            List <Quote> result = EfTddMethods.ReadAllQuotesWithSpecificQuoteStyle(QuoteStyle.Cheesy);

            Assert.AreEqual("New eras don't come about because of swords, they're created by the people who wield them.", result[0].Text);
            Assert.AreEqual("Watsuki Nobuhiro", result[0].Samurai.Name);
        }