Ejemplo n.º 1
0
        public void UpdateSetting()
        {
            var logger = new Mock <ILogger <RoleClaimRepository> >();

            var options = new DbContextOptionsBuilder <CacidbContext>().UseInMemoryDatabase(databaseName: "CACIDB").Options;

            context.Database.EnsureDeleted();

            using (var dbContext = new CacidbContext(options))
            {
                dbContext.RoleClaim.Add(new RoleClaim {
                    RoleClaimId = 1
                });
                dbContext.SaveChanges();
            }

            using (var dbContext = new CacidbContext(options))
            {
                RoleClaimRepository repository = new RoleClaimRepository(dbContext, logger.Object);
                // test Get By AppSettingName
                bool result = repository.Update(new RoleClaim {
                    RoleClaimId = 1
                });
                Assert.AreEqual(true, result);

                Assert.AreEqual(1, dbContext.RoleClaim.ToList()[0].RoleClaimId);
            }
        }
Ejemplo n.º 2
0
        public void RemoveSetting()
        {
            var logger  = new Mock <ILogger <RoleClaimRepository> >();
            var options = new DbContextOptionsBuilder <CacidbContext>().UseInMemoryDatabase(databaseName: "CACIDB").Options;

            context.Database.EnsureDeleted();

            using (var dbContext = new CacidbContext(options))
            {
                dbContext.RoleClaim.Add(new RoleClaim {
                    RoleClaimId = 1
                });
                dbContext.SaveChanges();
            }

            using (var dbContext = new CacidbContext(options))
            {
                RoleClaimRepository repository = new RoleClaimRepository(dbContext, logger.Object);
                var  caseOne = repository.Get().ToList().Where(m => m.RoleClaimId == 1).FirstOrDefault();
                bool result  = repository.Delete(caseOne);
                Assert.AreEqual(true, result);

                List <RoleClaim> cases = repository.Get().ToList();
                Assert.AreEqual(0, cases.Count);
            }
        }
Ejemplo n.º 3
0
        public void AddUser()
        {
            var logger = new Mock <ILogger <UserRepository> >();

            var options = new DbContextOptionsBuilder <CacidbContext>().UseInMemoryDatabase(databaseName: "CACIDB").Options;

            context.Database.EnsureDeleted();

            using (var dbContext = new CacidbContext(options))
            {
                dbContext.User.Add(new User {
                    UserId = 1, UserName = "******", Password = "******", FirstName = "first0", LastName = "last0", CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now
                });
                dbContext.SaveChanges();
            }

            using (var dbContext = new CacidbContext(options))
            {
                UserRepository repository = new UserRepository(dbContext, logger.Object);
                // test Get By AppSettingName
                bool result = repository.Add(new User {
                    UserId = 2, UserName = "******", Password = "******", FirstName = "first1", LastName = "last1", CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now
                });
                Assert.AreEqual(true, result);

                Assert.AreEqual(2, dbContext.User.ToList()[1].UserId);
                Assert.AreEqual("first1", dbContext.User.ToList()[1].FirstName);
                Assert.AreEqual("last1", dbContext.User.ToList()[1].LastName);
            }
        }
Ejemplo n.º 4
0
        public RoleClaimRepositoryTest()
        {
            var options = new DbContextOptionsBuilder <CacidbContext>()
                          .UseInMemoryDatabase(databaseName: "CACIDB")
                          .Options;

            context = new CacidbContext(options);

            context.Database.EnsureDeleted();
            context.RoleClaim.Add(new RoleClaim {
                RoleClaimId  = 1,
                CreatedDate  = DateTime.Now,
                CreatedUser  = "******",
                ModifiedDate = DateTime.Now,
                ModifiedUser = "******",
            });
            context.RoleClaim.Add(new RoleClaim {
                RoleClaimId = 2
            });
            context.RoleClaim.Add(new RoleClaim {
                RoleClaimId = 3
            });

            context.SaveChanges();
        }
Ejemplo n.º 5
0
        public void UpdateSetting()
        {
            var options = new DbContextOptionsBuilder <CacidbContext>().UseInMemoryDatabase(databaseName: "CACIDB").Options;

            context.Database.EnsureDeleted();

            using (var dbContext = new CacidbContext(options))
            {
                dbContext.UserRole.Add(new UserRole {
                    UserRoleId = 1
                });
                dbContext.SaveChanges();
            }

            using (var dbContext = new CacidbContext(options))
            {
                UserRoleRepository repository = new UserRoleRepository(dbContext);
                // test Get By AppSettingName
                bool result = repository.Update(new UserRole {
                    UserRoleId = 1
                });
                Assert.AreEqual(true, result);

                Assert.AreEqual(1, dbContext.UserRole.ToList()[0].UserRoleId);
            }
        }
