public async Task GetAllIssuesAsync_Should_return_all_issues_Test()
            {
                // Arrange

                // // Create Mocked Context by Seeding Data
                await using var context = new DataContext(Options);

                await MockHelpers.CreateMockedDataContext(Options);

                RepositoryUnderTest = new IssueRepository(context);

                // Act

                var result = await RepositoryUnderTest.GetAllIssuesAsync();

                // Assert

                var enumerable = result.ToList();

                enumerable.Should().NotBeNullOrEmpty();
                var items = enumerable.ToList();

                items.Count.Should().Be(3);
                items[0].Id.Should().Be(IssueList[0].Id);
                items[1].Id.Should().Be(IssueList[1].Id);
                items[2].Id.Should().Be(IssueList[2].Id);
            }
示例#2
0
        static void Main()
        {
            ConsoleCredentials.SetPasswordFromUserInput();

            try
            {
                WriteLine("Querying JIRA. This might take several seconds...");

                var issuesForCurrentUser = new IssueRepository().GetIssuesForCurrentUser();

                Clear();

                foreach (var issue in issuesForCurrentUser)
                {
                    WriteLine($"{issue.Key} | {issue.GetHours()} hours");
                }
            }
            catch (Exception ex)
            {
                WriteLine(ex.Message);
            }

            WriteLine();
            WriteLine("Press any key...");
            ReadLine();
        }
示例#3
0
        public void OpenRevision(string revisionText)
        {
            if (string.IsNullOrEmpty(revisionText))
            {
                throw new ArgumentNullException("revisionText");
            }

            long rev;

            IssueRepository repository = CurrentIssueRepository;

            if (repository != null &&
                repository.CanNavigateToRevision &&
                long.TryParse(revisionText, out rev))
            {
                try
                {
                    repository.NavigateToRevision(rev);
                    return;
                }
                catch { } // connector code
            }

            IAnkhWebBrowser web = GetService <IAnkhWebBrowser>();

            if (web != null)
            {
                Uri uri = CommitSettings.GetRevisionUri(revisionText);
                if (uri != null && !uri.IsFile && !uri.IsUnc)
                {
                    web.Navigate(uri);
                }
            }
        }
 public UnitOfWork(ApplicationDbContext context)
 {
     _context      = context;
     _Projects     = new ProjectRepository(context);
     _Issues       = new IssueRepository(context);
     _UserProjects = new UserProjectRepository(context);
 }
