当前位置: 首页>>代码示例>>C#>>正文


C# TestRepository.AddAll方法代码示例

本文整理汇总了C#中TestRepository.AddAll方法的典型用法代码示例。如果您正苦于以下问题:C# TestRepository.AddAll方法的具体用法?C# TestRepository.AddAll怎么用?C# TestRepository.AddAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestRepository的用法示例。


在下文中一共展示了TestRepository.AddAll方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetNextChallengeBoardCategory

        public void GetNextChallengeBoardCategory()
        {
            var repository = new TestRepository();

            // create a game with some challenges
            var board = new Board();
            repository.Add(board);
            var game = new Game() { BoardId = board.Id };
            repository.Add(game);
            var category = new ChallengeCategory();
            repository.Add(category);
            var challenge1 = new Challenge() { ChallengeCategoryId = category.Id };
            var challenge2 = new Challenge() { ChallengeCategoryId = category.Id };
            var challenge3 = new Challenge() { ChallengeCategoryId = category.Id };
            var challenges = new Challenge[] { challenge1, challenge2, challenge3 };
            repository.AddAll(challenges);
            repository.Add(new BoardChallengeCategory() { BoardId = board.Id, ChallengeCategoryId = category.Id });

            // keep getting the next challenge until all challenges should have been used
            var usedChallenges = new List<Challenge>();
            foreach (Challenge challenge in challenges)
            {
                usedChallenges.Add(game.GetNextChallenge(0));
            }

            // verify that all challenges were used
            CollectionAssert.AreEqual(challenges.Select(x => x.Id).OrderBy(x => x), usedChallenges.Select(x => x.Id).OrderBy(x => x));

            // verify that more challenges can be retrieved
            Assert.IsNotNull(game.GetNextChallenge(0));
        }
开发者ID:nfink,项目名称:Haven,代码行数:31,代码来源:GameTests.cs

示例2: DeleteChallenge

        public void DeleteChallenge()
        {
            var repository = new TestRepository();

            // add test challenges
            var challenge1 = new Challenge() { Question = "Test Question 1" };
            var challenge2 = new Challenge() { Question = "Test Question 2" };
            repository.Add(challenge1);
            repository.Add(challenge2);

            // add answers
            var answer1a = new ChallengeAnswer() { Answer = "Test Answer 1a", Correct = true, ChallengeId = challenge1.Id };
            var answer1b = new ChallengeAnswer() { Answer = "Test Answer 1b", Correct = false, ChallengeId = challenge1.Id };
            var answer2a = new ChallengeAnswer() { Answer = "Test Answer 2a", Correct = true, ChallengeId = challenge2.Id };
            var answer2b = new ChallengeAnswer() { Answer = "Test Answer 2b", Correct = false, ChallengeId = challenge2.Id };
            repository.AddAll(new ChallengeAnswer[] { answer1a, answer1b, answer2a, answer2b });

            // delete one challenge
            challenge1.Delete();

            // verify challenge and answers are deleted
            Assert.IsEmpty(repository.Find<Challenge>(x => x.Id == challenge1.Id));
            Assert.IsEmpty(repository.Find<ChallengeAnswer>(x => x.Id == answer1a.Id));
            Assert.IsEmpty(repository.Find<ChallengeAnswer>(x => x.Id == answer1b.Id));

            // verify other challenge is not deleted
            Assert.IsNotEmpty(repository.Find<Challenge>(x => x.Id == challenge2.Id));
            Assert.IsNotEmpty(repository.Find<ChallengeAnswer>(x => x.Id == answer2a.Id));
            Assert.IsNotEmpty(repository.Find<ChallengeAnswer>(x => x.Id == answer2b.Id));
        }
开发者ID:nfink,项目名称:Haven,代码行数:30,代码来源:ChallengeTests.cs

示例3: MultipleChoiceAnswer

        public void MultipleChoiceAnswer()
        {
            var repository = new TestRepository();

            // create a multiple choice challenge
            var challenge = new Challenge() { Question = "Test Question 1", ChallengeCategoryId = 2, OwnerId = 3 };
            repository.Add(challenge);
            var answer1 = new ChallengeAnswer() { Answer = "Test Answer 1", Correct = true, ChallengeId = challenge.Id };
            var answer2 = new ChallengeAnswer() { Answer = "Test Answer 2", Correct = false, ChallengeId = challenge.Id };
            repository.AddAll(new ChallengeAnswer[] { answer1, answer2 });

            // verify that correct answer is acknowledged as correct
            Assert.True(challenge.CorrectAnswer(answer1.Id));
            Assert.False(challenge.CorrectAnswer(answer2.Id));
        }