Ejemplo n.º 6
0
        public void RemoveUserById()
        {
            var logger  = new Mock <ILogger <UserRepository> >();
            var options = new DbContextOptionsBuilder <CacidbContext>().UseInMemoryDatabase(databaseName: "CACIDB").Options;

            context.Database.EnsureDeleted();

            using (var dbContext = new CacidbContext(options))
            {
                dbContext.User.Add(new User {
                    UserId = 1, UserName = "******", Password = "******", FirstName = "first0", LastName = "last0", CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now
                });
                dbContext.SaveChanges();
            }

            using (var dbContext = new CacidbContext(options))
            {
                UserRepository repository = new UserRepository(dbContext, logger.Object);
                bool           result     = repository.Delete(1);
                Assert.AreEqual(true, result);

                List <User> users = repository.Get().ToList();
                Assert.AreEqual(0, users.Count);
            }
        }
Ejemplo n.º 7
0
        public void UpdateSetting()
        {
            var logger = new Mock <ILogger <CasesRepository> >();

            var options = new DbContextOptionsBuilder <CacidbContext>().UseInMemoryDatabase(databaseName: "CACIDB").Options;

            context.Database.EnsureDeleted();

            using (var dbContext = new CacidbContext(options))
            {
                dbContext.Case.Add(new Case {
                    CaseId = 1, LastModifiedDate = DateTime.Now, CreatedDate = DateTime.Now, Title = "title 0", Description = "test 0"
                });
                dbContext.SaveChanges();
            }

            using (var dbContext = new CacidbContext(options))
            {
                CasesRepository repository = new CasesRepository(dbContext, logger.Object);
                // test Get By AppSettingName
                bool result = repository.UpdateCase(new Case {
                    CaseId = 1, LastModifiedDate = DateTime.Now, CreatedDate = DateTime.Now, Title = "title 22", Description = "test 22"
                });
                Assert.AreEqual(true, result);

                Assert.AreEqual(1, dbContext.Case.ToList()[0].CaseId);
                Assert.AreEqual("title 22", dbContext.Case.ToList()[0].Title);
                Assert.AreEqual("test 22", dbContext.Case.ToList()[0].Description);
            }
        }
Ejemplo n.º 8
0
        public void RemoveSetting()
        {
            var logger  = new Mock <ILogger <CasesRepository> >();
            var options = new DbContextOptionsBuilder <CacidbContext>().UseInMemoryDatabase(databaseName: "CACIDB").Options;

            context.Database.EnsureDeleted();

            using (var dbContext = new CacidbContext(options))
            {
                dbContext.Case.Add(new Case {
                    CaseId = 1, LastModifiedDate = DateTime.Now, CreatedDate = DateTime.Now, Title = "title 0", Description = "test 0"
                });
                dbContext.SaveChanges();
            }

            using (var dbContext = new CacidbContext(options))
            {
                CasesRepository repository = new CasesRepository(dbContext, logger.Object);
                var             caseOne    = repository.GetCases().ToList().Where(m => m.CaseId == 1).FirstOrDefault();
                bool            result     = repository.DeleteCase(caseOne);
                Assert.AreEqual(true, result);

                List <Case> cases = repository.GetCases().ToList();
                Assert.AreEqual(0, cases.Count);
            }
        }
Ejemplo n.º 9
0
        public void RemoveSettingById()
        {
            var options = new DbContextOptionsBuilder <CacidbContext>().UseInMemoryDatabase(databaseName: "CACIDB").Options;

            context.Database.EnsureDeleted();

            using (var dbContext = new CacidbContext(options))
            {
                dbContext.Role.Add(new Role {
                    RoleId = 1
                });
                dbContext.SaveChanges();
            }

            using (var dbContext = new CacidbContext(options))
            {
                RoleRepository repository = new RoleRepository(dbContext);
                // test Get By AppSettingName
                bool result = repository.Delete(1);
                Assert.AreEqual(true, result);

                List <Role> cases = repository.Get().ToList();
                Assert.AreEqual(0, cases.Count);
            }
        }
