public void BaseInitializeTest() { User = new EducationSecurityPrincipal(new User { UserKey = "whatever" }); MockHttpContext = MockHttpContextFactory.Create(); }
public void InitializeTest() { MockContext = MockHttpContextFactory.Create(); TestData = new TestData(); User = new EducationSecurityPrincipal(new User { UserKey = "whatever" }); }
public void InitializeTest() { EducationContext = new EducationDataContext(); Container = AssemblySetup.CreateWindsorContainer(EducationContext); RepositoryContainer repositoryContainer = new RepositoryContainer(Container, EducationContext); Target = new SchoolDistrictManager(repositoryContainer, new DataTableBinder(), new UserAuditor()); User = new EducationSecurityPrincipal(EducationContext.Users.Include("UserRoles.Role").Single(u => u.UserKey == "Bob")); MockContext = MockHttpContextFactory.Create(); }
public void GivenIControllerType_WhenICreateController_ThenContructTheType() { RequestContext request = new RequestContext(MockHttpContextFactory.Create(), new RouteData()); IController expected = new TestController(); Type controllerType = expected.GetType(); Kernel.Expect(m => m.Resolve(controllerType)).Return(expected); IController actual = Target.ExecuteGetControllerInstance(request, controllerType); Assert.AreEqual(expected, actual); }
public void BaseInitializeTest() { User = new EducationSecurityPrincipal(new User { UserKey = "whatever" }); Data = new TestData(); Repositories = new TestRepositories(Data); MockHttpContext = MockHttpContextFactory.Create(); MockDataTableBinder = MockRepository.GenerateMock <IDataTableBinder>(); PermissionFactory.SetCurrent(MockRepository.GenerateMock <IPermissionFactory>()); }
public void WhenGenerateDataTableResultViewModel_ThenViewModelContainsData() { HttpContextBase mockHttpContext = MockHttpContextFactory.Create(); DataTableRequestModel viewModel = new DataTableRequestModel { iDisplayLength = 10 }; UserClientDataTable dataTable = new UserClientDataTable(mockHttpContext.Request, new DefaultSecurityConfiguration()); DataTableResultModel actual = Target.GenerateDataTableResultViewModel(viewModel, dataTable); Assert.AreNotEqual(0, actual.aaData.Count()); }
public void GivenSortOnStatus_WhenGenerateDataTableResultViewModel_ThenViewModelContainsData() { HttpContextBase mockHttpContext = MockHttpContextFactory.Create(); DataTableRequestModel viewModel = new DataTableRequestModel { iDisplayLength = 10 }; mockHttpContext.Request.Expect(m => m["iSortCol_0"]).Return("0"); mockHttpContext.Request.Expect(m => m["sSortDir_0"]).Return("acs"); UserClientDataTable dataTable = new UserClientDataTable(mockHttpContext.Request, new DefaultSecurityConfiguration()); DataTableResultModel actual = Target.GenerateDataTableResultViewModel(viewModel, dataTable); Assert.AreNotEqual(0, actual.aaData.Count()); }
public void InitializeTest() { EducationContext = new EducationDataContext(); Container = AssemblySetup.CreateWindsorContainer(EducationContext); RepositoryContainer repositoryContainer = new RepositoryContainer(Container, EducationContext); SchoolDistrictManager logicManager = new SchoolDistrictManager(repositoryContainer, new DataTableBinder(), new UserAuditor()); Target = new StudentController(logicManager); User userEntity = EducationContext.Users.Include("UserRoles.Role").Include("UserRoles.Schools").Include("UserRoles.Providers").Single(s => s.UserKey == "Bob"); User = new EducationSecurityPrincipal(userEntity); MockHttpContext = MockHttpContextFactory.Create(); MockHttpContext.Expect(m => m.User).Return(User); ControllerContext context = new ControllerContext(MockHttpContext, new RouteData(), Target); Target.ControllerContext = context; }
public void InitializeTest() { TestData = new TestData(); User = new EducationSecurityPrincipal(new User { UserKey = "TestKey" }); MockContext = MockHttpContextFactory.Create(); MockContext.Expect(m => m.User).Return(User); MockBlobClient = MockRepository.GenerateMock <IBlobClient>(); MockBlobContainer = MockRepository.GenerateMock <IBlobContainer>(); MockBlobContainer.Expect(m => m.DownloadToStream(null, null)).IgnoreArguments().Do(new Action <string, Stream>((address, target) => { byte[] byteArray = File.ReadAllBytes(address); target.Write(byteArray, 0, (int)byteArray.Length); })); MockBlobContainer.Expect(m => m.UploadFromStream(null, null)).IgnoreArguments().Do(new Action <string, Stream>((address, stream) => { File.WriteAllBytes(address, ((MemoryStream)stream).ToArray()); })); MockBlobClient.Expect(m => m.CreateContainer(BaseFileProcessor.ServiceFileContainerName)).IgnoreArguments().Return(MockBlobContainer); FileData = new DataTable(); FileData.Columns.Add("blank", typeof(string)); FileData.Columns.Add("Id", typeof(string)); FileData.Columns.Add("DateAttended", typeof(string)); FileData.Columns.Add("Subject", typeof(string)); FileData.Columns.Add("Duration", typeof(string)); FileData.Columns.Add("Notes", typeof(string)); DataRow row = FileData.NewRow(); FileData.Rows.Add(row); row = FileData.NewRow(); row["Id"] = "2"; FileData.Rows.Add(row); row = FileData.NewRow(); row["Id"] = "STUDENT ID"; row["DateAttended"] = "DATE"; row["Subject"] = "SUBJECT"; row["Duration"] = "DURATION"; row["Notes"] = "NOTES"; FileData.Rows.Add(row); Repositories = new TestRepositories(TestData); IPermissionFactory mockPermissionFactory = MockRepository.GenerateMock <IPermissionFactory>(); PermissionFactory.SetCurrent(mockPermissionFactory); Target = new ServiceAttendanceFileProcessor(MockBlobClient, Repositories.MockRepositoryContainer); }
private static HttpContextBase CreateHttpContextBase(bool mockableContext, string userKey) { if (mockableContext) { HttpContextBase httpContext = MockHttpContextFactory.Create(); httpContext.Expect(m => m.User).Return(MockRepository.GenerateMock <IPrincipal>()); httpContext.User.Expect(m => m.Identity).Return(MockRepository.GenerateMock <IIdentity>()); httpContext.User.Identity.Expect(m => m.IsAuthenticated).Return(false); httpContext.Request.Expect(m => m.Url).Return(new Uri("http://site.com/Bob/123")); httpContext.Request.Expect(m => m.RawUrl).Return("Bob/123"); httpContext.Request.Headers.Add("Host", "site.com"); return(httpContext); } else { return(new UserHttpContext(userKey)); } }
public void GivenNullType_WhenICreateController_ThenThrowHttpException() { RequestContext request = new RequestContext(MockHttpContextFactory.Create(), new RouteData()); Target.ExpectException <HttpException>(() => Target.ExecuteGetControllerInstance(request, null)); }
public void InitializeTest() { MockHttpContext = MockHttpContextFactory.Create(); Target = new HandleEntityErrorAttribute(); }