public void Given_A_Excel_File_Then_Get_A_String()
        {
            var mockFile = new Mock <IFormFile>();

            _mockConstructFileStoragePath.Setup(x => x.GetPath(It.IsAny <string>())).Returns("d:/123-qwe.elsx");
            _mockSaveFile.Setup(x => x.Save(It.IsAny <IFormFile>(), It.IsAny <string>()));
            _mockFileParser.Setup(x => x.Parse(It.IsAny <string>())).Returns(new DataTable());
            _mockCompanyCatalogueCollection.Setup(x => x.GetCollection(It.IsAny <DataTable>()))
            .Returns(new List <CompanyDetailModel>());
            _mockCatalogueUOW
            .Setup(x => x.Create(It.IsAny <List <CompanyDetailModel> >(), It.IsAny <string>(), It.IsAny <string>()));
            _mockDeleteFile.Setup(x => x.Delete(It.IsAny <string>()));

            var result = _processCatalogueFile.Process(mockFile.Object);

            Assert.IsTrue(result is Task <string>);
        }
Esempio n. 2
0
        public async Task <IActionResult> PostAsync(IFormFile catalogueFile)
        {
            try
            {
                string catalogueId = await _processCatalogueFile.Process(catalogueFile);

                return(Created("api/catalogue/" + catalogueId, new { CatalogueId = catalogueId }));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }