Ejemplo n.º 1
0
        public void MultipleIdTest()
        {
            List <long> ids = BaseDbService.NewListIntID(2);

            Assert.IsNotNull(ids);
            Assert.AreEqual(2, ids.Count);
        }
Ejemplo n.º 2
0
        private static AvrTreeElement CreateFolderItem(long?parentId, string defaultName, string nationalName)
        {
            var item = new AvrTreeElement(BaseDbService.NewIntID(), parentId, null, AvrTreeElementType.Folder, m_TestQueryId, defaultName,
                                          nationalName, string.Empty, false);

            return(item);
        }
Ejemplo n.º 3
0
        public void UpdateElement_Valid()
        {
            var dbContext = new Mock <IDbContext>();
            var logger    = new Mock <ILogger <BaseDbService <Recipe> > >();

            BaseDbService <Recipe> recipe = new BaseDbService <Recipe>(dbContext.Object, logger.Object);

            var result = recipe.UpdateElement(new Recipe());

            dbContext.Verify(c => c.Update(It.IsAny <Recipe>()), Times.Once);
            dbContext.Verify(c => c.SaveChanges(), Times.Once);
            logger.Verify(l => l.Log(It.IsAny <LogLevel>(), It.IsAny <EventId>(), It.IsAny <FormattedLogValues>(), It.IsAny <Exception>(), It.IsAny <Func <object, Exception, string> >()), Times.Never);
            Assert.NotNull(result);
        }
Ejemplo n.º 4
0
        public void CreateElement_SaveChanges_Throw_Exception()
        {
            var dbContext = new Mock <IDbContext>();

            dbContext.Setup(d => d.SaveChanges()).Throws(new Exception());

            var logger = new Mock <ILogger <BaseDbService <Recipe> > >();

            BaseDbService <Recipe> recipe = new BaseDbService <Recipe>(dbContext.Object, logger.Object);

            var result = recipe.CreateElement(new Recipe());

            dbContext.Verify(a => a.Add(It.IsAny <Recipe>()), Times.Once);
            dbContext.Verify(a => a.SaveChanges(), Times.Once);
            logger.Verify(l => l.Log(It.IsAny <LogLevel>(), It.IsAny <EventId>(), It.IsAny <FormattedLogValues>(), It.IsAny <Exception>(), It.IsAny <Func <object, Exception, string> >()), Times.Once);
            Assert.Null(result);
        }
Ejemplo n.º 5
0
 private long NewId()
 {
     return(BaseDbService.NewIntID());
 }