public void RemoveScreenShot()
        {
            try
            {
                var options = CreateNewContextOptions(); using (var db = new PortfolioContext(options))
                {
                    var repository = new PortfolioRepository(db);
                    WorkTestHelper.PopulateDefaultDataPortfolioCtx(db);
                    var item = GenerateModel();
                    Assert.DoesNotThrow(() => repository.Save(item));

                    var portfolioVideo = new PortfolioScreenshot
                    {
                        Screenshot  = GenerateAttachment(),
                        Description = "myNew Video"
                    };
                    Assert.DoesNotThrow(() => repository.AddScreenshot(item, portfolioVideo));
                    Assert.DoesNotThrow(() => repository.RemoveScreenshot(item, portfolioVideo));
                }
            }
            catch (Exception ex)
            {
                LogEventManager.Logger.Error(ex);
                throw;
            }
        }
 public void GetPortfolioScreenshots()
 {
     try
     {
         var options = CreateNewContextOptions(); using (var db = new PortfolioContext(options))
         {
             var repository = new PortfolioRepository(db);
             WorkTestHelper.PopulateDefaultDataPortfolioCtx(db);
             var item = GenerateModel();
             Assert.DoesNotThrow(() => repository.Save(item));
             var portfolioVideo = new PortfolioScreenshot
             {
                 Screenshot  = GenerateAttachment(),
                 Description = "myNew Video"
             };
             IEnumerable <PortfolioScreenshot> result = null;
             Assert.DoesNotThrow(() => result = repository.GetPortfolioScreenshots(item.Id));
             Assert.True(result == null || !result.Any());
             Assert.DoesNotThrow(() => repository.AddScreenshot(item, portfolioVideo));
             Assert.DoesNotThrow(() => repository.AddScreenshot(item, new PortfolioScreenshot
             {
                 Screenshot  = GenerateAttachment(),
                 Description = "myNew Video"
             }));
             Assert.DoesNotThrow(() => result = repository.GetPortfolioScreenshots(item.Id));
             Assert.NotNull(result);
             Assert.True(result.Count() == 2);
         }
     }
     catch (Exception ex)
     {
         LogEventManager.Logger.Error(ex);
         throw;
     }
 }
        public void Get_Portfolio()
        {
            try
            {
                var options = CreateNewContextOptions(); using (var db = new PortfolioContext(options))
                {
                    var repository = new PortfolioRepository(db);
                    WorkTestHelper.PopulateDefaultDataPortfolioCtx(db);
                    var item  = GenerateModel();
                    var item2 = GenerateModel();
                    item2.UserId = 2;
                    item2.Code   = "code2";
                    IEnumerable <PortfolioItem> result = null;
                    Assert.DoesNotThrow(() => repository.Save(item));
                    Assert.DoesNotThrow(() => repository.Save(item2));
                    Assert.DoesNotThrow(() => result = repository.Get(new PortfolioFilter
                    {
                        UserId = 1
                    }));
                    Assert.NotNull(result);
                    Assert.True(result.Count() == 1);
                    Assert.DoesNotThrow(() => result = repository.Get(new PortfolioFilter
                    {
                        UserId          = 1,
                        FinishDateStart = DateTime.Now.AddDays(-1),
                        FinishDateEnd   = DateTime.Now
                    }));
                    Assert.NotNull(result);
                    Assert.True(result.Count() == 1);
                    Assert.DoesNotThrow(() => result = repository.Get(new PortfolioFilter
                    {
                        UserId          = 1,
                        FinishDateStart = DateTime.Now.AddDays(-1),
                    }));
                    Assert.NotNull(result);
                    Assert.True(result.Count() == 1);

                    Assert.DoesNotThrow(() => result = repository.Get(new PortfolioFilter
                    {
                        UserId        = 1,
                        FinishDateEnd = DateTime.Now.AddDays(1),
                    }));
                    Assert.NotNull(result);
                    Assert.True(result.Count() == 1);
                }
            }
            catch (Exception ex)
            {
                LogEventManager.Logger.Error(ex);
                throw;
            }
        }
 public void Delete()
 {
     try
     {
         var options = CreateNewContextOptions(); using (var db = new PortfolioContext(options))
         {
             var repository = new PortfolioRepository(db);
             WorkTestHelper.PopulateDefaultDataPortfolioCtx(db);
             var item = GenerateModel();
             Assert.DoesNotThrow(() => repository.Save(item));
             Assert.DoesNotThrow(() => repository.Delete(item));
         }
     }
     catch (Exception ex)
     {
         LogEventManager.Logger.Error(ex);
         throw;
     }
 }