예제 #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);
        }
예제 #7
0
        public void Test_BattlesAndSamurais()
        {
            var samurai = new Samurai()
            {
                Name           = "Leonardo",
                Hairstyle      = Hairstyle.Oicho,
                SecretIdentity = new SecretIdentity()
                {
                    RealName = "Svangunn"
                },
                Quotes = new List <Quote>()
                {
                    new Quote()
                    {
                        QuoteStyle = QuoteStyle.Cheesy,
                        Text       = "You can always die. It's living that takes real courage."
                    }
                },
                SamuraiBattles = new List <Samurai_Battle>()
                {
                    new Samurai_Battle()
                    {
                        Battle = new Battle()
                        {
                            Name        = "Battle of Academy",
                            Description = "A fierce battle of wits!",
                            StartDate   = new DateTime(2019, 06, 11), EndDate = new DateTime(2019, 09, 13), IsBrutal = true,
                            BattleLog   = new BattleLog()
                            {
                                Name         = "The Hackathon",
                                BattleEvents = new List <BattleEvent>()
                                {
                                    new BattleEvent()
                                    {
                                        Order       = 1,
                                        Description = "What started as a friendly competition emerged into a deadly battle, where laptops were used as blunt weapons.",
                                        Summary     = "The fight ended in a lot of tears and broken laptops. There were no victors..."
                                    }
                                }
                            }
                        }
                    },
                    new Samurai_Battle()
                    {
                        Battle = new Battle()
                        {
                            Name        = "The revenge of the N.E.R.D.S",
                            Description = "Notable Enigmatic Revolting Dapping Students",
                            StartDate   = new DateTime(2019, 09, 15), EndDate = new DateTime(2019, 09, 16), IsBrutal = true,
                            BattleLog   = new BattleLog()
                            {
                                BattleEvents = new List <BattleEvent>()
                                {
                                    new BattleEvent()
                                    {
                                        Order       = 2,
                                        Description = "As there were no laptops left. Pillows were used.",
                                        Summary     = "The fight ended in a deadlock. There were no victors."
                                    },
                                    new BattleEvent()
                                    {
                                        Order       = 3,
                                        Description = "Suddenly someone got the bright idea to stuff their pillows with rocks!",
                                        Summary     = "It was a brutal fight with lots of casualties on all sides."
                                    }
                                }
                            }
                        }
                    }
                }
            };

            using (var context = new SamuraiContext())
            {
                context.Samurais.Add(samurai);
                context.SaveChanges();
            }
            string result = EfMethods.ListAllBattlesWithinPeriod(new DateTime(2019, 01, 01), new DateTime(2019, 09, 14), true);

            // isBrutal,
            Assert.AreEqual("Leonardo alias Svangunn fought in Battle of Academy", result);
        }