Esempio n. 1
0
        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);
        }
 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);
 }