public void GvImport_Command_Success()
        {
            //Arrage
            CreateShims();
            var eventArgs  = new GridViewCommandEventArgs(null, new CommandEventArgs(string.Empty, "U"));
            var testObject = new importDatafromFile();

            InitializeAllControls(testObject);
            var privateObject = new PrivateObject(testObject);

            ShimDirectory.ExistsString          = p => false;
            ShimDirectory.CreateDirectoryString = p => null;
            ShimFile.ExistsString     = p => true;
            ShimFile.DeleteString     = p => { };
            ShimFile.AppendTextString = p => new ShimStreamWriter();
            ShimEmailGroup.ExportFromImportEmailsUserStringString = (p1, p2, p3) => new DataTable {
                Columns = { "1" }, Rows = { { "1" } }
            };
            var responseHeader = string.Empty;

            ShimHttpResponse.AllInstances.ContentTypeSetString  = (p1, p2) => { };
            ShimHttpResponse.AllInstances.AddHeaderStringString = (p1, p2, p3) => responseHeader += p2 + " " + p3;
            ShimHttpResponse.AllInstances.WriteFileString       = (p1, p2) => { };
            ShimHttpResponse.AllInstances.End = (p) => { };
            ShimPage.AllInstances.ResponseGet = (p) => new System.Web.HttpResponse(TextWriter.Null);

            // Act
            privateObject.Invoke("gvImport_Command", new object[] { null, eventArgs });

            // Assert
            responseHeader.ShouldBe("content-disposition attachment; filename=U-.xls");
        }
 private void Initialize()
 {
     CreateShims();
     _importDataFromFileType = typeof(importDatafromFile);
     _importDataFromFile     = CreateInstance(_importDataFromFileType);
     _dataFile     = new DataTable();
     _errlabel     = new Label();
     _importButton = new Button();
     _lblGUID      = new Label();
     _gvImport     = new GridView();
     SetDefaults();
 }
        public void BuildEmailImportForm_Success([Values("C", "S")] string fileType)
        {
            //Arrage
            var dataTable = new DataTable {
                Columns = { "1", "2" }, Rows = { { "1", "2" } }
            };
            var mapper     = new ImportMapper {
            };
            var testObject = new importDatafromFile();

            InitializeAllControls(testObject);
            var privateObject = new PrivateObject(testObject);

            privateObject.SetFieldOrProperty("fileType", fileType);
            var dataCollectionTable = privateObject.GetFieldOrProperty("dataCollectionTable") as HtmlTable;

            // Act
            privateObject.Invoke("BuildEmailImportForm", new object[] { dataTable, mapper });

            // Assert
            dataCollectionTable.Rows.Count.ShouldBe(2);
        }