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


C# TestRepository.Add方法代码示例

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


在下文中一共展示了TestRepository.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: CloneSpace

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

            // create a space
            var space = new Space() { BackgroundColorId = 1, BoardId = 2, Height = 3, ImageId = 4, Order = 5, TextColorId = 6, Type = SpaceType.TurnAround, Width = 7, X = 8, Y = 9, IconId = 11 };
            repository.Add(space);

            // clone the space
            var clonedSpace = space.Clone();

            // verify that space was cloned
            Assert.AreNotEqual(space.Id, clonedSpace.Id);
            Assert.AreEqual(clonedSpace.BackgroundColorId, space.BackgroundColorId);
            Assert.AreEqual(clonedSpace.BoardId, space.BoardId);
            Assert.AreEqual(clonedSpace.Height, space.Height);
            Assert.AreEqual(clonedSpace.ImageId, space.ImageId);
            Assert.AreEqual(clonedSpace.Name, space.Name);
            Assert.AreEqual(clonedSpace.Order, space.Order);
            Assert.AreEqual(clonedSpace.TextColorId, space.TextColorId);
            Assert.AreEqual(clonedSpace.Type, space.Type);
            Assert.AreEqual(clonedSpace.Width, space.Width);
            Assert.AreEqual(clonedSpace.X, space.X);
            Assert.AreEqual(clonedSpace.Y, space.Y);
            Assert.AreEqual(clonedSpace.IconId, space.IconId);
        }
开发者ID:nfink,项目名称:Haven,代码行数:26,代码来源:SpaceTests.cs

示例4: RecentMessages

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

            // create a player with some messages
            var player = new Player();
            repository.Add(player);
            var message1 = new Message() { PlayerId = player.Id };
            var message2 = new Message() { PlayerId = player.Id };
            var message3 = new Message() { PlayerId = player.Id };
            var message4 = new Message() { PlayerId = player.Id };
            var message5 = new Message() { PlayerId = player.Id };
            repository.Add(message1);
            repository.Add(message2);
            repository.Add(message3);
            repository.Add(message4);
            repository.Add(message5);

            // verify that the correct messages are returned and in the correct order
            var expectedMessages = new Message[] { message5, message4, message3 }.Select(x => x.Id);
            var recentMessages = player.RecentMessages(3).Select(x => x.Id);
            Assert.AreEqual(expectedMessages, recentMessages);

            // add more messages
            var message6 = new Message() { PlayerId = player.Id };
            var message7 = new Message() { PlayerId = player.Id };
            repository.Add(message6);
            repository.Add(message7);

            // verify that the correct messages are returned and in the correct order
            expectedMessages = new Message[] { message7, message6, message5 }.Select(x => x.Id);
            recentMessages = player.RecentMessages(3).Select(x => x.Id);
            Assert.AreEqual(expectedMessages, recentMessages);
        }
开发者ID:nfink,项目名称:Haven,代码行数:34,代码来源:PlayerTests.cs

示例5: FootlooseFSTestUnitOfWork

        public FootlooseFSTestUnitOfWork()
        {
            List<Person> persons = TestDataStore.GetPersonTestData();

            _persons = new TestRepository<Person>();

            foreach (Person person in persons)
                _persons.Add(person);
        }
开发者ID:rasmith2001,项目名称:FootlooseFinancialServices,代码行数:9,代码来源:FootlooseFSTestUnitOfWork.cs

示例6: CloneNameCard

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

            // create a name card
            var image = new Image() { Filename = "test1" };
            repository.Add<Image>(image);
            var nameCard = new NameCard() { Name = "test1", Details = "test2", ImageId = image.Id };
            repository.Add<NameCard>(nameCard);

            // clone the name card
            var clonedCard = nameCard.Clone();

            // verify that the name card was cloned
            Assert.AreNotEqual(nameCard.Id, clonedCard.Id);
            Assert.AreEqual(nameCard.Name, clonedCard.Name);
            Assert.AreEqual(nameCard.Details, clonedCard.Details);
            Assert.AreNotEqual(nameCard.ImageId, clonedCard.ImageId);
        }
开发者ID:nfink,项目名称:Haven,代码行数:19,代码来源:NameCardTests.cs

示例7: CloneSafeHavenCard

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

            // create a safe haven card
            var image = new Image() { Filename = "test1" };
            repository.Add(image);
            var safeHavenCard = new SafeHavenCard() { Name = "test1", Details = "test2", ImageId = image.Id };
            repository.Add(safeHavenCard);

            // clone the safe haven card
            var clonedCard = safeHavenCard.Clone();

            // verify that the safe haven card was cloned
            Assert.AreNotEqual(safeHavenCard.Id, clonedCard.Id);
            Assert.AreEqual(safeHavenCard.Name, clonedCard.Name);
            Assert.AreEqual(safeHavenCard.Details, clonedCard.Details);
            Assert.AreNotEqual(safeHavenCard.ImageId, clonedCard.ImageId);
        }
