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)).Return(MockBlobContainer); FileData = new DataTable(); FileData.Columns.Add("blank", typeof(string)); FileData.Columns.Add("Id", typeof(string)); FileData.Columns.Add("StartDate", typeof(string)); FileData.Columns.Add("EndDate", 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["StartDate"] = "START DATE"; row["EndDate"] = "END DATE"; row["Notes"] = "NOTES"; FileData.Rows.Add(row); Repositories = new TestRepositories(TestData); IPermissionFactory mockPermissionFactory = MockRepository.GenerateMock <IPermissionFactory>(); PermissionFactory.SetCurrent(mockPermissionFactory); Target = new ServiceOfferingFileProcessor(MockBlobClient, Repositories.MockRepositoryContainer); }
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)).Return(MockBlobContainer); FileData = new DataTable(); FileData.Columns.Add("blank", typeof(string)); FileData.Columns.Add("Id", typeof(string)); FileData.Columns.Add("StartDate", typeof(string)); FileData.Columns.Add("EndDate", 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["StartDate"] = "START DATE"; row["EndDate"] = "END DATE"; row["Notes"] = "NOTES"; FileData.Rows.Add(row); Repositories = new TestRepositories(TestData); IPermissionFactory mockPermissionFactory = MockRepository.GenerateMock<IPermissionFactory>(); PermissionFactory.SetCurrent(mockPermissionFactory); Target = new ServiceOfferingFileProcessor(MockBlobClient, Repositories.MockRepositoryContainer); }