Ejemplo n.º 10
0
        public CasesRepositoryTest()
        {
            var options = new DbContextOptionsBuilder <CacidbContext>()
                          .UseInMemoryDatabase(databaseName: "CACIDB")
                          .Options;

            context = new CacidbContext(options);

            context.Database.EnsureDeleted();
            context.Case.Add(new Case {
                CaseId           = 1,
                StatusId         = 1,
                LastModifiedDate = DateTime.Now,
                CreatedDate      = DateTime.Now,
                Title            = "title 0",
                Description      = "test 0"
            });
            context.Case.Add(new Case {
                CaseId = 2, Title = "title 1", Description = "test 1", StatusId = 2, CreatedDate = DateTime.Now, LastModifiedDate = DateTime.Now
            });
            context.Case.Add(new Case {
                CaseId = 3, Title = "title 2", Description = "test 2", StatusId = 3, CreatedDate = DateTime.Now, LastModifiedDate = DateTime.Now
            });

            context.SaveChanges();
        }
Ejemplo n.º 11
0
        public void RemoveSettingById()
        {
            var logger  = new Mock <ILogger <ClaimsRespository> >();
            var options = new DbContextOptionsBuilder <CacidbContext>().UseInMemoryDatabase(databaseName: "CACIDB").Options;

            context.Database.EnsureDeleted();

            using (var dbContext = new CacidbContext(options))
            {
                dbContext.Claim.Add(new Claim {
                    ClaimId = 1, Title = "", Description = ""
                });
                dbContext.SaveChanges();
            }

            using (var dbContext = new CacidbContext(options))
            {
                ClaimsRespository repository = new ClaimsRespository(dbContext, logger.Object);
                // test Get By AppSettingName
                bool result = repository.DeleteClaimById(1);
                Assert.AreEqual(true, result);

                List <Claim> claim = repository.GetClaims(new Claim {
                    ClaimId = 1, Title = "", Description = ""
                }).ToList();
                Assert.AreEqual(0, claim.Count);
            }
        }
Ejemplo n.º 12
0
        public void RemoveSetting()
        {
            var options = new DbContextOptionsBuilder <CacidbContext>().UseInMemoryDatabase(databaseName: "CACIDB").Options;

            context.Database.EnsureDeleted();

            using (var dbContext = new CacidbContext(options))
            {
                dbContext.UserRole.Add(new UserRole {
                    UserRoleId = 1
                });
                dbContext.SaveChanges();
            }

            using (var dbContext = new CacidbContext(options))
            {
                UserRoleRepository repository = new UserRoleRepository(dbContext);
                var  caseOne = repository.Get().FirstOrDefault(m => m.UserRoleId == 1);
                bool result  = repository.Delete(caseOne);
                Assert.AreEqual(true, result);

                List <UserRole> cases = repository.Get().ToList();
                Assert.AreEqual(0, cases.Count);
            }
        }
Ejemplo n.º 13
0
        public void RemoveSetting()
        {
            var logger  = new Mock <ILogger <SettingsRepository> >();
            var options = new DbContextOptionsBuilder <CacidbContext>().UseInMemoryDatabase(databaseName: "CACIDB").Options;

            context.Database.EnsureDeleted();

            using (var dbContext = new CacidbContext(options))
            {
                dbContext.AppSettings.Add(new AppSettings {
                    AppSettingId = 1, AppSettingName = "SMTP", AppSettingValue = "127.0.0.1"
                });
                dbContext.SaveChanges();
            }

            using (var dbContext = new CacidbContext(options))
            {
                SettingsRepository repository = new SettingsRepository(dbContext, logger.Object);
                // test Get By AppSettingName
                bool result = repository.RemoveSetting(new AppSettings {
                    AppSettingId = 1, AppSettingName = "SMTP", AppSettingValue = "127.0.0.1"
                });
                Assert.AreEqual(true, result);

                AppSettings setting = repository.GetSettingById(1);
                Assert.AreEqual(null, setting);
            }
        }
Ejemplo n.º 14
0
        public UserRepositoryTest()
        {
            var options = new DbContextOptionsBuilder <CacidbContext>()
                          .UseInMemoryDatabase(databaseName: "CACIDB")
                          .Options;

            context = new CacidbContext(options);

            context.Database.EnsureDeleted();
            context.User.Add(new User {
                UserId       = 1,
                UserName     = "******",
                Email        = "*****@*****.**",
                Password     = "******",
                FirstName    = "first0",
                MiddleName   = "L",
                LastName     = "last0",
                IsActive     = true,
                IsApproved   = true,
                CreatedDate  = DateTime.Now,
                CreatedUser  = "******",
                ModifiedDate = DateTime.Now,
                ModifiedUser = "******"
            });
            context.User.Add(new User {
                UserId = 2, UserName = "******", Email = "*****@*****.**", Password = "******", FirstName = "first1", LastName = "last1", CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now
            });
            context.User.Add(new User {
                UserId = 3, UserName = "******", Email = "*****@*****.**", Password = "******", FirstName = "first2", LastName = "last2", CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now
            });

            context.SaveChanges();
        }
