public void ParseAndSave_ShouldReadTheStreamFromTheFile()
        {
            //Arrange
            var model = fixture.Build<UpdateDiamondsModel>().With(x => x.Supplier, "SampleCSVModel").CreateAnonymous();
            var httpContext = MockRepository.GenerateStub<HttpContextBase>();

            var fileCollection = MockRepository.GenerateStub<HttpFileCollectionBase>();

            var file = MockRepository.GenerateMock<HttpPostedFileBase>();
            file.Expect(x => x.InputStream).Return(new MemoryStream());

            fileCollection.Stub(x => x[0]).Return(file);

            var request = MockRepository.GenerateStub<HttpRequestBase>();
            request.Stub(x => x.Files).Repeat.Once().Return(fileCollection);

            httpContext.Stub(x => x.Request).Return(request);

            var csvParser = MockRepository.GenerateStub<ICSVParser>();
            var db = MockRepository.GenerateStub<IDatabasePersistence>();

            var hendler = new TempUpdateDiamodsHendler(model, httpContext, csvParser, db);
            //Act
            hendler.ParseAndSave();

            //Assert
            request.VerifyAllExpectations();
        }
Esempio n. 2
0
 public ActionResult UpdateDiamonds(UpdateDiamondsModel model)
 {
     var parser = new TempUpdateDiamodsHendler(model, HttpContext, csvParser, databasePersistence);
     parser.ParseAndSave();
     return View();
 }