protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            var ioc = new AutofacSetup();

            _container = ioc.Init();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        }
        public void ResolveController_UsingSqlData_ExpectPatientsControllerWithPatientsContext()
        {
            // arrange
            var ioc = new AutofacSetup();

            var expectedContext = typeof(PatientContext);

            // act
            var container = ioc.Init();

            var actualContext = container.Resolve <IPatientContext>();

            // assert
            Assert.IsInstanceOf(expectedContext, actualContext);
        }
        public void Get_PatientDoesNotExist_ThrowsHttpResponseExceptionHttpStatusCodeNotFound()
        {
            // arrange
            var ioc = new AutofacSetup();

            var useInMemoryDataContext = true;

            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            var container = ioc.Init(useInMemoryDataContext);

            var controller = container.Resolve <PatientsController>();

            var patientId = 2;

            // act
            Action action = () => controller.Get(patientId);

            // assert
            action.ShouldThrowExactly <HttpResponseException>(HttpStatusCode.NotFound.ToString());
        }
        public void Get_PatientExistsWithAnEpisode_ExpectPatientWithEpisode()
        {
            // arrange
            var ioc = new AutofacSetup();

            var useInMemoryDataContext = true;

            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            var container = ioc.Init(useInMemoryDataContext);

            var controller = container.Resolve <PatientsController>();

            var patientId = 1;

            var expected = new Patient
            {
                DateOfBirth = new DateTime(1972, 10, 27),
                FirstName   = "Millicent",
                PatientId   = patientId,
                LastName    = "Hammond",
                NhsNumber   = "1111111111",
                Episodes    = new[]
                {
                    new Episode
                    {
                        AdmissionDate = new DateTime(2014, 11, 12),
                        Diagnosis     = "Irritation of inner ear",
                        DischargeDate = new DateTime(2014, 11, 27),
                        EpisodeId     = 1,
                        PatientId     = patientId
                    }
                }
            };

            // act
            var patient = controller.Get(patientId);

            // assert
            patient.ShouldBeEquivalentTo(expected);
        }