开发者ID:nfink,项目名称:Haven,代码行数:15,代码来源:ChallengeTests.cs

示例4: CloneChallenge

        public void CloneChallenge()
        {
            var repository = new TestRepository();

            // create a challenge
            var challenge = new Challenge() { Question = "Test Question 1", ChallengeCategoryId = 2, OwnerId = 3, OpenEnded = true };
            repository.Add(challenge);
            var answer1 = new ChallengeAnswer() { Answer = "Test Answer 1", Correct = true, ChallengeId = challenge.Id };
            var answer2 = new ChallengeAnswer() { Answer = "Test Answer 2", Correct = false, ChallengeId = challenge.Id };
            repository.AddAll(new ChallengeAnswer[] { answer1, answer2 });

            // clone the challenge
            var clonedChallenge = challenge.Clone();

            // verify that challenge and answers were cloned
            Assert.AreNotEqual(challenge.Id, clonedChallenge.Id);
            Assert.AreEqual(challenge.Question, clonedChallenge.Question);
            Assert.AreEqual(challenge.ChallengeCategoryId, clonedChallenge.ChallengeCategoryId);
            Assert.AreEqual(challenge.OwnerId, clonedChallenge.OwnerId);
            Assert.AreEqual(challenge.OpenEnded, clonedChallenge.OpenEnded);
            Assert.AreNotEqual(challenge.Answers.Select(x => x.Id), clonedChallenge.Answers.Select(x => x.Id));
            Assert.AreEqual(challenge.Answers.Select(x => x.Answer), clonedChallenge.Answers.Select(x => x.Answer));
            Assert.AreEqual(challenge.Answers.Select(x => x.Correct), clonedChallenge.Answers.Select(x => x.Correct));
        }
开发者ID:nfink,项目名称:Haven,代码行数:24,代码来源:ChallengeTests.cs

示例5: DeleteSpace

        public void DeleteSpace()
        {
            var repository = new TestRepository();

            // create spaces
            var space1 = new Space();
            var space2 = new Space();
            repository.AddAll(new Space[] { space1, space2 });

            // delete a space
            space1.Delete();

            // verify that space is deleted
            Assert.IsEmpty(repository.Find<Space>(x => x.Id == space1.Id));

            // verify that other space is not deleted
            Assert.IsNotEmpty(repository.Find<Space>(x => x.Id == space2.Id));
        }
开发者ID:nfink,项目名称:Haven,代码行数:18,代码来源:SpaceTests.cs

示例6: DeletedSafeHavenSpace

        public void DeletedSafeHavenSpace()
        {
            var repository = new TestRepository();

            // create safe haven spaces
            var safeHavenCard1 = new SafeHavenCard();
            var safeHavenCard2 = new SafeHavenCard();
            repository.AddAll(new SafeHavenCard[] { safeHavenCard1, safeHavenCard2 });
            var space1 = new Space() { SafeHavenCardId = safeHavenCard1.Id };
            var space2 = new Space() { SafeHavenCardId = safeHavenCard2.Id };
            repository.AddAll(new Space[] { space1, space2 });

            // delete a space
            space1.Delete();

            // verify that space is deleted
            Assert.IsEmpty(repository.Find<Space>(x => x.Id == space1.Id));

            // verify that safe haven card is deleted
            Assert.IsEmpty(repository.Find<SafeHavenCard>(x => x.Id == space1.SafeHavenCardId));

            // verify that other space data is not deleted
            Assert.IsNotEmpty(repository.Find<Space>(x => x.Id == space2.Id));
            Assert.IsNotEmpty(repository.Find<SafeHavenCard>(x => x.Id == space2.SafeHavenCardId));
        }
开发者ID:nfink,项目名称:Haven,代码行数:25,代码来源:SpaceTests.cs

