Ejemplo n.º 1
0
        public async Task Update_AssigneeIdIsSet_AddsAssigneeIdParameter()
        {
            const uint expected = 0;

            await _sut.Update(0, 0, assigneeId : expected);

            _request.Received().AddParameterIfNotNull("assignee_id", expected);
        }
        public void UpdateIssueByTransfertObject_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();
                f2.Description = "PASProut";
                issueRepository.Update(f2);

                Assert.AreEqual(2, issueRepository.GetAll().Count());
                Assert.AreEqual("PASProut", f2.Description);
            }
        }
Ejemplo n.º 3
0
        private void Update(int id)
        {
            // Arrange
            Issue  issue    = _repo.Find(id);
            String newTitle = "New Testing Title";

            issue.Title = newTitle;

            // Act
            _repo.Update(issue);
            Issue newIssue = _repo.Find(id);

            // Assert
            Assert.AreEqual(newTitle, issue.Title, "Title was not updated properly");
        }
Ejemplo n.º 4
0
 public Issue UpdateIssue(int issueId, [FromBody] Issue issue)
 {
     try
     {
         if (issue == null || issue.Id != issueId)
         {
             throw new Exception("Invalid issue");
         }
         _issueRepository.Update(issue);
         return(issue);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
        public void UpdateIssueByTransfertObject_ThrowException_WhenUnexistingIssueIsSupplied()
        {
            //ARRANGE
            var options = new DbContextOptionsBuilder <FacilityContext>()
                          .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name)
                          .Options;

            using var memoryCtx = new FacilityContext(options);
            var issueRepository = new IssueRepository(memoryCtx);
            var issue           = new IssueTO {
                Id = 999
            };

            //ACT & ASSERT
            Assert.ThrowsException <LoggedException>(() => issueRepository.Update(issue));
        }
Ejemplo n.º 6
0
        static void Main()
        {
            Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
            using (var context = new DatabaseContext())
            {
                IRepository <Issue> repository = new IssueRepository(context);

                var date  = DateTime.Now;
                var issue = new Issue
                {
                    CreatedOn  = date,
                    ModifiedOn = date,
                    Title      = "TestTitle1",
                    Notes      = "TestNotes1"
                };

                repository.Create(issue);

                var issues = repository.Get(1).ToList();

                foreach (var entity in issues)
                {
                    Console.WriteLine($"{entity.Notes} {entity.ModifiedOn} {entity.CreatedOn}");
                }

                var savedIssue = repository.Get(1).FirstOrDefault();

                if (savedIssue != null)
                {
                    Console.WriteLine($"{savedIssue.Notes} {savedIssue.ModifiedOn}");
                    savedIssue.Notes = "UpdatedNotes";
                    repository.Update(savedIssue);
                }

                var updatedIssue = repository.Get(savedIssue.Id).FirstOrDefault();


                if (updatedIssue != null)
                {
                    Console.WriteLine($"{updatedIssue.Notes} {updatedIssue.ModifiedOn}");
                }

                Console.ReadKey();
            }
        }
        public void UpdatePersists()
        {
            dbFactory.Run(db => db.Insert(new Issue { Id = 1, Title = "Test Item" }));

            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, 1);
                                  Assert.AreEqual(response[0].Title, "Test Edit");
                              });
        }
        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");
                              });
        }