Ejemplo n.º 1
0
        public ActionResult Index(HttpPostedFileBase file)
        {
            if (file != null && file.ContentLength > 0)
            {
                try
                {
                    if (Path.GetExtension(file.FileName)?.Substring(1) != "csv")
                    {
                        ViewBag.Message = "Please upload a file of type CSV.";
                        return(View());
                    }

                    string inputContent;
                    using (var inputStreamReader = new StreamReader(file.InputStream))
                    {
                        inputContent = inputStreamReader.ReadToEnd();
                    }
                    ViewBag.Message = LabFunctions.GetLeader(inputContent);
                }
                catch (Exception ex)
                {
                    ViewBag.Message = "ERROR:" + ex.Message;
                }
            }
            else
            {
                ViewBag.Message = "You have not specified a file.";
            }
            return(View());
        }
Ejemplo n.º 2
0
        public void AssertThatOneIsReturned()
        {
            // Arrange
            var fileContentString = "2,3,4,5,6,2,2,2,2,2,2,2,2";

            // Act
            var result = LabFunctions.GetLeader(fileContentString);

            // Assert
            Assert.AreSame(result, "1");
        }
Ejemplo n.º 3
0
        public void AssertThatNullMessageReturnedWhenfileContentStringIsNull()
        {
            // Arrange
            string fileContentString = null;

            // Act
            var result = LabFunctions.GetLeader(fileContentString);

            // Assert
            Assert.AreSame(result, "String is null");
        }