Пример #1
0
 public CitationsController(CommonContext commonContext, RedisCache redisCache, IServiceProvider serviceProvider, IOptions <AppSettings> appSettings, CommonAccountService commonAccountSvc, CitationService citationSvc, FileService fileSvc)
     : base(commonContext, redisCache, serviceProvider, appSettings)
 {
     _commonAccountSvc = commonAccountSvc;
     _citationSvc      = citationSvc;
     _fileSvc          = fileSvc;
 }
        public void CitationService_Add_Throws_On_Null_Citation()
        {
            //Arrange
            _service = new CitationService(_mockUnitOfWork.Object);

            //Assert
            Assert.Throws<ArgumentNullException>(() => _service.Add(null));
        }
 public TicketController(CommonContext commonContext, IServiceProvider serviceProvider, RedisCache redisCache, IOptions <AppSettings> appSettings, CommonAccountService commonAccountSvc, FileService fileService, IDataProtectionProvider dataProtector, StripeService stripeSvc, CitationService citationSvc)
     : base(commonContext, serviceProvider, redisCache, appSettings)
 {
     _commonAccountSvc = commonAccountSvc;
     _dataProtector    = dataProtector.CreateProtector(GetType().FullName);
     _fileService      = fileService;
     _stripeSvc        = stripeSvc;
     _citationSvc      = citationSvc;
 }
 public CitationsController(CommonContext commonContext, RedisCache cache, IOptions <AppSettings> appSettings, AccountContext accountCtx, FileService _fileService, IHostingEnvironment environment, CitationService citationSvc) :
     base(commonContext, cache, appSettings)
 {
     _accountCtx  = accountCtx;
     fileService  = _fileService;
     _environment = environment;
     _appSettings = appSettings.Value;
     _citationSvc = citationSvc;
     _commonCtx   = commonContext;
 }
Пример #5
0
        private void button5_Click(object sender, EventArgs e)
        {
            var citationRepo = new CitationService();

            citationRepo.AddRawCitations(
                new BelManagedLib.EventData
            {
                Text       = "First text.",
                StartPage  = 1,
                StopPage   = 1,
                StartGlyph = 100,
                StopGlyph  = 110,
                //SelectionRectsString = "1,2,3,4;",
                Len      = 1,
                Code     = (int)CodesEnum.DEKBELCODE_ADDCITATION,
                FilePath = @"C:\\28",
            }
                );

            citationRepo.AddRawCitations(
                new BelManagedLib.EventData
            {
                Text       = "Second text.",
                StartPage  = 2,
                StopPage   = 2,
                StartGlyph = 19,
                StopGlyph  = 25,
                //SelectionRectsString = "1,2,3,4;",
                Len      = 1,
                Code     = (int)CodesEnum.DEKBELCODE_ADDCITATION,
                FilePath = @"C:\\28",
            }
                );


            BelGui bel = new BelGui(
                new BelManagedLib.EventData
            {
                Text       = "Third text: Recently, analyses of two large stellar surveys revealed the presence.",
                StartPage  = 1,
                StopPage   = 1,
                StartGlyph = 5,
                StopGlyph  = 8,
                //SelectionRectsString = "1,2,3,4;",
                Len      = 1,
                Code     = (int)CodesEnum.DEKBELCODE_ADDANDSHOWCITATION,
                FilePath = @"C:\\28",
            });

            bel.ShowDialog();

            label_resulttext.Text = bel.Result.Message;
        }
        public void CitationService_Add_Calls_Repository_Add_Method_With_The_Same_Citation_Object_It_Recieved()
        {
            // Create test data
            var newCitation = new Citation
                                    {
                                        Text = "Foo",
                                        Page = "Bar"
                                    };

            //Create Mock
            var mockRepository = new Mock<IRepository<Citation>>();
            _mockUnitOfWork.Setup(d => d.GetRepository<Citation>()).Returns(mockRepository.Object);

            //Arrange
            _service = new CitationService(_mockUnitOfWork.Object);

            //Act
            _service.Add(newCitation);

            //Assert
            mockRepository.Verify(r => r.Add(newCitation));
        }