示例7: DeletedChallengeSpace

        public void DeletedChallengeSpace()
        {
            var repository = new TestRepository();

            // create challenge spaces
            var nameCard1 = new NameCard();
            var nameCard2 = new NameCard();
            repository.AddAll(new NameCard[] { nameCard1, nameCard2 });
            var space1 = new Space() { NameCardId = nameCard1.Id };
            var space2 = new Space() { NameCardId = nameCard2.Id };
            repository.AddAll(new Space[] { space1, space2 });

            // delete a space
            space1.Delete();

            // verify that space is deleted
            Assert.IsEmpty(repository.Find<Space>(x => x.Id == space1.Id));

            // verify that name card is deleted
            Assert.IsEmpty(repository.Find<NameCard>(x => x.Id == space1.NameCardId));

            // verify that other space data is not deleted
            Assert.IsNotEmpty(repository.Find<Space>(x => x.Id == space2.Id));
            Assert.IsNotEmpty(repository.Find<NameCard>(x => x.Id == space2.NameCardId));
        }
开发者ID:nfink,项目名称:Haven,代码行数:25,代码来源:SpaceTests.cs

示例8: GetNextChallengeMultipleBoardCategories

        public void GetNextChallengeMultipleBoardCategories()
        {
            var repository = new TestRepository();

            // create a game with some challenges
            var board = new Board();
            repository.Add(board);
            var game = new Game() { BoardId = board.Id };
            repository.Add(game);
            var category1 = new ChallengeCategory();
            var category2 = new ChallengeCategory();
            repository.Add(category1);
            repository.Add(category2);
            var challenge1 = new Challenge() { ChallengeCategoryId = category1.Id };
            var challenge2 = new Challenge() { ChallengeCategoryId = category1.Id };
            var challenge3 = new Challenge() { ChallengeCategoryId = category2.Id };
            var challenge4 = new Challenge() { ChallengeCategoryId = category2.Id };
            var challenge5 = new Challenge() { ChallengeCategoryId = category2.Id };
            var challenges = new Challenge[] { challenge1, challenge2, challenge3, challenge4, challenge5 };
            repository.AddAll(challenges);
            repository.Add(new BoardChallengeCategory() { BoardId = board.Id, ChallengeCategoryId = category1.Id });
            repository.Add(new BoardChallengeCategory() { BoardId = board.Id, ChallengeCategoryId = category2.Id });

            // get some challenges (which ones will be used is indeterminate)
            for (int i = 0; i < 10; i++)
            {
                game.GetNextChallenge(0);
            }
        }
开发者ID:nfink,项目名称:Haven,代码行数:29,代码来源:GameTests.cs

示例9: CreateGameData

        private Game CreateGameData(TestRepository repository)
        {
            // create game
            var board = new Board();
            repository.Add(board);
            repository.Add(new Space() { BoardId = board.Id });
            var game = new Game() { BoardId = board.Id };
            repository.Add(game);

            // add challenges
            var challenge1 = new Challenge();
            var challenge2 = new Challenge();
            var challenge3 = new Challenge();
            var challenge4 = new Challenge();
            repository.AddAll(new Challenge[] { challenge1, challenge2, challenge3, challenge4 });

            // mark some challenges as used
            repository.Add(new UsedChallenge() { GameId = game.Id, ChallengeId = challenge1.Id });
            repository.Add(new UsedChallenge() { GameId = game.Id, ChallengeId = challenge2.Id });

            // add players
            game.AddPlayer();
            game.AddPlayer();
            game.AddPlayer();

            return game;
        }
开发者ID:nfink,项目名称:Haven,代码行数:27,代码来源:GameTests.cs

示例10: CreateBoardData

 private Board CreateBoardData(TestRepository repository)
 {
     var image = new Image() { Filename = "test.jpg" };
     repository.Add(image);
     var board = new Board() { ImageId = image.Id, Active = true, Description = "test1", Name = "test3", OwnerId = 4, TurnsToEnd = 50, NameCardsToEnd = 10, SafeHavenCardsToEnd = 5 };
     repository.Add(board);
     var space1 = new Space() { BoardId = board.Id, Order = 10 };
     var space2 = new Space() { BoardId = board.Id, Order = 20 };
     var space3 = new Space() { BoardId = board.Id, Order = 30 };
     repository.AddAll(new Space[] { space1, space2, space3 });
     var category1 = new ChallengeCategory() { Name = "test1", OwnerId = 2 };
     var category2 = new ChallengeCategory() { Name = "test3", OwnerId = 4 };
     var category3 = new ChallengeCategory() { Name = "test4", OwnerId = 4 };
     var categories = new ChallengeCategory[] { category1, category2, category3 };
     repository.AddAll(categories);
     repository.Add(new SpaceChallengeCategory() { SpaceId = space1.Id, ChallengeCategoryId = category1.Id });
     repository.Add(new SpaceChallengeCategory() { SpaceId = space2.Id, ChallengeCategoryId = category3.Id });
     var challenge1 = new Challenge() { Question = "test1", ChallengeCategoryId = category1.Id, OwnerId = 3 };
     var challenge2 = new Challenge() { Question = "test2", ChallengeCategoryId = category2.Id, OwnerId = 4 };
     repository.AddAll(new Challenge[] { challenge1, challenge2 });
     repository.Add(new BoardChallengeCategory() { BoardId = board.Id, ChallengeCategoryId = category1.Id });
     repository.Add(new BoardChallengeCategory() { BoardId = board.Id, ChallengeCategoryId = category2.Id });
     return board;
 }
