コード例 #1
0
 public void InitializeTest()
 {
     MockLogicManager       = MockRepository.GenerateMock <IServiceOfferingManager>();
     MockServiceTypeManager = MockRepository.GenerateMock <IServiceTypeManager>();
     MockProviderManager    = MockRepository.GenerateMock <IProviderManager>();
     MockProgramManager     = MockRepository.GenerateMock <IProgramManager>();
     MockFileProcessor      = MockRepository.GenerateMock <IFileProcessor>();
     Target = new ServiceOfferingController(MockLogicManager, MockServiceTypeManager, MockProviderManager, MockProgramManager, MockFileProcessor);
     Target.ControllerContext = new ControllerContext(MockHttpContext, new RouteData(), Target);
     MockHttpContext.Expect(m => m.User).Return(User);
     MockHttpContext.Server.Expect(m => m.MapPath("../../App_Data/Uploads/")).Return(UploadTemplateFolderPath);
 }
コード例 #2
0
        public void TestInitialize()
        {
            EducationContext = new EducationDataContext();
            Container        = AssemblySetup.CreateWindsorContainer(EducationContext);
            RepositoryContainer    repositoryContainer = new RepositoryContainer(Container, EducationContext);
            ServiceOfferingManager logicManager        = new ServiceOfferingManager(repositoryContainer, new DataTableBinder());
            ServiceTypeManager     serviceTypeManager  = new ServiceTypeManager(repositoryContainer, new DataTableBinder());
            ProviderManager        providerManager     = new ProviderManager(repositoryContainer, new DataTableBinder());
            ProgramManager         programManager      = new ProgramManager(repositoryContainer, new DataTableBinder());
            HttpContext            context             = new HttpContext(new HttpRequest("", "http://tempuri.org", ""), new HttpResponse(new StringWriter()));
            User userEntity = EducationContext.Users.Include("UserRoles.Role").Include("UserRoles.Schools").Include("UserRoles.Providers").Single(s => s.UserKey == "Bob");

            User         = new EducationSecurityPrincipal(userEntity);
            context.User = User;
            Target       = new ServiceOfferingController(logicManager, serviceTypeManager, providerManager, programManager, MockRepository.GenerateMock <IFileProcessor>());
            ControllerContext controllerContext = new ControllerContext(new HttpContextWrapper(context), new RouteData(), Target);

            Target.ControllerContext = controllerContext;
        }
コード例 #3
0
        private ServiceUploadModel ExecuteFileUploadPostedFailure(int mockedContentLength)
        {
            IServiceOfferingManager   tempLogicManager = MockRepository.GenerateMock <IServiceOfferingManager>();
            ServiceOfferingController tempTarget       = new ServiceOfferingController(tempLogicManager, MockServiceTypeManager, MockProviderManager, MockProgramManager, MockFileProcessor);

            tempTarget.ControllerContext = new ControllerContext(MockHttpContext, new RouteData(), tempTarget);
            var file = MockRepository.GenerateStub <UploadExcelFileModel>();

            file.File = MockRepository.GenerateStub <HttpPostedFileBase>();
            file.File.Expect(f => f.ContentLength).Return(mockedContentLength);
            file.File.Expect(f => f.ContentType).Return(ExcelWriter.ContentType);
            file.File.Expect(f => f.FileName).Return("HappyPath.xlsx");

            var result = tempTarget.FileUpload(file) as ViewResult;

            MockFileProcessor.AssertWasNotCalled(m => m.ConsumeFile(file));
            MockFileProcessor.AssertWasNotCalled(m => m.Import(User, Path.Combine(UploadTemplateFolderPath, ServiceOfferingController.TemplateFile), null));
            return(result.AssertGetViewModel <ServiceUploadModel>());
        }
        private ServiceUploadModel ExecuteFileUploadPostedFailure(int mockedContentLength)
        {
            IServiceOfferingManager tempLogicManager = MockRepository.GenerateMock<IServiceOfferingManager>();
            ServiceOfferingController tempTarget = new ServiceOfferingController(tempLogicManager, MockServiceTypeManager, MockProviderManager, MockProgramManager, MockFileProcessor);
            tempTarget.ControllerContext = new ControllerContext(MockHttpContext, new RouteData(), tempTarget);
            var file = MockRepository.GenerateStub<UploadExcelFileModel>();
            file.File = MockRepository.GenerateStub<HttpPostedFileBase>();
            file.File.Expect(f => f.ContentLength).Return(mockedContentLength);
            file.File.Expect(f => f.ContentType).Return(ExcelWriter.ContentType);
            file.File.Expect(f => f.FileName).Return("HappyPath.xlsx");

            var result = tempTarget.FileUpload(file) as ViewResult;

            MockFileProcessor.AssertWasNotCalled(m => m.ConsumeFile(file));
            MockFileProcessor.AssertWasNotCalled(m => m.Import(User, Path.Combine(UploadTemplateFolderPath, ServiceOfferingController.TemplateFile), null));
            return result.AssertGetViewModel<ServiceUploadModel>();
        }
 public void InitializeTest()
 {
     MockLogicManager = MockRepository.GenerateMock<IServiceOfferingManager>();
     MockServiceTypeManager = MockRepository.GenerateMock<IServiceTypeManager>();
     MockProviderManager = MockRepository.GenerateMock<IProviderManager>();
     MockProgramManager = MockRepository.GenerateMock<IProgramManager>();
     MockFileProcessor = MockRepository.GenerateMock<IFileProcessor>();
     Target = new ServiceOfferingController(MockLogicManager, MockServiceTypeManager, MockProviderManager, MockProgramManager, MockFileProcessor);
     Target.ControllerContext = new ControllerContext(MockHttpContext, new RouteData(), Target);
     MockHttpContext.Expect(m => m.User).Return(User);
     MockHttpContext.Server.Expect(m => m.MapPath("../../App_Data/Uploads/")).Return(UploadTemplateFolderPath);
 }
 public void TestInitialize()
 {
     EducationContext = new EducationDataContext();
     Container = AssemblySetup.CreateWindsorContainer(EducationContext);
     RepositoryContainer repositoryContainer = new RepositoryContainer(Container, EducationContext);
     ServiceOfferingManager logicManager = new ServiceOfferingManager(repositoryContainer, new DataTableBinder());
     ServiceTypeManager serviceTypeManager = new ServiceTypeManager(repositoryContainer, new DataTableBinder());
     ProviderManager providerManager = new ProviderManager(repositoryContainer, new DataTableBinder());
     ProgramManager programManager = new ProgramManager(repositoryContainer, new DataTableBinder());
     HttpContext context = new HttpContext(new HttpRequest("", "http://tempuri.org", ""), new HttpResponse(new StringWriter()));
     User userEntity = EducationContext.Users.Include("UserRoles.Role").Include("UserRoles.Schools").Include("UserRoles.Providers").Single(s => s.UserKey == "Bob");
     User = new EducationSecurityPrincipal(userEntity);
     context.User = User;
     Target = new ServiceOfferingController(logicManager, serviceTypeManager, providerManager, programManager, MockRepository.GenerateMock<IFileProcessor>());
     ControllerContext controllerContext = new ControllerContext(new HttpContextWrapper(context), new RouteData(), Target);
     Target.ControllerContext = controllerContext;
 }