Пример #7
0
        public static void Main()
        {
            List <Driver>  drivers  = Driver.GenerateDrivers();
            List <Officer> officers = Officer.GenerateOfficers();
            var            service  = new CitationService();

            for (int i = 0; i < officers.Count; i++)
            {
                Citation currentCitation = service.PullOver(
                    officers[i].Rank,
                    officers[i].FirstName,
                    officers[i].LastName,
                    officers[i].BadgeId,
                    officers[i].NegativeComment,
                    officers[i].PositiveComment,
                    drivers[i].FirstName,
                    drivers[i].LastName,
                    drivers[i].AddressOne,
                    drivers[i].AddressTwo,
                    drivers[i].City,
                    drivers[i].State,
                    drivers[i].Zip,
                    drivers[i].DateOfBirth,
                    drivers[i].IsImpaired
                    );

                Console.WriteLine(currentCitation.ToString());
                Console.WriteLine("");
                Console.Write("Press any key to move on...");
                Console.ReadLine();
            }

            Console.WriteLine("");
            Console.WriteLine("");
            Console.Write("Press any key to terminated execution...");
            Console.ReadLine();
        }
        public void CitationService_Add_Calls_UnitOfWork_Commit_Method()
        {
            // Create test data
            var newCitation = new Citation
                                    {
                                        Text = "Foo",
                                        Page = "Bar"
                                    };

            //Create Mock
            var mockRepository = new Mock<IRepository<Citation>>();
            _mockUnitOfWork.Setup(d => d.GetRepository<Citation>()).Returns(mockRepository.Object);

            //Arrange
            _service = new CitationService(_mockUnitOfWork.Object);

            //Act
            _service.Add(newCitation);

            //Assert
            _mockUnitOfWork.Verify(db => db.Commit());
        }
        public void CitationService_Get_ByPage_Overload_Returns_PagedList_Of_Citations()
        {
            //Arrange
            var mockRepository = new Mock<IRepository<Citation>>();
            mockRepository.Setup(r => r.Get(It.IsAny<int>())).Returns(GetCitations(TestConstants.PAGE_TotalCount));
            _mockUnitOfWork.Setup(u => u.GetRepository<Citation>()).Returns(mockRepository.Object);

            _service = new CitationService(_mockUnitOfWork.Object);
            const int treeId = TestConstants.TREE_Id;

            //Act
            var citations = _service.Get(treeId, t => true, 0, TestConstants.PAGE_RecordCount);

            //Assert
            Assert.IsInstanceOf<IPagedList<Citation>>(citations);
            Assert.AreEqual(TestConstants.PAGE_TotalCount, citations.TotalCount);
            Assert.AreEqual(TestConstants.PAGE_RecordCount, citations.PageSize);
        }
        public void CitationService_Get_ByPage_Overload_Calls_Repository_Get()
        {
            //Arrange
            var mockRepository = new Mock<IRepository<Citation>>();
            _mockUnitOfWork.Setup(u => u.GetRepository<Citation>()).Returns(mockRepository.Object);

            _service = new CitationService(_mockUnitOfWork.Object);
            const int treeId = TestConstants.TREE_Id;

            //Act
            _service.Get(treeId, t => true, 0, TestConstants.PAGE_RecordCount);

            //Assert
            mockRepository.Verify(r => r.Get(It.IsAny<int>()));
        }
        public void CitationService_Get_ByPage_Overload_Throws_On_Negative_TreeId()
        {
            //Arrange
            _service = new CitationService(_mockUnitOfWork.Object);

            //Assert
            Assert.Throws<IndexOutOfRangeException>(() => _service.Get(-1, t => true, 0, TestConstants.PAGE_RecordCount));
        }
        public void CitationService_Get_Overload_Throws_On_Negative_TreeId()
        {
            //Arrange
            _service = new CitationService(_mockUnitOfWork.Object);

            //Assert
            Assert.Throws<IndexOutOfRangeException>(() => _service.Get(-1));
        }
        public void CitationService_Get_Returns_Null_On_InValid_Id()
        {
            //Arrange
            var mockRepository = new Mock<IRepository<Citation>>();
            mockRepository.Setup(r => r.Get(It.IsAny<int>())).Returns(GetCitations(TestConstants.PAGE_TotalCount));
            _mockUnitOfWork.Setup(u => u.GetRepository<Citation>()).Returns(mockRepository.Object);

            _service = new CitationService(_mockUnitOfWork.Object);
            const int id = TestConstants.ID_NotFound;

            //Act
            var citation = _service.Get(id, It.IsAny<int>());

            //Assert
            Assert.IsNull(citation);
        }
        public void CitationService_Get_Calls_Repository_Get()
        {
            //Arrange
            var mockRepository = new Mock<IRepository<Citation>>();
            _mockUnitOfWork.Setup(u => u.GetRepository<Citation>()).Returns(mockRepository.Object);

            _service = new CitationService(_mockUnitOfWork.Object);
            const int id = TestConstants.ID_Exists;

            //Act
            _service.Get(id, It.IsAny<int>());

            //Assert
            mockRepository.Verify(r => r.Get(It.IsAny<int>()));
        }
        public void CitationService_Get_Throws_On_Negative_Id()
        {
            //Arrange
            _service = new CitationService(_mockUnitOfWork.Object);

            //Assert
            Assert.Throws<IndexOutOfRangeException>(() => _service.Get(-1, It.IsAny<int>()));
        }