public void test_that_speakers_can_be_downloaded_and_loaded()
        {
            var container = new PollerContainer();
            var masterDataProvider = container.TryGet<IMasterDataProvider>();
            Assert.AreNotEqual(null, masterDataProvider);

            var speakers = masterDataProvider.GetAllSpeakers();
            Assert.AreNotEqual(0, speakers.Count);
        }
        public void test_that_given_a_non_matching_condition_get_returns_a_null_session_reference()
        {
            // arrange
            var container = new PollerContainer();

            // act
            var session = container.Get<ISessionRepository>().Get(s => s.Title == null);

            // assert
            Assert.IsNull(session);
        }
        public void test_that_giving_an_invalid_session_id_to_get_returns_a_null_session_reference()
        {
            // arrange
            var container = new PollerContainer();

            // act
            var session = container.Get<ISessionRepository>().Get(int.MaxValue);

            // assert
            Assert.IsNull(session);
        }
        public void test_that_getall_returns_all_speakers_from_database_table()
        {
            // arrange
            var repository = new PollerContainer().Get<ISpeakerRepository>();

            // act
            var list = repository.GetAll();

            // assert
            Assert.AreNotEqual(0, list.Count);
        }
        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);
        }
        public void test_that_a_get_with_a_condition_matching_no_items_returns_a_null_instance()
        {
            // arrange
            var repository = new PollerContainer().Get<ISpeakerRepository>();

            // act
            var speaker = repository.Get(sp => sp.Name == null);

            // assert
            Assert.IsNull(speaker);
        }
        public void test_that_given_an_invalid_primary_key_value_get_returns_a_null_session_change_instance()
        {
            // arrange
            var repository = new PollerContainer().Get<IChangeRepository>();

            // act
            var sessionChange = repository.Get(int.MaxValue);

            // assert
            Assert.IsNull(sessionChange);
        }
        public void test_that_getall_with_matching_condition_returns_non_empty_list_from_database()
        {
            // arrange
            var repository = new PollerContainer().Get<ISpeakerRepository>();

            // act
            var list = repository.GetAll(sp => sp.Name != string.Empty);

            // assert
            Assert.AreNotEqual(0, list.Count);
        }
        public void test_that_given_a_matching_condition_applicable_sessionchange_instances_can_be_extracted()
        {
            // arrange
            var repository = new PollerContainer().Get<IChangeRepository>();

            // act
            var list = repository.GetAll(sc => sc.EntityId == 1);

            // assert
            Assert.AreEqual(1, list.Count);
        }
        public void test_that_given_a_matching_condition_get_returns_a_non_null_instance_of_sessionchange()
        {
            // arrange
            var repository = new PollerContainer().Get<IChangeRepository>();

            // act
            var sessionChange = repository.Get(sc => sc.Key == "Title" && sc.EntityId == 1);

            // assert
            Assert.IsNotNull(sessionChange);
            Assert.AreEqual(1, sessionChange.EntityId);
        }
        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());
        }
        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);
        }
        public void test_that_given_a_master_with_sessions_matching_existing_sessions_sessions_are_updated_with_new_values()
        {
            // arrange
            var sessions = GetTestSessionList();
            var originalSessionCount = sessions.Count;
            var container = new PollerContainer();
            var repository = container.Get<ISessionRepository>();

            // add test data
            repository.SaveRange(sessions);
            sessions = repository.GetAll();
            long sessionId = sessions[0].SessionId;

            // precondition
            Assert.AreNotEqual(0, sessionId);

            // act
            sessions[0].Title = "new title";
            repository.SaveRange(sessions);

            // assert
            Assert.AreEqual(originalSessionCount, repository.GetAll().Count);
            Assert.AreEqual("new title", repository.Get(sessionId).Title);
        }
        public void test_that_get_with_a_condition_matching_a_speaker_returns_a_non_null_instance()
        {
            // arrange
            var repository = new PollerContainer().Get<ISpeakerRepository>();

            // act
            var speaker = repository.Get(sp => sp.Name != string.Empty);

            // assert
            Assert.IsNotNull(speaker);
        }
        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));
        }
        public void test_that_get_with_an_invalid_key_value_returns_a_null_speaker_reference()
        {
            // arrange
            var repository = new PollerContainer().Get<ISpeakerRepository>();

            // act
            var speaker = repository.Get(int.MaxValue);

            // assert
            Assert.IsNull(speaker);
        }
        public void test_that_session_data_can_retrieved_using_get_all()
        {
            // arrange
            var container = new PollerContainer();

            // act
            var list = container.Get<ISessionRepository>().GetAll();

            // assert
            Assert.AreNotEqual(0, list.Count);
        }
 public void test_that_a_process_instance_can_be_extracted_from_poller_container()
 {
     var container = new PollerContainer();
     Assert.AreNotEqual(null, container.Get<SessionSynchronize>());
 }
 public void test_general_execution_of_session_worker_process()
 {
     var container = new PollerContainer();
     var process = container.Get<ISynchronize>("Session");
     process.Synchronize();
 }
        public void test_that_get_by_a_valid_key_value_returns_a_non_null_speaker_with_the_given_key()
        {
            // arrange
            var repository = new PollerContainer().Get<ISpeakerRepository>();

            // act
            var speakerId = SpeakerTestDataFactory.GetValidSpeakerId();
            var speaker = repository.Get(speakerId);

            // assert
            Assert.IsNotNull(speaker);
        }
        public void test_that_session_data_can_retrieved_with_a_filter()
        {
            // arrange
            var container = new PollerContainer();

            // act
            var list = container.Get<ISessionRepository>().GetAll(s => s.Abstract.Contains("LINQ"));

            // assert
            Assert.AreNotEqual(0, list.Count);
        }
        public void test_that_sessionchange_instances_can_be_extracted_enmasse_from_the_database()
        {
            // arrange
            var repository = new PollerContainer().Get<IChangeRepository>();

            // act
            var changes = repository.GetAll();

            // assert
            Assert.AreNotEqual(0, changes.Count);
        }
        public void test_that_given_a_valid_primary_key_value_get_returns_a_non_null_sessionchange_instance()
        {
            // arrange
            var repository = new PollerContainer().Get<IChangeRepository>();

            // act
            var lastSessionChangeId = GetLastChangeId();
            var sessionChange = repository.Get(lastSessionChangeId);

            // assert
            Assert.IsNotNull(sessionChange);
            Assert.AreEqual(lastSessionChangeId, sessionChange.ChangeId);
        }
        public void test_that_given_a_range_of_sessions_those_sessions_are_saved_to_the_database_and_can_be_retrieved()
        {
            // arrange
            var sessions = GetTestSessionList();
            var container = new PollerContainer();
            var repository = container.Get<ISessionRepository>();

            // act
            repository.SaveRange(sessions);

            // assert
            Assert.IsTrue(sessions.Count >= repository.GetAll().Count);
        }
        public void test_that_requesting_a_session_using_get_with_a_valid_id_returns_the_appropriate_instance()
        {
            // arrange
            var container = new PollerContainer();
            int sessionId = int.MinValue;
            using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MainConnectionString"].ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("select max(sessionId) from sessions", connection))
                {
                    sessionId = command.ExecuteScalar().ToString().AsInt();
                }
            }

            // act
            var session = container.Get<ISessionRepository>().Get(sessionId);

            // assert
            Assert.IsNotNull(session);
            Assert.AreEqual(sessionId, session.SessionId);
        }
        public void test_that_given_a_non_matching_condition_get_returns_a_null_instance_of_sessionchange()
        {
            // arrange
            var repository = new PollerContainer().Get<IChangeRepository>();

            // act
            var sessionChange = repository.Get(sc => sc.Key == null);

            // assert
            Assert.IsNull(sessionChange);
        }
        public void test_that_given_a_session_range_which_does_not_include_a_session_currently_in_the_database_that_session_should_be_removed()
        {
            // arrange
            var sessions = GetTestSessionList();
            var container = new PollerContainer();
            var repository = container.Get<ISessionRepository>();

            // add
            repository.SaveRange(sessions);

            // act
            sessions = repository.GetAll();
            var removedSessionId = sessions[0].SessionId;
            sessions.RemoveAt(0);
            var sessionCount = sessions.Count;
            repository.SaveRange(sessions);

            // assert
            Assert.IsNull(repository.Get(removedSessionId));
            Assert.AreEqual(sessionCount, repository.GetAll().Count);
        }
 public PollerWorkerRole()
 {
     _container = new PollerContainer();
 }
 public void Init()
 {
     TheContainer = new PollerContainer();
 }