コード例 #1
0
        public void test_that_if_a_session_exists_with_an_unmatching_speaker_id_that_session_is_not_saved()
        {
            // arrange
            var sessions = GetTestSessionList();

            sessions.Add(new Session
            {
                SessionId = 9999,
                Title     = "Some Title",
                Abstract  = "Some Abstract",
                End       = DateTime.Now,
                Start     = DateTime.Now,
                Level     = string.Empty,
                Room      = string.Empty,
                Track     = string.Empty,
                SpeakerId = 9999
            });
            var repository = new PollerContainer().Get <ISessionRepository>();

            // act
            repository.SaveRange(sessions);

            // assert
            Assert.IsNull(repository.Get(9999));
        }
コード例 #2
0
        public void test_that_if_a_speaker_exists_in_the_repository_but_not_in_the_speaker_range_it_is_removed_from_the_repository()
        {
            // arrange
            var repository = new PollerContainer().Get <ISpeakerRepository>();

            // add
            repository.SaveRange(GetSpeakerData());

            // act
            var list      = repository.GetAll().Take(2).ToList();
            var listCount = list.Count;

            repository.SaveRange(list);

            // assert
            Assert.AreEqual(listCount, repository.GetAll().Count);
        }
コード例 #3
0
        public void test_that_saving_a_range_of_sessionchange_instances_allows_those_instances_to_be_retrievable()
        {
            // arrange
            var repository = new PollerContainer().Get <IChangeRepository>();

            // act
            repository.SaveRange(GetChangeTestData());

            // assert
            Assert.AreNotEqual(0, repository.GetAll().Count);
        }
コード例 #4
0
        public void test_that_given_a_range_of_speakers_which_match_existing_speakers_changes_to_speakers_are_persisted_in_the_databsae()
        {
            // arrange
            var repository          = new PollerContainer().Get <ISpeakerRepository>();
            var speakers            = GetSpeakerData();
            var orginalSpeakerCount = speakers.Count;

            // add
            repository.SaveRange(speakers);

            // act
            speakers         = repository.GetAll();
            speakers[0].Name = "Kerry";
            repository.SaveRange(speakers);

            // assert
            speakers = repository.GetAll();
            Assert.AreEqual(orginalSpeakerCount, speakers.Count);
            Assert.AreEqual("Kerry", speakers[0].Name);
        }
コード例 #5
0
        public void test_that_if_a_speaker_exists_in_the_given_range_but_not_in_the_repository_the_speaker_is_added()
        {
            // arrange
            var repository = new PollerContainer().Get <ISpeakerRepository>();
            var speakers   = GetSpeakerData();

            // add
            repository.SaveRange(speakers.Take(2));

            // act
            speakers = repository.GetAll();
            var speaker = GetSpeakerData().First();

            speaker.SpeakerId = 4;
            speakers.Add(speaker);
            repository.SaveRange(speakers);
            speakers = repository.GetAll();

            // assert
            Assert.AreEqual(3, speakers.Count);
        }
コード例 #6
0
        public void test_that_given_a_range_of_speakers_ensure_that_all_items_are_written_to_the_database()
        {
            // arrange
            var repository = new PollerContainer().Get <ISpeakerRepository>();

            // act
            var speakers = GetSpeakerData().ToList();

            repository.SaveRange(speakers);

            // assert pt. 2
            Assert.IsTrue(speakers.Count >= repository.GetAll().Count);
        }
コード例 #7
0
        public void test_that_given_a_master_list_containing_a_session_not_in_the_database_that_the_session_is_added_to_the_database()
        {
            // arrange
            var sessions   = GetTestSessionList();
            var repository = new PollerContainer().Get <ISessionRepository>();

            // add
            var count = sessions.Count;

            repository.SaveRange(sessions.Take(sessions.Count - 1));

            // act
            sessions = repository.GetAll();
            var session = GetTestSessionList()[0];

            session.SessionId = 4;
            sessions.Add(session);
            repository.SaveRange(sessions);

            // assert
            Assert.AreEqual(count, repository.GetAll().Count);
        }
コード例 #8
0
        public void test_that_saving_a_range_produces_one_distinct_timestamp_for_creation_grouping()
        {
            // arrange
            var repository = new PollerContainer().Get <IChangeRepository>();

            // act
            repository.SaveRange(GetChangeTestData());

            // assert
            var blocks = repository.GetAll().Select(sc => sc.Changeset).Distinct();

            Assert.AreNotEqual(0, blocks.Count());
            Assert.AreNotEqual(DateTime.MinValue, blocks.First());
        }