开发者ID:nfink,项目名称:Haven,代码行数:19,代码来源:SafeHavenCardTests.cs

示例8: CloneChallengeSpace

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

            // create a space with a name card
            var nameCard = new NameCard() { Name = "test1" };
            repository.Add(nameCard);
            var space = new Space() { NameCardId = nameCard.Id, Order = 10 };
            repository.Add(space);

            // clone the space
            var clonedSpace = space.Clone();

            // verify that space and subobject were cloned
            Assert.AreNotEqual(space.Id, clonedSpace.Id);
            Assert.AreEqual(clonedSpace.Order, space.Order);
            Assert.AreNotEqual(clonedSpace.NameCardId, space.NameCardId);
            Assert.AreEqual(clonedSpace.NameCard.Name, space.NameCard.Name);
        }
开发者ID:nfink,项目名称:Haven,代码行数:19,代码来源:SpaceTests.cs

示例9: CloneSafeHavenSpace

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

            // create a space with a safe haven card
            var safeHavenCard = new SafeHavenCard() { Name = "test1" };
            repository.Add(safeHavenCard);
            var space = new Space() { SafeHavenCardId = safeHavenCard.Id, Order = 10 };
            repository.Add(space);

            // clone the space
            var clonedSpace = space.Clone();

            // verify that space and subobject were cloned
            Assert.AreNotEqual(space.Id, clonedSpace.Id);
            Assert.AreEqual(clonedSpace.Order, space.Order);
            Assert.AreNotEqual(clonedSpace.SafeHavenCardId, space.SafeHavenCardId);
            Assert.AreEqual(clonedSpace.SafeHavenCard.Name, space.SafeHavenCard.Name);
        }
开发者ID:nfink,项目名称:Haven,代码行数:19,代码来源:SpaceTests.cs

示例10: CanSetStateOfExternalInstance

        public void CanSetStateOfExternalInstance()
        {
            var writeTimeRespository = new TestRepository();
            var writeTimeInstance = new ClassB(3);
            var xmlText = SerializeAsXml(new ClassA(writeTimeInstance), writeTimeRespository);

            var readTimeRepository = new TestRepository();
            var readTimeInstance = new ClassB(23);
            readTimeRepository.Add(readTimeInstance.GetType(), readTimeInstance);
            var readClass = ReadXmlText<ClassA>(xmlText, readTimeRepository, null, null);
            Assert.AreSame(readTimeInstance, readClass.Parameter);
            Assert.AreEqual(3, readClass.Parameter.Parameter);
        }
开发者ID:RobSmyth,项目名称:nserializer,代码行数:13,代码来源:ApplicationObjectRepositoryUATs.cs

示例11: TurnAround

        public void TurnAround()
        {
            // set up data
            var repository = new TestRepository();

            var board = new Board();
            repository.Add(board);
            var space = new Space() { Type = SpaceType.TurnAround, BoardId = board.Id };
            repository.Add(space);
            var game = new Game();
            game.Repository = repository;
            game.Create(board.Id, 2);

            // trigger onland
            var player = game.Players.First();
            space.OnLand(player);

            // verify that player was turned around and received the correct message
            player = repository.Get<Player>(player.Id);
            Assert.AreEqual(false, player.MovementDirection);
            var message = player.Messages.Single();
            Assert.AreEqual("Turned around.", message.Text);
        }
开发者ID:nfink,项目名称:Haven,代码行数:23,代码来源:TurnAroundSpaceTests.cs

示例12: DeleteEmptyGame

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

            // create a game without players or used challenges
            var game = new Game();
            repository.Add(game);

            // delete the game
            game.Delete();

            // verify that deletion works
            Assert.IsEmpty(repository.Find<Game>(x => x.Id == game.Id));
        }
开发者ID:nfink,项目名称:Haven,代码行数:14,代码来源:GameTests.cs

示例13: 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

示例14: Init

        public void Init()
        {
            Entity = new TestEntity
                {
                    Id = 0,
                    DateCreated = DateTime.Now,
                    CreatedByUserId = 1,
                    IsActive = true,
                    Name = "Some Test Name"
                };

            Repository = new TestRepository();

            Repository.Add(Entity);
        }
开发者ID:nathanmenhinnitt,项目名称:SharedTools,代码行数:15,代码来源:UpdateTests.cs

示例15: CloneEmptyBoard

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

            // create a board without any associated data
            var board = new Board();
            board.Name = "test1";
            repository.Add(board);

            // clone the board
            var clonedBoard = board.Clone();

            // verify that the board is cloned
            Assert.AreNotEqual(board.Id, clonedBoard.Id);
            Assert.AreEqual(board.Name, clonedBoard.Name);
        }
开发者ID:nfink,项目名称:Haven,代码行数:16,代码来源:BoardTests.cs


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