开发者ID:nfink,项目名称:Haven,代码行数:24,代码来源:BoardTests.cs

示例11: GetNewSpace

        public void GetNewSpace()
        {
            var repository = new TestRepository();

            // create a board with some spaces
            var board = new Board();
            repository.Add(board);
            var space1 = new Space() { BoardId = board.Id, Order = 10 };
            var space2 = new Space() { BoardId = board.Id, Order = 20 };
            var space3 = new Space() { BoardId = board.Id, Order = 30 };
            var space4 = new Space() { BoardId = board.Id, Order = 40 };
            var space5 = new Space() { BoardId = board.Id, Order = 50 };
            repository.AddAll(new Space[] { space1, space2, space3, space4, space5 });

            // verify that the correct space is returned moving forward
            Assert.AreEqual(space2.Id, board.GetNewSpace(space1.Id, 1, true).Id);
            Assert.AreEqual(space3.Id, board.GetNewSpace(space1.Id, 2, true).Id);
            Assert.AreEqual(space5.Id, board.GetNewSpace(space1.Id, 4, true).Id);

            // verify that the correct space is returned moving forward and wrapping around
            Assert.AreEqual(space1.Id, board.GetNewSpace(space5.Id, 1, true).Id);
            Assert.AreEqual(space3.Id, board.GetNewSpace(space4.Id, 4, true).Id);

            // verify that the correct space is returned moving forward and moving more than the number of spaces
            Assert.AreEqual(space1.Id, board.GetNewSpace(space1.Id, 5, true).Id);
            Assert.AreEqual(space2.Id, board.GetNewSpace(space1.Id, 11, true).Id);

            // verify that the correct space is returned moving backward
            Assert.AreEqual(space4.Id, board.GetNewSpace(space5.Id, 1, false).Id);
            Assert.AreEqual(space3.Id, board.GetNewSpace(space5.Id, 2, false).Id);
            Assert.AreEqual(space1.Id, board.GetNewSpace(space5.Id, 4, false).Id);

            // verify that the correct space is returned moving backward and wrapping around
            Assert.AreEqual(space5.Id, board.GetNewSpace(space1.Id, 1, false).Id);
            Assert.AreEqual(space3.Id, board.GetNewSpace(space2.Id, 4, false).Id);

            // verify that the correct space is returned moving backward and moving more than the number of spaces
            Assert.AreEqual(space1.Id, board.GetNewSpace(space1.Id, 5, false).Id);
            Assert.AreEqual(space5.Id, board.GetNewSpace(space1.Id, 11, false).Id);
        }
开发者ID:nfink,项目名称:Haven,代码行数:40,代码来源:BoardTests.cs

示例12: OpenEndedAnswer

        public void OpenEndedAnswer()
        {
            var repository = new TestRepository();

            // create an open ended challenge
            var challenge = new Challenge() { Question = "Test Question 1", ChallengeCategoryId = 2, OwnerId = 3, OpenEnded = true };
            repository.Add(challenge);
            var answer1 = new ChallengeAnswer() { Answer = "Test Answer 1", Correct = true, ChallengeId = challenge.Id };
            var answer2 = new ChallengeAnswer() { Answer = "Test Answer 2", Correct = false, ChallengeId = challenge.Id };
            repository.AddAll(new ChallengeAnswer[] { answer1, answer2 });

            // verify that correct answer is acknowledged as correct
            Assert.True(challenge.CorrectAnswer(answer1.Answer));
            Assert.False(challenge.CorrectAnswer(answer2.Answer));
            Assert.False(challenge.CorrectAnswer(answer1.Answer + "a"));
        }
开发者ID:nfink,项目名称:Haven,代码行数:16,代码来源:ChallengeTests.cs


注:本文中的TestRepository.AddAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。