public void TestAddPermit()
        {
            Mock<IPermitInfoView> view = new Mock<IPermitInfoView>();
            view.Setup(viewSetup => viewSetup.PermitInfoEntity).Returns(
                new DataContext.CS_JobPermit()
                {
                    Type = 1,
                    Number = "ABC123",
                    Location = "Denton, TX",
                    CreationDate = DateTime.Now,
                    CreatedBy = "ksantos",
                    FileName = "UploadSample.txt",
                    Path = "/Uploads/Permits/20101208190800_UploadSample.txt",
                    Active = true,
                    ID = 1,
                    AgencyOperator = "Agency",
                    AgentOperatorName = "David Jones",
                    PermitDate = DateTime.Now
                }
            );
            view.Setup(viewSetup => viewSetup.PermitInfoEntityList).Returns(new List<DataContext.CS_JobPermit>());

            PermitInfoPresenter presenter = new PermitInfoPresenter(view.Object);
            presenter.AddPermit();

            Assert.AreEqual(LIST_COUNT_TO_TEST, view.Object.PermitInfoEntityList.Count);
        }
        public void TestFileUpload()
        {
            FileInfo fileInfo = new FileInfo(Path.GetFullPath("UploadSample.txt"));

            Mock<IPermitInfoView> view = new Mock<IPermitInfoView>();
            view.Setup(viewSetup => viewSetup.FileName).Returns("UploadSample.txt");
            view.Setup(viewSetup => viewSetup.UploadedFile).Returns(fileInfo.OpenRead());
            view.Setup(viewSetup => viewSetup.UploadFolder).Returns(Path.GetTempPath());
            view.SetupProperty(viewSetup => viewSetup.FullFilePath);

            PermitInfoPresenter presenter = new PermitInfoPresenter(view.Object);
            presenter.SaveFile();

            Assert.IsTrue(System.IO.File.Exists(view.Object.FullFilePath));
        }
 public void WhenCloningPermittingInfoExcludeOnlySingleTripPermitType()
 {
     //Arrange
     Mock<IPermitInfoView> mockPermitInfoView = new Mock<IPermitInfoView>();
     mockPermitInfoView.SetupProperty(e => e.CloningId, 1);
     mockPermitInfoView.SetupProperty(e => e.PermitInfoEntityList, null);
     Mock<JobModel> mockJobModel = new Mock<JobModel>();
     mockJobModel.Setup(e => e.GetPermitInfoByJob(1)).Returns(
         new List<CS_JobPermit>()
         {
             new CS_JobPermit() { CS_JobPermitType = new CS_JobPermitType() { ID=1, Description = "Single-trip"}},
             new CS_JobPermit() { CS_JobPermitType = new CS_JobPermitType() { ID=2, Description="Anual"}},
             new CS_JobPermit() { CS_JobPermitType = new CS_JobPermitType() { ID=3, Description="Quartely"}},
             new CS_JobPermit() { CS_JobPermitType = new CS_JobPermitType() { ID=4, Description = "Single-trip"}}
         });
     PermitInfoPresenter presenter = new PermitInfoPresenter(mockPermitInfoView.Object,mockJobModel.Object);
     //Act
     presenter.ListPermitInfoCloning();
     //Assert
     Assert.AreEqual(mockPermitInfoView.Object.PermitInfoEntityList.Count,2);
 }
        public void TestRemovePermit()
        {
            Mock<IPermitInfoView> view = new Mock<IPermitInfoView>();
            view.Setup(viewSetup => viewSetup.RemoveIndex).Returns(0);
            view.Setup(viewSetup => viewSetup.PermitInfoEntityList).Returns(new List<DataContext.CS_JobPermit>()
                {
                    new DataContext.CS_JobPermit() { ID = 1 },
                    new DataContext.CS_JobPermit() { ID = 2 }
                }
            );

            PermitInfoPresenter presenter = new PermitInfoPresenter(view.Object);
            presenter.RemovePermit();

            Assert.AreEqual(LIST_COUNT_TO_TEST, view.Object.PermitInfoEntityList.Count);
        }
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     _presenter = new PermitInfoPresenter(this);
 }