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); }
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); }
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); }
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); }
public PermisoVM() { Roles = new ObservableCollection <Role>(RoleQueries.GetRoles()); Permissions = new ObservableCollection <SubMenuPermission>(); SelectedRol = new Role(); }