コード例 #1
0
        public void InMemoryParticipantStore_canAdd()
        {
            var participantAdded            = new Participant(1, "Bob", "Smith");
            IRepository <Participant> store = new InMemoryParticipantStore();

            store.Add(participantAdded);
            var resultParticipant = store.Single(a => a.ID == participantAdded.ID);

            Assert.That(resultParticipant, Is.EqualTo(participantAdded));
        }
コード例 #2
0
        public void InMemoryParticipantStore_canUpsertAndThenSelect()
        {
            var participantAdded            = new Participant(null, "Bob", "Smith");
            IRepository <Participant> store = new InMemoryParticipantStore();

            store.Add(participantAdded);

            var resultParticipant = store.Single(a => a.FirstName == participantAdded.FirstName);

            Assert.That(resultParticipant.FirstName, Is.EqualTo(participantAdded.FirstName));
            Assert.That(resultParticipant.ID, Is.Not.Null);
        }
コード例 #3
0
        public void InMemoryParticipantStore_CanLookup()
        {
            //Setup
            List <Participant> originalList = new List <Participant>();
            var expectedParticipant         = new Participant(1, "Bob", "Smith");

            originalList.Add(expectedParticipant);

            IRepository <Participant> store = new InMemoryParticipantStore(originalList);

            var result = store.Single(p => p.ID == expectedParticipant.ID);

            //Assert Results
            Assert.That(result, Is.EqualTo(expectedParticipant));
        }
コード例 #4
0
        public void InMemoryParticipantStore_canUpsertManyAndThenSelect()
        {
            var participant1     = new Participant(null, "Bob", "Smith");
            var participant2     = new Participant(null, "John", "Doe");
            var participantArray = new Participant[] { participant1, participant2 };

            IRepository <Participant> store = new InMemoryParticipantStore();

            store.Add(participantArray);

            var resultParticipant = store.Single(a => a.FirstName == participant1.FirstName);

            Assert.That(resultParticipant.FirstName, Is.EqualTo(participant1.FirstName));
            Assert.That(resultParticipant.ID, Is.Not.Null);
        }
コード例 #5
0
        public void InMemoryParticipantStore_ReturnsNullWhenNotFound()
        {
            //Setup
            List <Participant> originalList = new List <Participant>();
            var participant = new Participant(1, "Bob", "Smith");

            originalList.Add(participant);

            var nonExistantID = 12345;

            IRepository <Participant> store = new InMemoryParticipantStore(originalList);

            var result = store.Single(p => p.ID == nonExistantID);

            //Assert Results
            Assert.That(result, Is.Null);
        }