Ejemplo n.º 15
0
        public ClaimsRepositoryTest()
        {
            var options = new DbContextOptionsBuilder <CacidbContext>()
                          .UseInMemoryDatabase(databaseName: "CACIDB")
                          .Options;

            context = new CacidbContext(options);

            context.Database.EnsureDeleted();
            context.Claim.Add(new Claim {
                ClaimId = 1, Title = "title 0", Description = "test 0", ClaimCode = "Test Code 0"
            });
            context.Claim.Add(new Claim {
                ClaimId = 2, Title = "title 1", Description = "test 1", ClaimCode = "Test Code 1"
            });
            context.Claim.Add(new Claim {
                ClaimId = 3, Title = "title 2", Description = "test 2", ClaimCode = "Test Code 2"
            });

            context.SaveChanges();
        }
Ejemplo n.º 16
0
        public ATemplateRepositoryTest()
        {
            var options = new DbContextOptionsBuilder <CacidbContext>()
                          .UseInMemoryDatabase(databaseName: "CACIDB")
                          .Options;

            context = new CacidbContext(options);

            context.Database.EnsureDeleted();
            context.ATemplate.Add(new ATemplate {
                Id = 1
            });
            context.ATemplate.Add(new ATemplate {
                Id = 2
            });
            context.ATemplate.Add(new ATemplate {
                Id = 3
            });

            context.SaveChanges();
        }
Ejemplo n.º 17
0
        public void SetUp()
        {
            var options = new DbContextOptionsBuilder <CacidbContext>()
                          .UseInMemoryDatabase(databaseName: "CACIDB")
                          .Options;

            context = new CacidbContext(options);

            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            context.AppSettings.Add(new AppSettings {
                AppSettingId = 1, AppSettingName = "SMTP", AppSettingValue = "127.0.0.1"
            });
            context.AppSettings.Add(new AppSettings {
                AppSettingId = 2, AppSettingName = "SMTP1", AppSettingValue = "127.1.1.1"
            });
            context.AppSettings.Add(new AppSettings {
                AppSettingId = 3, AppSettingName = "SMTP2", AppSettingValue = "127.2.2.2"
            });
            context.Database.AutoTransactionsEnabled = false;
            context.SaveChanges();
        }
Ejemplo n.º 18
0
        public ApplicationRepositoryTest()
        {
            var options = new DbContextOptionsBuilder <CacidbContext>()
                          .UseInMemoryDatabase(databaseName: "CACIDB")
                          .Options;

            context = new CacidbContext(options);

            context.Database.EnsureDeleted();
            context.Application.Add(new Application
            {
                ApplicationId   = 1,
                ApplicationName = "Test App 1",
                StatusId        = 1,
                SystemOwner     = "Fred Sanford",
                IMatrixNumber   = "2",
                PhaseId         = 2,
                POC             = "Lamont Sanford",
                IsActive        = true,
                IsApproved      = true,
                CreatedDate     = DateTime.Now,
                CreatedUser     = "******",
                ModifiedDate    = DateTime.Now,
                ModifiedUser    = "******",
                Expiration      = DateTime.Now.AddYears(3),
                Icon            = "testing"
            });
            context.Application.Add(new Application
            {
                ApplicationId   = 2,
                ApplicationName = "Test App 2",
                StatusId        = 1,
                SystemOwner     = "Billy Bob",
                IMatrixNumber   = "2",
                PhaseId         = 2,
                POC             = "Joe Bob",
                IsActive        = true,
                IsApproved      = true,
                CreatedDate     = DateTime.Now,
                CreatedUser     = "******",
                ModifiedDate    = DateTime.Now,
                ModifiedUser    = "******",
                Expiration      = DateTime.Now.AddYears(-2),
                Icon            = "testing"
            });
            context.Application.Add(new Application
            {
                ApplicationId   = 3,
                ApplicationName = "Test App 3",
                StatusId        = 1,
                SystemOwner     = "Stan Lee",
                IMatrixNumber   = "2",
                PhaseId         = 2,
                POC             = "Loretta Chow",
                IsActive        = true,
                IsApproved      = true,
                CreatedDate     = DateTime.Now,
                CreatedUser     = "******",
                ModifiedDate    = DateTime.Now,
                ModifiedUser    = "******",
                Expiration      = DateTime.Now.AddDays(30),
                Icon            = "testing"
            });

            context.SaveChanges();
        }