예제 #1
0
        public async Task GetNestedSimpleResources_GivenNoDataIsFound_ExpectMaybeWithNothing()
        {
            var connection = new Mock <IDbConnection>();

            connection.SetupDapperAsync(c => c.QueryAsync <SimpleResourceDto>(
                                            It.IsAny <string>(),
                                            It.IsAny <DynamicParameters>(),
                                            null, null, It.IsAny <CommandType>()))
            .ReturnsAsync(() => new List <SimpleResourceDto>());

            var dbConnectionProvider = new Mock <IConnectionProvider>();

            dbConnectionProvider.Setup(x => x.GetConnection())
            .Returns(() => connection.Object);

            var roleQueries = new RoleQueries(dbConnectionProvider.Object);
            var result      = await roleQueries.GetNestedSimpleResources();

            Assert.True(result.HasNoValue);
        }
예제 #2
0
        public async Task CheckForPresenceOfRoleByName_GivenRoleDoesNotExist_ExpectNotPresentStatus()
        {
            var connection = new Mock <IDbConnection>();

            connection.SetupDapperAsync(c => c.QueryAsync <PresenceCheckDto <string> >(
                                            It.IsAny <string>(),
                                            It.IsAny <DynamicParameters>(),
                                            null, null, It.IsAny <CommandType>()))
            .ReturnsAsync(() => new List <PresenceCheckDto <string> >());

            var dbConnectionProvider = new Mock <IConnectionProvider>();

            dbConnectionProvider.Setup(x => x.GetConnection())
            .Returns(() => connection.Object);

            var roleQueries = new RoleQueries(dbConnectionProvider.Object);
            var result      = await roleQueries.CheckForPresenceOfRoleByName("name");

            Assert.False(result.IsPresent);
        }
예제 #3
0
        public async Task CheckForRoleUsageById_GivenRoleIsInUse_ExpectPresentStatus()
        {
            var connection = new Mock <IDbConnection>();

            connection.SetupDapperAsync(c => c.QueryAsync <PresenceCheckDto <Guid> >(
                                            It.IsAny <string>(),
                                            It.IsAny <DynamicParameters>(),
                                            null, null, It.IsAny <CommandType>()))
            .ReturnsAsync(() => new List <PresenceCheckDto <Guid> >
            {
                new PresenceCheckDto <Guid>(),
            });

            var dbConnectionProvider = new Mock <IConnectionProvider>();

            dbConnectionProvider.Setup(x => x.GetConnection())
            .Returns(() => connection.Object);

            var roleQueries = new RoleQueries(dbConnectionProvider.Object);
            var result      = await roleQueries.CheckForRoleUsageById(Guid.NewGuid());

            Assert.True(result.IsPresent);
        }
예제 #4
0
        public async Task GetDetailsOfRoleById_GivenMoreThenOneRecordIsFound_ExpectMaybeWithNothing()
        {
            var connection = new Mock <IDbConnection>();

            connection.SetupDapperAsync(c => c.QueryAsync <DetailedRoleDto>(
                                            It.IsAny <string>(),
                                            It.IsAny <DynamicParameters>(),
                                            null, null, It.IsAny <CommandType>()))
            .ReturnsAsync(() => new List <DetailedRoleDto>
            {
                new DetailedRoleDto(),
                new DetailedRoleDto(),
            });

            var dbConnectionProvider = new Mock <IConnectionProvider>();

            dbConnectionProvider.Setup(x => x.GetConnection())
            .Returns(() => connection.Object);

            var roleQueries = new RoleQueries(dbConnectionProvider.Object);
            var result      = await roleQueries.GetDetailsOfRoleById(Guid.NewGuid());

            Assert.True(result.HasNoValue);
        }
예제 #5
0
 public PermisoVM()
 {
     Roles       = new ObservableCollection <Role>(RoleQueries.GetRoles());
     Permissions = new ObservableCollection <SubMenuPermission>();
     SelectedRol = new Role();
 }