示例#5
0
 static void Main(string[] args)
 {
     try
     {
        
         using (var db = new IssuesContext())
         {
             var list = new List<Issue>(); 
             using(IIssueRepository repos = new IssueRepository())
             {
                 list = repos.GetCollection<Issue>().Where(arg => arg.Title == "userstory123").ToList();
                 foreach(var iss in list)
                 {
                     repos.Remove(iss);
                 }
                 var f3123 = repos.GetCollection<Issue>();
                 var us2 = repos.GetById<Userstory>(Guid.NewGuid());
                 repos.Remove(us2);
                 repos.UpdateTitle<Userstory>(Guid.NewGuid(), "newuserstory");
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
        public void RemoveById_AddANewIncidentThenRemoveIt_ReturnTrue()
        {
            //ARRANGE
            var options = new DbContextOptionsBuilder <FacilityContext>()
                          .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name)
                          .Options;

            using var context = new FacilityContext(options);
            IIncidentRepository      incidentRepository      = new IncidentRepository(context);
            IRoomRepository          roomRepository          = new RoomRepository(context);
            IFloorRepository         floorRepository         = new FloorRepository(context);
            IComponentTypeRepository componentTypeRepository = new ComponentTypeRepository(context);
            IIssueRepository         issueRepository         = new IssueRepository(context);
            //Room(and it's floor)
            var floor = new FloorTO {
                Number = 2
            };
            var addedFloor1 = floorRepository.Add(floor);

            context.SaveChanges();
            RoomTO room = new RoomTO {
                Name = new MultiLanguageString("Room1", "Room1", "Room1"), Floor = addedFloor1
            };
            var addedRoom = roomRepository.Add(room);

            context.SaveChanges();
            //Component
            var componentType = new ComponentTypeTO {
                Archived = false, Name = new MultiLanguageString("Name1En", "Name1Fr", "Name1Nl")
            };
            var addedComponentType = componentTypeRepository.Add(componentType);

            context.SaveChanges();
            //Issue
            var issue = new IssueTO {
                Description = "prout", Name = new MultiLanguageString("Issue1EN", "Issue1FR", "Issue1NL"), ComponentType = addedComponentType
            };
            var addedIssue = issueRepository.Add(issue);

            context.SaveChanges();
            //Incident
            var incident = new IncidentTO
            {
                Description = "No coffee",
                Issue       = addedIssue,
                Status      = IncidentStatus.Waiting,
                SubmitDate  = DateTime.Now,
                UserId      = 1,
                Room        = addedRoom
            };
            var addedIncident = incidentRepository.Add(incident);

            context.SaveChanges();
            //ACT
            var result = incidentRepository.Remove(addedIncident.Id);

            context.SaveChanges();
            //ASSERT
            Assert.IsTrue(result);
        }
示例#7
0
        public void GetAllFundableIssues_returns_all_fundable_issues_from_db()
        {
            // Arrange
            Issue fundableIssue    = Mock.Of <Issue>(i => i.IsFundable == true);
            Issue nonFundableIssue = Mock.Of <Issue>(i => i.IsFundable == false);
            var   data             = new List <Issue>()
            {
                fundableIssue, fundableIssue, fundableIssue, nonFundableIssue, nonFundableIssue
            }.AsQueryable();

            var mockDbSet = new Mock <DbSet <Issue> >();

            mockDbSet.As <IQueryable <Issue> >().Setup(m => m.Provider).Returns(data.Provider);
            mockDbSet.As <IQueryable <Issue> >().Setup(m => m.Expression).Returns(data.Expression);
            mockDbSet.As <IQueryable <Issue> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockDbSet.As <IQueryable <Issue> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

            var mockContext = new Mock <ApplicationDbContext>();

            mockContext.Setup(c => c.Issues).Returns(mockDbSet.Object);

            var repo = new IssueRepository(mockContext.Object);

            // Act
            List <Issue> results = repo.GetAllFundableIssues();

            // Assert
            Assert.AreEqual(3, results.Count);
        }
示例#8
0
        // "id" is project ID
        public object Post(int id, AddIssueArgs args, IFile attachment = null)
        {
            return(ExecuteInUnitOfWork(() =>
            {
                Project p = ProjectRepository.Get(id);

                Issue i = new Issue(p, args.Title, args.Description, args.Severity);
                IssueRepository.Add(i);

                if (args.Attachment != null && attachment != null)
                {
                    using (Stream s = attachment.OpenStream())
                    {
                        byte[] content = s.ReadAllBytes();
                        Attachment att = new Attachment(i, args.Attachment.Title, args.Attachment.Description, content, attachment.ContentType.MediaType);
                        AttachmentRepository.Add(att);
                    }
                }

                Uri issueUrl = typeof(IssueResource).CreateUri(new { id = i.Id });

                return new OperationResult.Created {
                    RedirectLocation = issueUrl
                };
            }));
        }
示例#9
0
 public IssueRepositoryTests()
 {
     _request        = Substitute.For <IRequest>();
     _requestFactory = Substitute.For <IRequestFactory>();
     _requestFactory.Create(Arg.Any <string>(), Arg.Any <Method>(), Arg.Any <bool>()).Returns(_request);
     _sut = new IssueRepository(_requestFactory);
 }
示例#10
0
        public void RefreshPageContents()
        {
            Controls.Clear();

            if (IssueService != null)
            {
                IssueRepository repository = IssueService.CurrentIssueRepository;
                IWin32Window    window     = null;

                if (repository != null &&
                    (window = repository.Window) != null)
                {
                    Control control = Control.FromHandle(window.Handle);
                    if (control != null)
                    {
                        control.Dock = DockStyle.Fill;
                        Controls.Add(control);

                        if (VSVersion.SupportsTheming && Context != null)
                        {
                            IWinFormsThemingService wts = Context.GetService <IWinFormsThemingService>();

                            if (wts != null)
                            {
                                wts.ThemeRecursive(control, false);
                            }
                        }
                        return;
                    }
                }
            }
            Controls.Add(pleaseConfigureLabel);
        }
示例#11
0
        public async Task <ActionResultDto> Execute(ContextDto context)
        {
            try
            {
                init();
                validate();

                var count = 0;

                var repo = new IssueRepository(context);

                for (int i = 0; i < _listId.Count; i++)
                {
                    if (_listId[i] > 0 && await repo.Delete(_listId[i]))
                    {
                        count++;
                        InsertLuocSuAction ls = new InsertLuocSuAction();
                        ls.InsertLuocSu(context, "ListIssue", _listId[i], "Delete", 0);
                    }
                }

                return(returnActionResult(HttpStatusCode.OK, count, null));
            }
            catch (FormatException ex)
            {
                return(returnActionError(HttpStatusCode.BadRequest, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
            catch (Exception ex)
            {
                return(returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
        }
示例#12
0
        /// <summary>
        /// Passes the open request to the current issue repository if available,
        /// otherwise tries to open web browser base on project settings
        /// </summary>
        /// <param name="issueId">Issue Id</param>
        public void OpenIssue(string issueId)
        {
            if (string.IsNullOrEmpty(issueId))
            {
                throw new ArgumentNullException("issueId");
            }

            IssueRepository repository = CurrentIssueRepository;

            if (repository != null)
            {
                try
                {
                    repository.NavigateTo(issueId);
                    return;
                }
                catch { } // connector code
            }

            IAnkhWebBrowser web = GetService <IAnkhWebBrowser>();

            if (web != null)
            {
                Uri uri = CommitSettings.GetIssueTrackerUri(issueId);

                if (uri != null && !uri.IsFile && !uri.IsUnc)
                {
                    web.Navigate(uri);
                }
            }
        }
示例#13
0
        // "id" is issue ID
        public object Post(int id, AddAttachmentArgs args, IFile attachment = null)
        {
            return(ExecuteInUnitOfWork(() =>
            {
                Issue issue = IssueRepository.Get(id);
                Attachment att;
                if (attachment != null)
                {
                    using (Stream s = attachment.OpenStream())
                    {
                        byte[] content = s.ReadAllBytes();
                        att = new Attachment(issue, args.Title, args.Description, content, attachment.ContentType.MediaType);
                    }
                }
                else
                {
                    att = new Attachment(issue, args.Title, args.Description, null, null);
                }

                AttachmentRepository.Add(att);

                Uri attUrl = typeof(AttachmentResource).CreateUri(new { id = att.Id });

                return new OperationResult.Created {
                    RedirectLocation = attUrl
                };
            }));
        }
示例#14
0
        public UnitOfWork(string connectionString, string migrationAssemblyName)
        {
            _context = new LibraryContext(connectionString, migrationAssemblyName);

            bookRepository    = new BookRepository(_context);
            issueRepository   = new IssueRepository(_context);
            studentRepository = new StudentRepository(_context);
        }
示例#15
0
        private void InitParams()
        {
            _repo = new IssueRepository();

            DESCRIPTION  = "Description";
            TITLE        = "Test Data Title";
            ISSTATEISSUE = false;
        }
示例#16
0
 public object Post(int id, UpdateIssueArgs args)
 {
     return(ExecuteInUnitOfWork(() =>
     {
         Issue i = IssueRepository.Get(id);
         i.Update(args.Title, args.Description, args.Severity);
         return ReadIssueResource(id);
     }));
 }
        public void AddReturnsId()
        {
            var repository = new IssueRepository(dbFactory, personRepository);

            var response = repository.Add(new Issue());

            Assert.IsNotNull(response);
            Assert.AreEqual(response.Id, 1);
        }
示例#18
0
 public object Get(int id)
 {
     return(ExecuteInUnitOfWork(() =>
     {
         Issue i = IssueRepository.Get(id);
         List <Attachment> attachments = AttachmentRepository.AttachmentsForIssue(id);
         return ReadIssueResource(id);
     }));
 }
示例#19
0
 public object Delete(int id)
 {
     return(ExecuteInUnitOfWork(() =>
     {
         Issue i = IssueRepository.Get(id);
         IssueRepository.Delete(i);
         return new OperationResult.NoContent();
     }));
 }
        public void RemoveIssueByTransfertObject_Successfull()
        {
            var options = new DbContextOptionsBuilder <FacilityContext>()
                          .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name)
                          .Options;

            using var memoryCtx = new FacilityContext(options);
            var componentTypeRepository = new ComponentTypeRepository(memoryCtx);

            var componentType = new ComponentTypeTO
            {
                Archived = false,
                Name     = new MultiLanguageString("Name1En", "Name1Fr", "Name1Nl"),
            };
            var componentType2 = new ComponentTypeTO
            {
                Archived = false,
                Name     = new MultiLanguageString("Name2En", "Name2Fr", "Name2Nl"),
            };
            var addedComponentType1 = componentTypeRepository.Add(componentType);
            var addedComponentType2 = componentTypeRepository.Add(componentType2);

            memoryCtx.SaveChanges();

            var IssueToUseInTest = new IssueTO
            {
                Description   = "prout",
                Name          = new MultiLanguageString("Issue1EN", "Issue1FR", "Issue1NL"),
                ComponentType = addedComponentType1,
            };
            var IssueToUseInTest2 = new IssueTO
            {
                Description   = "proutprout",
                Name          = new MultiLanguageString("Issue2EN", "Issue2FR", "Issue2NL"),
                ComponentType = addedComponentType1,
            };
            var IssueToUseInTest3 = new IssueTO
            {
                Description   = "proutproutprout",
                Name          = new MultiLanguageString("Issue3EN", "Issue3FR", "Issue3NL"),
                ComponentType = addedComponentType2,
            };

            var issueRepository = new IssueRepository(memoryCtx);

            var f1 = issueRepository.Add(IssueToUseInTest);
            var f2 = issueRepository.Add(IssueToUseInTest2);

            memoryCtx.SaveChanges();
            issueRepository.Remove(f2);
            memoryCtx.SaveChanges();

            var retrievedIssues = issueRepository.GetAll();

            Assert.AreEqual(1, retrievedIssues.Count());
            Assert.IsFalse(retrievedIssues.Any(x => x.Id == 2));
        }
示例#21
0
        public void GetIssuesByComponentTypeId_ReturnCorrectNumberOfCorrespondingIssues()
        {
            //ARRANGE
            var options = new DbContextOptionsBuilder <FacilityContext>()
                          .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name)
                          .Options;

            using var context = new FacilityContext(options);

            var issueRepository         = new IssueRepository(context);
            var componentTypeRepository = new ComponentTypeRepository(context);

            var componentType = new ComponentTypeTO
            {
                Archived = false,
                Name     = new MultiLanguageString("Name1En", "Name1Fr", "Name1Nl"),
            };
            var componentType2 = new ComponentTypeTO
            {
                Archived = false,
                Name     = new MultiLanguageString("Name2En", "Name2Fr", "Name2Nl"),
            };
            var addedComponentType1 = componentTypeRepository.Add(componentType);
            var addedComponentType2 = componentTypeRepository.Add(componentType2);

            context.SaveChanges();

            IssueTO issue1 = new IssueTO
            {
                Name          = new MultiLanguageString("Issue1", "Issue1", "Issue1"),
                ComponentType = addedComponentType1,
                Description   = "prout",
            };
            IssueTO issue2 = new IssueTO
            {
                Name          = new MultiLanguageString("Issue2", "Issue2", "Issue2"),
                ComponentType = addedComponentType1,
                Description   = "proutprout",
            };
            IssueTO issue3 = new IssueTO
            {
                Name          = new MultiLanguageString("Issue3", "Issue3", "Issue3"),
                ComponentType = addedComponentType2,
                Description   = "proutproutprout",
            };

            issueRepository.Add(issue1);
            issueRepository.Add(issue2);
            issueRepository.Add(issue3);
            context.SaveChanges();

            var retrievedIssues = issueRepository.GetIssuesByComponentType(addedComponentType1.Id);

            Assert.IsNotNull(retrievedIssues);
            Assert.AreEqual(2, retrievedIssues.Count);
        }
        public ContextViewModel(IssueRepository allissues, User user)
        {
            _allissues = allissues;
            User = user;
            Issues = new ThreadSafeObservableCollection<IssueViewModel>();

            _allissues
                .Where(x => x.Repo.Owner.Login == user.Username)
                .Subscribe(CheckInternal);
        }
        public void RemoveIssueByTransfertObject_ThrowException_WhenNullIsSupplied()
        {
            var options = new DbContextOptionsBuilder <FacilityContext>()
                          .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name)
                          .Options;

            using var memoryCtx = new FacilityContext(options);
            var issueRepository = new IssueRepository(memoryCtx);

            Assert.ThrowsException <ArgumentNullException>(() => issueRepository.Remove(null));
        }
        public async Task IssueRepository_GetAllAsync_ReturnsAllValues()
        {
            await using var context = new TimeTrackingDbContext(_dbOptions);
            var issueRepository = new IssueRepository(context);
            var expected        = IssuesDbSet.Get();

            var actual = await issueRepository.GetAllAsync();

            Assert.That(actual.OrderBy(e => e.Id), Is.EqualTo(expected.OrderBy(e => e.Id))
                        .Using(EqualityComparers.IssueComparer));
        }
示例#25
0
        public HttpResponseMessage Get(int id)
        {
            var repo   = new IssueRepository();
            var entity = repo.Get(id);

            var json = JsonConvert.SerializeObject(entity);

            return(new HttpResponseMessage {
                Content = new StringContent(json, Encoding.UTF8, "application/json")
            });
        }
示例#26
0
        private object ReadIssueResource(int id)
        {
            Issue             i           = IssueRepository.Get(id);
            List <Attachment> attachments = AttachmentRepository.AttachmentsForIssue(id);

            return(new IssueResource
            {
                Issue = i,
                Attachments = attachments
            });
        }
        public async Task IssueRepository_UpdateAsync_UpdateEntity()
        {
            await using var context = new TimeTrackingDbContext(_dbOptions);
            var issueRepository = new IssueRepository(context);
            var entityToUpdate  = IssuesDbSet.Get().First();

            entityToUpdate.Title = "New title";

            var actual = await issueRepository.UpdateAsync(entityToUpdate);

            Assert.That(actual, Is.EqualTo(entityToUpdate).Using(EqualityComparers.IssueComparer));
        }
        public async Task IssueRepository_GetById_ShouldReturnCorrectItem(string id)
        {
            var guidId = Guid.Parse(id);

            await using var context = new TimeTrackingDbContext(_dbOptions);
            var expected        = IssuesDbSet.Get().First(x => x.Id == guidId);
            var issueRepository = new IssueRepository(context);

            var issue = await issueRepository.GetByIdAsync(guidId);

            Assert.That(issue, Is.EqualTo(expected).Using(EqualityComparers.IssueComparer));
        }
示例#29
0
        public void GetAllVotableIssuesSortedByDate_returns_empty_if_no_issues_are_found()
        {
            // Arrange
            IssueRepository mockRepo =
                Mock.Of <IssueRepository>(r => r.GetAllVotableIssues() == new List <Issue>());

            // Act
            var result = mockRepo.GetAllVotableIssuesSortedByDate();

            // Assert
            Assert.IsTrue(result.Count == 0);
        }
        //injected product repo
        //injected issue repo

        public void DoIt()
        {
            var observer = new Observer(); //get via identity
            var product  = new ProductRepository().Get(new ProductId(Guid.NewGuid()));

            var newIssue = product.CreateNewIssue(observer);

            newIssue.SetTitle("New issue");

            var issueRepo = new IssueRepository();

            issueRepo.Save(newIssue);
        }
        public void GetIssueById_ThrowsException_WhenInvalidIdIsProvided()
        {
            var options = new DbContextOptionsBuilder <FacilityContext>()
                          .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name)
                          .Options;

            using (var memoryCtx = new FacilityContext(options))
            {
                var issueRepository = new IssueRepository(memoryCtx);

                Assert.ThrowsException <NullIssueException>(() => issueRepository.GetById(84));
            }
        }
示例#32
0
 // "id" is issue ID
 public object Get(int id)
 {
     return(ExecuteInUnitOfWork(() =>
     {
         Issue issue = IssueRepository.Get(id);
         List <Attachment> attachments = AttachmentRepository.AttachmentsForIssue(id);
         return new IssueAttachmentsResource
         {
             Issue = issue,
             Attachments = attachments
         };
     }));
 }
示例#33
0
 // "id" is project ID
 public object Get(int id)
 {
     return(ExecuteInUnitOfWork(() =>
     {
         Project project = ProjectRepository.Get(id);
         List <Issue> issues = IssueRepository.IssuesForProject(id);
         return new ProjectIssuesResource
         {
             Project = project,
             Issues = issues
         };
     }));
 }
        public void AddPersists()
        {
            var repository = new IssueRepository(dbFactory, personRepository);

            repository.Add(new Issue { Title = "Test Item" });

            dbFactory.Run(db =>
                              {
                                  var response = db.Select<Issue>();

                                  Assert.AreEqual(response.Count, 1);
                                  Assert.AreEqual(response[0].Title, "Test Item");
                              });
        }
        public void DeleteFails()
        {
            dbFactory.Run(db => db.Insert(new Issue { Id = 1, Title = "Test Item" }));

            var repository = new IssueRepository(dbFactory, personRepository);

            repository.Delete(2);
            dbFactory.Run(db =>
                              {
                                  var response = db.Select<Issue>();

                                  Assert.AreEqual(response.Count, 1);
                                  Assert.AreEqual(response[0].Title, "Test Item");
                              });
        }
        public void GetAllReturnsEmpty()
        {
            var repository = new IssueRepository(dbFactory, personRepository);

            var response = repository.GetAll();

            Assert.IsNotNull(response);
            Assert.AreEqual(response.Count, 0);
        }
        public void GetByIdReturnsNull()
        {
            dbFactory.Run(db => db.Insert(new Issue { Id = 1, Title = "Test Item" }));

            var repository = new IssueRepository(dbFactory, personRepository);

            var response = repository.GetById(2);

            Assert.IsNull(response);
        }
        public void UpdateIsSingular()
        {
            dbFactory.Run(db =>
                              {
                                  db.Insert(new Issue { Id = 1, Title = "Test Item" });
                                  db.Insert(new Issue { Id = 2, Title = "Test Item 2" });
                              });

            var repository = new IssueRepository(dbFactory, personRepository);

            repository.Update(new Issue { Id = 1, Title = "Test Edit" });

            dbFactory.Run(db =>
                              {
                                  var response = db.Select<Issue>();

                                  Assert.AreEqual(response.Count, 2);
                                  Assert.AreEqual(response.Single(x => x.Id == 1).Title, "Test Edit");
                                  Assert.AreEqual(response.Single(x => x.Id == 2).Title, "Test Item 2");
                              });
        }
 public OverviewViewModel(IssueRepository issues, PullRequestRepository pullRequest)
 {
     Issues = issues;
     PullRequests = pullRequest;
     Contexts = new ObservableCollection<ContextViewModel>();
 }
        public void GetAllReturnsItems()
        {
            dbFactory.Run(db =>
                              {
                                  db.Insert(new Issue { Id = 1, Title = "Test Item" });
                                  db.Insert(new Issue { Id = 2, Title = "Test Item 2" });
                              });

            var repository = new IssueRepository(dbFactory, personRepository);

            var response = repository.GetAll();

            Assert.IsNotNull(response);
            Assert.AreEqual(response.Count, 2);
            Assert.AreEqual(response.Single(x => x.Id == 1).Title, "Test Item");
            Assert.AreEqual(response.Single(x => x.Id == 2).Title, "Test Item 2");
        }
        public void InitTests()
        {
            dbFactory = new OrmLiteConnectionFactory(":memory:", false, SqliteOrmLiteDialectProvider.Instance);
            dbFactory.Run(db => db.CreateTable<Comment>());

            var users = new InMemoryAuthRepository();

            personRepository = new PersonRepository(users, null);
            issueRepository = new IssueRepository(dbFactory, personRepository);

            // TODO add issues
        }