Beispiel #1
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 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));
            }
        }
        public void AddIssue_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 addedComponentType1 = componentTypeRepository.Add(componentType);
                memoryCtx.SaveChanges();

                var IssueToUseInTest = new IssueTO
                {
                    Description   = "prout",
                    Name          = new MultiLanguageString("Issue1EN", "Issue1FR", "Issue1NL"),
                    ComponentType = addedComponentType1,
                };

                var issueRepository = new IssueRepository(memoryCtx);

                issueRepository.Add(IssueToUseInTest);
                memoryCtx.SaveChanges();

                Assert.AreEqual(1, issueRepository.GetAll().Count());
                var IssueToAssert = issueRepository.GetById(1);
                Assert.AreEqual(1, IssueToAssert.Id);
                Assert.AreEqual("prout", IssueToAssert.Description);
            }
        }
        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);
        }