public async Task RemoveFromPersonnel_ValidUserWithNoQualification_QualificationIdIsNull()
        {
            const string QUALIFICATION_NAME = "TestQualification";
            string       userId             = Guid.NewGuid().ToString();
            string       roleIdDoctor       = Guid.NewGuid().ToString();
            string       roleIdPersonnel    = Guid.NewGuid().ToString();
            string       qualificationId    = Guid.NewGuid().ToString();

            var service = new AdminQualificationService(dbContext, userManager, roleManager, signInManager);

            await dbContext.Qualification.AddAsync(new Qualification(QUALIFICATION_NAME)
            {
                IsDeleted      = false,
                NameNormalized = QUALIFICATION_NAME.ToUpperInvariant(),
                Users          = new List <User>(),
                Id             = qualificationId
            });

            await dbContext.Roles.AddAsync(new IdentityRole(Roles.DOCTOR) { Id = roleIdDoctor });

            await dbContext.Roles.AddAsync(new IdentityRole(Roles.PERSONNEL) { Id = roleIdPersonnel });

            await dbContext.SaveChangesAsync();

            await dbContext.Users.AddAsync(new User("TestName", "TestUserName", "*****@*****.**", DateTime.Now)
            {
                Id = userId,
            });

            await dbContext.SaveChangesAsync();

            await service.RemoveFromQualificationAsync(userId);

            Assert.IsNull(dbContext.Users.Find(userId).FacilityId);
        }
Exemplo n.º 2
0
        public void All_WithNone_ReturnEmptyCollection()
        {
            var service = new AdminQualificationService(dbContext, userManager, roleManager, signInManager);

            IEnumerable <QualificationConciseViewModel> results = service.All();

            Assert.IsNotNull(results);
            Assert.AreEqual(0, results.ToList().Count);
        }
Exemplo n.º 3
0
        public async Task Add_NewEntity_Created()
        {
            var service = new AdminQualificationService(dbContext, userManager, roleManager, signInManager);

            await service.AddAsync(new QualificationCreateBindingModel()
            {
                Name = NAME_QUALIICATION
            });

            Assert.AreEqual(1, dbContext.Qualification.Count());
        }
Exemplo n.º 4
0
        public async Task GetPersonnel_HaveNone_ReturnZero()
        {
            string qualificationId = Guid.NewGuid().ToString();

            var service = new AdminQualificationService(dbContext, userManager, roleManager, signInManager);

            await dbContext.Qualification.AddAsync(new Qualification("TestQualification") { Id = qualificationId });

            await dbContext.SaveChangesAsync();

            Assert.AreEqual(0, (await service.GetAllPersonnelAsync(qualificationId)).Count());
        }
Exemplo n.º 5
0
        public async Task Delete_WithPersonnel_NetDeleted()
        {
            var service = new AdminQualificationService(dbContext, userManager, roleManager, signInManager);

            string itemId = Guid.NewGuid().ToString();

            await dbContext.Qualification.AddAsync(new Qualification(Roles.PERSONNEL) { Id = itemId });

            await dbContext.SaveChangesAsync();

            await service.DeleteAsync(itemId);

            Assert.IsFalse(dbContext.Qualification.Find(itemId).IsDeleted);
        }
Exemplo n.º 6
0
        public async Task Delete_WithOne_NotExisting()
        {
            var service = new AdminQualificationService(dbContext, userManager, roleManager, signInManager);

            string itemId = Guid.NewGuid().ToString();

            await dbContext.Qualification.AddAsync(new Qualification("TestQualification") { Id = itemId });

            await dbContext.SaveChangesAsync();

            await service.DeleteAsync(itemId);

            Assert.IsTrue(dbContext.Qualification.Find(itemId).IsDeleted);
        }
Exemplo n.º 7
0
        public async Task GetQualificationList_HaveSeveral_ReturnAll()
        {
            var service = new AdminQualificationService(dbContext, userManager, roleManager, signInManager);

            await dbContext.Qualification.AddRangeAsync(
                new Qualification("TestQualification1"),
                new Qualification("TestQualification2"),
                new Qualification("TestQualification3"),
                new Qualification("TestQualification4"));

            await dbContext.SaveChangesAsync();

            Assert.AreEqual(4, (await service.GetQualificationsListAsync()).ToList().Count);
        }
Exemplo n.º 8
0
        public async Task Add_DeleteEntity_Restored()
        {
            var service = new AdminQualificationService(dbContext, userManager, roleManager, signInManager);

            await dbContext.Qualification.AddAsync(new Qualification(NAME_QUALIICATION) { IsDeleted = true });

            await dbContext.SaveChangesAsync();

            await service.AddAsync(new QualificationCreateBindingModel()
            {
                Name = NAME_QUALIICATION
            });

            Assert.AreEqual(1, dbContext.Qualification.Count());
            Assert.IsFalse(dbContext.Qualification.First().IsDeleted);
        }
Exemplo n.º 9
0
        public async Task All_WithSome_ReturnAll()
        {
            const string NAME_QUALIICATION = "TestQualification";
            await dbContext.Qualification.AddRangeAsync(
                new Qualification(NAME_QUALIICATION),
                new Qualification(NAME_QUALIICATION),
                new Qualification(NAME_QUALIICATION));

            await dbContext.SaveChangesAsync();

            var service = new AdminQualificationService(dbContext, userManager, roleManager, signInManager);

            IEnumerable <QualificationConciseViewModel> results = service.All();

            Assert.IsNotNull(results);
            Assert.AreEqual(3, results.ToList().Count);
        }
Exemplo n.º 10
0
        public async Task GetPersonnel_HaveSeveral_ReturnAll()
        {
            string qualificationId = Guid.NewGuid().ToString();

            var service = new AdminQualificationService(dbContext, userManager, roleManager, signInManager);

            await dbContext.Qualification.AddAsync(new Qualification("TestQualification") { Id = qualificationId });

            await dbContext.SaveChangesAsync();

            await dbContext.Users.AddRangeAsync(
                new User("TestName1", "TestUserName1", "*****@*****.**", DateTime.Now)
            {
                QualificationId = qualificationId,
                Id = Guid.NewGuid().ToString()
            },
                new User("TestName2", "TestUserName2", "*****@*****.**", DateTime.Now)
            {
                QualificationId = qualificationId,
                Id = Guid.NewGuid().ToString()
            },
                new User("TestName3", "TestUserName3", "*****@*****.**", DateTime.Now)
            {
                QualificationId = qualificationId,
                Id = Guid.NewGuid().ToString()
            },
                new User("TestName4", "TestUserName4", "*****@*****.**", DateTime.Now)
            {
                QualificationId = qualificationId,
                Id = Guid.NewGuid().ToString()
            }
                );

            await dbContext.SaveChangesAsync();

            Assert.AreEqual(4, (await service.GetAllPersonnelAsync(qualificationId)).Count());
        }
Exemplo n.º 11
0
        public async Task GetQualificationList_HaveNone_ReturnZero()
        {
            var service = new AdminQualificationService(dbContext, userManager, roleManager, signInManager);

            Assert.AreEqual(0, (await service.GetQualificationsListAsync()).ToList().Count);
        }