Inheritance: MonoBehaviour
コード例 #1
0
        public void Index_Contains_All_Groups()
        {
            // Arrange (Организация)
            Mock <IGroupRepository> mock = new Mock <IGroupRepository>();

            mock.Setup(_ => _.Groups).Returns(new List <GroupStudent>
            {
                new GroupStudent {
                    Id = 1, Name = "Group1", Course = 1, QualificationId = 1, SpecialityId = 1
                },
                new GroupStudent {
                    Id = 2, Name = "Group2", Course = 2, QualificationId = 2, SpecialityId = 2
                },
                new GroupStudent {
                    Id = 3, Name = "Group3", Course = 3, QualificationId = 3, SpecialityId = 3
                },
                new GroupStudent {
                    Id = 4, Name = "Group4", Course = 4, QualificationId = 4, SpecialityId = 4
                },
                new GroupStudent {
                    Id = 5, Name = "Group5", Course = 5, QualificationId = 5, SpecialityId = 5
                }
            });

            // Act (Действие)
            GroupController controller = new GroupController(mock.Object);

            List <GroupStudent> result = ((IEnumerable <GroupStudent>)controller.Index().ViewData.Model).ToList();

            // Assert (Утверждение)
            Assert.AreEqual(result.Count, 5);
            Assert.AreEqual(result[0].Id, 1);
            Assert.AreEqual(result[2].Id, 3);
        }
コード例 #2
0
        public void SetUp()
        {
            groups = new List <GroupDTO>()
            {
                new GroupDTO(1, "name1", 1, "mentorName1"),
                new GroupDTO(2, "name2", 2, "mentorName2"),
                new GroupDTO(3, "name3", 3, "mentorName3"),
                new GroupDTO(4, "name4", 4, "mentorName4")
            };

            groupServiceMock        = new Mock <IGroupService>();
            traceWriterMock         = new Mock <ITraceWriter>();
            userServiceMock         = new Mock <IUserService>();
            userIdentityServiceMock = new Mock <IUserIdentityService>();

            var userPrincipal = new ClaimsPrincipal(new ClaimsIdentity(new[]
            {
                new Claim(ClaimTypes.Role, "Admin")
            }));

            groupController = new GroupController(groupServiceMock.Object, userServiceMock.Object, userIdentityServiceMock.Object, traceWriterMock.Object);
            groupController.ControllerContext.RequestContext.Principal = userPrincipal;
            groupController.Request       = new HttpRequestMessage();
            groupController.Configuration = new HttpConfiguration();
            groupController.ControllerContext.ControllerDescriptor = new HttpControllerDescriptor(
                groupController.Configuration, "GroupController", groupController.GetType());
        }
コード例 #3
0
        public void CreateGroup(string gName, DateTime startDate, DateTime endDate)
        {
            Group           group = new Group(gName, startDate, endDate);
            GroupController gc    = new GroupController();

            gc.Create(group);
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: marioqx/TradfriDiscolight
        private void LoadAllDevices()
        {
            GatewayController gwc = new GatewayController(gatewayConnection.Client);

            comboBox2.Enabled = false;
            comboBox2.BeginUpdate();
            comboBox2.Items.Clear();

            // Read the devices
            foreach (long deviceID in gwc.GetDevices())
            {
                DeviceController dcl    = new DeviceController(deviceID, gatewayConnection.Client);
                TradFriDevice    device = dcl.GetTradFriDevice();
                comboBox2.Items.Add(device);
            }

            // Read the groups
            foreach (long groupID in gwc.GetGroups())
            {
                GroupController gcl          = new GroupController(groupID, gatewayConnection.Client);
                TradFriGroup    currentGroup = gcl.GetTradFriGroup();
                comboBox2.Items.Add(currentGroup);
            }

            comboBox2.SelectedIndex = -1;
            comboBox2.EndUpdate();
            comboBox2.Enabled = true;
        }
コード例 #5
0
        public void Client_Can_Get_Users_For_A_Group()
        {
            // arrange
            // arrange
            var mockedDataService = new Mock <IGroupService>();

            var userDtoResultId = Guid.NewGuid();

            mockedDataService.Setup(x => x.GetUsersFromGroup(It.IsAny <Guid>())).Returns(new List <UserDto>()
            {
                new UserDto()
                {
                    Id = userDtoResultId
                }
            });

            var groupController = new GroupController(
                mockedDataService.Object,
                _apiLogger.Object);

            // act
            var actionResult  = groupController.GetUsers(Guid.NewGuid());
            var contentResult = actionResult as OkNegotiatedContentResult <IEnumerable <UserDto> >;

            // assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(userDtoResultId, contentResult.Content.FirstOrDefault().Id);
        }
コード例 #6
0
        public void Client_Can_Get_Groups_By_Lat_Lon()
        {
            // arrange
            var mockedDataService = new Mock <IGroupService>();

            var groupDtoResultId = Guid.NewGuid();

            mockedDataService.Setup(x => x.GetGroups(It.IsAny <double>(), It.IsAny <double>())).Returns(new List <GroupMetadataResponseDto>()
            {
                new GroupMetadataResponseDto()
                {
                    Id = groupDtoResultId
                }
            });

            var groupController = new GroupController(
                mockedDataService.Object,
                _apiLogger.Object);

            // act
            var actionResult  = groupController.Get(23, 23);
            var contentResult = actionResult as OkNegotiatedContentResult <IEnumerable <GroupMetadataResponseDto> >;


            // assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(groupDtoResultId, contentResult.Content.FirstOrDefault().Id);
        }
コード例 #7
0
 /// <summary>
 /// Funzione di Setup
 /// </summary>
 /// <param name="_bossCtrl"></param>
 public void Setup(Boss2Controller _bossCtrl)
 {
     bossCtrl      = _bossCtrl;
     groupCtrl     = bossCtrl.GetLevelManager().GetGroupController();
     collisionCtrl = bossCtrl.GetBossCollisionController();
     aliveTouretts = new List <TourretController>();
 }
コード例 #8
0
        public void JoinTheGroup_Action_Excaption_Test()
        {
            Mock <IGroupService> moqGroupService = new Mock <IGroupService>();

            moqGroupService.Setup(x => x.GetGroup(It.IsAny <int>())).Returns(new Group());
            moqGroupService.Setup(x => x.UpateGroup(It.IsAny <Group>()));
            moqGroupService.Setup(x => x.SaveGroup()).Throws(new Exception());

            Mock <IUserService> moqUserService = new Mock <IUserService>();

            moqUserService.Setup(x => x.GetUser(It.IsAny <int>())).Returns(new User());


            _groupService = (IGroupService)moqGroupService.Object;
            _userService  = (IUserService)moqUserService.Object;

            controller = new GroupController(_groupService, _userService, _logger);
            builder    = new TestControllerBuilder();
            builder.InitializeController(controller);

            int groupId = 1;
            int userId  = 1;

            var result = controller.JoinTheGroup(groupId, userId) as JsonResult;

            Assert.AreEqual("false", result.Data.ToString());
        }
コード例 #9
0
        public static GroupController GetGroup(Client player, string IDOrName)
        {
            int id;
            int count = 0;

            if (int.TryParse(IDOrName, out id))
            {
                return(GetGroup(id));
            }

            GroupController rGroup = null;

            foreach (var group in Groups)
            {
                if (group.Group.Name.ToLower().StartsWith(IDOrName.ToLower()))
                {
                    if ((group.Group.Name.Equals(IDOrName, StringComparison.OrdinalIgnoreCase)))
                    {
                        return(group);
                    }
                    rGroup = group;
                    count++;
                }
            }
            if (count == 1)
            {
                return(rGroup);
            }
            else if (count > 1)
            {
                API.shared.sendChatMessageToPlayer(player, "~r~ERROR: ~w~Multiple groups found.");
            }
            return(null);
        }
コード例 #10
0
        public void CreateWorkSpace()
        {
            //Setup a fake HttpRequest
            Mock <HttpContextBase>    moqContext    = new Mock <HttpContextBase>();
            Mock <HttpRequestBase>    moqRequest    = new Mock <HttpRequestBase>();
            Mock <HttpPostedFileBase> moqPostedFile = new Mock <HttpPostedFileBase>();

            moqRequest.Setup(r => r.Files.Count).Returns(0);
            moqContext.Setup(x => x.Request).Returns(moqRequest.Object);

            //arrange
            var controller = new GroupController();
            var workspace  = new WorkSpace()
            {
                WorkSpaceName = "WorkSpace TestCorrect",
                Bilimail      = "*****@*****.**",
                Description   = "Demo test is correct",
                ImageWS       = "name.jpg"
            };

            controller.ControllerContext = new ControllerContext(moqContext.Object, new RouteData(), controller);
            var validationResults = TestModelHelper.ValidateModel(controller, workspace);

            //act
            var redirectRoute = controller.CreateGroup(workspace) as RedirectToRouteResult;

            //assert
            Assert.IsNotNull(redirectRoute);
            Assert.AreEqual("Index", redirectRoute.RouteValues["action"]);
            //Assert.AreEqual("Home", redirectRoute.RouteValues["controller"]);
            Assert.AreEqual(0, validationResults.Count);
        }
コード例 #11
0
        public void TestAddGroupOwner()
        {
            var GroupID = 1;
            TestControllerBuilder builder    = new TestControllerBuilder();
            GroupController       controller = new GroupController();

            builder.InitializeController(controller);
            var controllerContext = new Mock <ControllerContext>();
            var session           = new Mock <HttpSessionStateBase>();
            var mockHttpContext   = new Mock <HttpContextBase>();

            //get session
            mockHttpContext.Setup(ctx => ctx.Session).Returns(session.Object);
            controllerContext.Setup(ctx => ctx.HttpContext).Returns(mockHttpContext.Object);
            controllerContext.Setup(p => p.HttpContext.Session["GroupID"]).Returns(GroupID);
            controller.ControllerContext = controllerContext.Object;
            var group = new Group();
            var db    = new cap21t4Entities();

            using (var scope = new TransactionScope())
            {
                var result1 = controller.AddGroupOwner(db.Groups.First().ID.ToString("1")) as RedirectResult;
                Assert.IsNull(result1);
            }
        }
コード例 #12
0
 public void Setup()
 {
     _mediator        = IoC.GetMediator();
     _groupController = new GroupController(_mediator);
     _groupController.ControllerContext = IoC.SetControllerContext();
     _groupController.Request.Scheme    = "http";
 }
コード例 #13
0
        public async Task TestInsertExcelSucess()
        {
            TestControllerBuilder builder    = new TestControllerBuilder();
            GroupController       controller = new GroupController();

            builder.InitializeController(controller);
            var db      = new cap21t4Entities();
            var context = new Mock <HttpContextBase>();
            var request = new Mock <HttpRequestBase>();
            var files   = new Mock <HttpFileCollectionBase>();
            var file    = new Mock <HttpPostedFileBase>();
            var server  = new Mock <HttpServerUtilityBase>();
            var session = new Mock <HttpSessionStateBase>();

            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);
            context.Setup(c => c.Request).Returns(request.Object);
            request.Setup(r => r.Files).Returns(files.Object);
            files.Setup(f => f["file"]).Returns(file.Object);
            context.Setup(c => c.Server).Returns(server.Object);
            file.Setup(f => f.ContentLength).Returns(1);
            file.Setup(f => f.ContentType).Returns("Excel");
            server.Setup(s => s.MapPath("~/Uploads/")).Returns("./Uploads/");
            context.Setup(ctx => ctx.Session).Returns(session.Object);
            await controller.InsertExcelData();
        }
コード例 #14
0
        public void TestReadExcelUnSeccess()
        {
            var controller = new GroupController();
            var context    = new Mock <HttpContextBase>();
            var request    = new Mock <HttpRequestBase>();
            var files      = new Mock <HttpFileCollectionBase>();
            var file       = new Mock <HttpPostedFileBase>();
            var server     = new Mock <HttpServerUtilityBase>();

            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);
            context.Setup(c => c.Request).Returns(request.Object);
            request.Setup(r => r.Files).Returns(files.Object);
            files.Setup(f => f["file"]).Returns(file.Object);
            context.Setup(c => c.Server).Returns(server.Object);
            file.Setup(f => f.ContentLength).Returns(1);
            file.Setup(f => f.ContentType).Returns("Excel");
            server.Setup(s => s.MapPath("~/Uploads/")).Returns("./Uploads/");

            var case3 = "Word.docx";

            file.Setup(f => f.FileName).Returns(case3);
            var reader = new StreamReader(case3);

            file.Setup(f => f.InputStream).Returns(reader.BaseStream);
            var result = controller.ReadExcel() as ViewResult;

            System.Diagnostics.Trace.WriteLine("This file format is not supported");
        }
コード例 #15
0
        public void Post_adds_profile_to_group_then_returns_succes_msg()
        {
            #region Arrange
            using (Mock.Record())
            {
                Expect.Call(GroupService.AddProfileToGroup(1, 1)).Return(true);
            }
            #endregion

            #region Act

            JsonResult result;
            using (Mock.Playback())
            {
                result = (JsonResult)GroupController.Join(1, 1);
            }

            #endregion

            #region Assert
            Assert.That(result.Data, Is.Not.Null);
            Assert.That(((ResponseMessage)result.Data).IsSuccess, Is.True);

            #endregion
        }
コード例 #16
0
ファイル: GroupMap.cs プロジェクト: secc/RockDataImport
        public Dictionary<string, object> GetGroupById( int groupId )
        {
            GroupController controller = new GroupController( Service );
            var group = controller.GetById( groupId );

            return ToDictionary( group );
        }
コード例 #17
0
 public static void Init()
 {
     GroupController.LoadGroups();
     VehicleController.LoadVehicles();
     PropertyController.LoadProperties();
     JobController.LoadJobs();
 }
コード例 #18
0
        public void Get_gets_group_and_returns_details_view_with_model()
        {
            #region Arrange

            using (Mock.Record())
            {
                Expect.Call(GroupService.GetGroup(1)).Return(SampleGroup);
            }
            #endregion

            #region Act

            ViewResult view;
            using (Mock.Playback())
            {
                view = (ViewResult)GroupController.Details(1);
            }

            #endregion

            #region Assert
            Assert.IsEmpty(view.ViewName);
            Assert.That(view.ViewData.Model, Is.InstanceOf <GroupModelDto>());
            #endregion
        }
コード例 #19
0
ファイル: QuickSceneSetupper.cs プロジェクト: supernikx/YLEM
    protected override void Start()
    {
        if (FindObjectsOfType <GameManager>().Length == 1)
        {
            //Controllo e istanzio se mancano cose
            inst = FindObjectOfType <QuickSceneInstantiator>();
            inst.Setup();

            //Flow normale di setup
            SetUIManager(FindObjectOfType <UI_Manager>());
            SetLevelManager(FindObjectOfType <LevelManager>());
            reset     = FindObjectOfType <QuickSceneReset>();
            poolMng   = FindObjectOfType <PoolManager>();
            groupCtrl = FindObjectOfType <GroupController>();

            reset.Setup(this, groupCtrl, uiMng);
            poolMng.Setup();
            groupCtrl.Setup();
            lvlMng.Setup();
            uiMng.Setup(this);

            uiMng.GetCurrentUIController().SetCurrentMenu <UIMenu_Gameplay>();
        }
        else
        {
            Destroy(gameObject);
        }
    }
コード例 #20
0
 public void Initialise()
 {
     _source     = new SourceCache <Person, string>(p => p.Name);
     _controller = new GroupController();
     _grouped    = _source.Connect(p => _grouper(p) != AgeBracket.Pensioner)
                   .Group(_grouper, _controller).AsObservableCache();
 }
コード例 #21
0
        public AddEventPage(UserController ucon, GroupController gcon, Group g, EventPage e)
        {
            //gc = new GroupController();
            uc = ucon;
            gc = gcon;
            ev = e;
            InitializeComponent();


            search_bar.ApiKey            = "AIzaSyCyQVh1VQEBkpYuonBeikY9QK1y35Djy2s";
            search_bar.Type              = PlaceType.Establishment;
            search_bar.Components        = new Components("country:ph");
            search_bar.PlacesRetrieved  += Search_Bar_PlacesRetrieved;
            search_bar.TextChanged      += Search_Bar_TextChanged;
            search_bar.MinimumSearchText = 5;
            results_list.ItemSelected   += Results_List_ItemSelected;

            if (g == null)
            {
                group = new Group();
            }
            else
            {
                group               = g;
                Subject.Text        = group.Name;
                StartDate.Date      = group.MeetupDateTime;
                StartTime.Time      = group.MeetupDateTime.TimeOfDay;
                EndDate.Date        = group.MeetupDateTimeEnd;
                EndTime.Time        = group.MeetupDateTimeEnd.TimeOfDay;
                LocationName.Text   = "Location: " + group.MeetupLocation;
                EventAddUpdate.Text = "Update";
                GetPlaceIDEditEvent();
            }
        }
コード例 #22
0
        public void Can_Paginate()
        {
            Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>();
            Mock <IGenericRepository <Group> > mockR = new Mock <IGenericRepository <Group> >();

            mockR.Setup(r => r.GetAll()).Returns(() => new Group[]
            {
                new Group {
                    ID = 1, Name = "N1"
                },
                new Group {
                    ID = 2, Name = "N2"
                },
                new Group {
                    ID = 3, Name = "N3"
                },
                new Group {
                    ID = 4, Name = "N4"
                },
                new Group {
                    ID = 5, Name = "N5"
                }
            }.AsQueryable());
            mock.Setup(u => u.Groups).Returns(mockR.Object);
            GroupController controller = new GroupController(mock.Object);

            controller.PageSize = 3;
            GroupsListViewModel result = (GroupsListViewModel)controller.List(2).Model;

            Group[] groupArray = result.Groups.ToArray();
            Assert.IsTrue(groupArray.Length == 2);
            Assert.AreEqual(groupArray[0].Name, "N4");
            Assert.AreEqual(groupArray[1].Name, "N5");
        }
コード例 #23
0
    public async Task GetGroupById_ShouldReturnGroup_WhenGroupExists()
    {
        // Arrange
        const int groupId = 1;

        GroupResource expectedGroup = new GroupResource
        {
            GroupId = groupId
        };

        Mock <IMediator> mediatorMock = new Mock <IMediator>();

        mediatorMock
        .Setup(m => m.Send(It.IsAny <GetGroupByIdQuery>(), It.IsAny <CancellationToken>()))
        .ReturnsAsync(expectedGroup);

        GroupController controller = new GroupController(mediatorMock.Object, null);

        // Act
        ActionResult <GroupResource> response = await controller.GetGroupById(groupId);

        // Assert
        OkObjectResult result = Assert.IsType <OkObjectResult>(response.Result);

        GroupResource actualGroup = Assert.IsType <GroupResource>(result.Value);

        Assert.NotNull(actualGroup);
        Assert.Equal(groupId, actualGroup.GroupId);
    }
        public void AddGlobalSuppression_UpdateData_ReturnJson()
        {
            // Arrange
            InitilizeAddGlobalSuppressionTests();
            var controller = new GroupController();

            ShimEmailGroup.ImportEmailsToGlobalMSUserInt32String = (p1, p2, p3) => new DataTable
            {
                Columns = { "Action", "Counts" },
                Rows    = { { TotalRecordKeyT,   "1" }, { TotalRecordKeyT,     "2" }, { NewRecordKeyI,     "4" },
                            { ChangedRecordKeyU, "5" }, { DublicateRecordKeyD, "6" }, { SkippedRecordKeyS, "7" } }
            };

            // Act
            var result = controller.AddGlobalSuppression(SampleEmail) as JsonResult;

            // Assert
            result.ShouldNotBeNull();
            result.Data.ShouldNotBeNull();
            dynamic jsonResult = result.Data;

            Assert.AreEqual(jsonResult.Count, 3);
            Assert.AreEqual(jsonResult[0], HttpStatusOk);
            Assert.IsTrue(jsonResult[1].Contains(TotalRecordsMessage + "3"));
            Assert.IsTrue(jsonResult[1].Contains(NewRecordsMessage + "4"));
            Assert.IsTrue(jsonResult[1].Contains(ChangedMessage + "5"));
            Assert.IsTrue(jsonResult[1].Contains(DublicateMessage + "6"));
            Assert.IsTrue(jsonResult[1].Contains(SkippedMessage + "7"));
        }
コード例 #25
0
    public async Task UpdateGroup_ShouldReturnNotFoundResult_WhenGroupDoesNotExist()
    {
        // Arrange
        const int groupId = 15453;

        UpdateGroupBody model = new UpdateGroupBody
        {
            Name        = "Some updated name",
            Description = "Some updated description"
        };

        Mock <IMediator> mediatorMock = new Mock <IMediator>();

        mediatorMock
        .Setup(m => m.Send(It.IsAny <GroupExistsQuery>(), It.IsAny <CancellationToken>()))
        .ReturnsAsync(false);

        GroupController controller = new GroupController(mediatorMock.Object, null);

        // Act
        ActionResult response = await controller.UpdateGroup(groupId, model);

        // Assert
        NotFoundObjectResult result = Assert.IsType <NotFoundObjectResult>(response);

        ErrorResource error = Assert.IsType <ErrorResource>(result.Value);

        Assert.Equal(StatusCodes.Status404NotFound, error.StatusCode);
    }
コード例 #26
0
        public void Client_Can_Get_Group_By_Id()
        {
            // arrange
            var mockedDataService = new Mock <IGroupService>();

            var groupDtoResultId = Guid.NewGuid();

            mockedDataService.Setup(x => x.GetGroupById(It.IsAny <Guid>())).Returns(new GroupDto()
            {
                Id = groupDtoResultId
            });

            var groupController = new GroupController(
                mockedDataService.Object,
                _apiLogger.Object);

            // act
            var actionResult  = groupController.Get(Guid.NewGuid());
            var contentResult = actionResult as OkNegotiatedContentResult <GroupDto>;

            // asssert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(groupDtoResultId, contentResult.Content.Id);
        }
コード例 #27
0
    public async Task UpdateGroup_ShouldReturnUpdateGroup_WhenGroupExists()
    {
        // Arrange
        const int groupId = 1;

        UpdateGroupBody model = new UpdateGroupBody
        {
            Name        = "Some updated name",
            Description = "Some updated description"
        };

        Mock <IMediator> mediatorMock = new Mock <IMediator>();

        mediatorMock
        .Setup(m => m.Send(It.IsAny <GroupExistsQuery>(), It.IsAny <CancellationToken>()))
        .ReturnsAsync(true);

        GroupController controller = new GroupController(mediatorMock.Object, null);

        // Act
        ActionResult response = await controller.UpdateGroup(groupId, model);

        // Assert
        Assert.IsType <NoContentResult>(response);

        mediatorMock.Verify(m => m.Send(It.IsAny <UpdateGroupCommand>(), It.IsAny <CancellationToken>()));
    }
コード例 #28
0
        public TradesByTimeViewer(ITradeService tradeService, ISchedulerProvider schedulerProvider)
        {
            _schedulerProvider = schedulerProvider;

            var groupController = new GroupController();

            var grouperRefresher = Observable.Interval(TimeSpan.FromSeconds(1))
                                   .Subscribe(_ => groupController.RefreshGroup());

            var loader = tradeService.Trades.Connect()
                         .Group(trade =>
            {
                var diff = DateTime.Now.Subtract(trade.Timestamp);
                if (diff.TotalSeconds <= 60)
                {
                    return(TimePeriod.LastMinute);
                }
                if (diff.TotalMinutes <= 60)
                {
                    return(TimePeriod.LastHour);
                }
                return(TimePeriod.Older);
            }, groupController)
                         .Transform(group => new TradesByTime(group, _schedulerProvider))
                         .Sort(SortExpressionComparer <TradesByTime> .Ascending(t => t.Period))
                         .ObserveOn(_schedulerProvider.Dispatcher)
                         .Bind(_data)
                         .DisposeMany()
                         .Subscribe();

            _cleanUp = new CompositeDisposable(loader, grouperRefresher);
        }
コード例 #29
0
    /// <summary>
    /// Funzione di Setup della scena di Swarm
    /// </summary>
    private void SwarmSceneSetup()
    {
        PoolManager.instance.Setup();
        GroupController groupCtrl = FindObjectOfType <GroupController>();

        groupCtrl.Setup();
    }
コード例 #30
0
 public void SetupTest()
 {
     DbConnection connection = Effort.DbConnectionFactory.CreateTransient();
     _context = new MobileServiceContext(connection);
     _controller = new GroupController();
     _controller.SetDomainManager(new EntityDomainManager<Group>(_context, _controller.Request));
 }
コード例 #31
0
        public async Task TestQuit()
        {
            var groupAppService = Substitute.For <IGroupAppService>();

            var target = new GroupController(
                CreateMemoryCache(),
                CreateMapper(),
                Substitute.For <IDepartmentAppService>(),
                Substitute.For <IPositionAppService>(),
                groupAppService);

            target.ControllerContext = CreateMockContext();

            groupAppService.QuitAsync(Arg.Any <GroupInput>())
            .ReturnsForAnyArgs(RemotingResult.Success());
            var result = await target.Quit(Guid.NewGuid());

            result.Value.Should().NotBeNull();
            result.Value.Status.Should().Be(0);

            groupAppService.QuitAsync(Arg.Any <GroupInput>())
            .ReturnsForAnyArgs(RemotingResult.Fail());
            result = await target.Quit(Guid.NewGuid());

            result.Value.Status.Should().NotBe(0);
        }
コード例 #32
0
ファイル: GroupMap.cs プロジェクト: secc/RockDataImport
        public Dictionary<string, object> GetFamilyGroupByForeignId( string foreignId )
        {
            int familyGroupTypeId = GetGroupTypeByGuid( new Guid( SystemGuid.GroupType.GROUPTYPE_FAMILY ) ).Id;
            GroupController controller = new GroupController( Service );
            Group family = controller.GetByForeignIdGroupType( foreignId, familyGroupTypeId );

            return ToDictionary( family );
        }
コード例 #33
0
ファイル: GroupMap.cs プロジェクト: secc/RockDataImport
        public int? SaveGroup( int groupTypeId, string name, int? parentGroupId = null, bool isSystem = false, int? campusId = null, 
                        string description = null, bool isSecurityRole = false, bool isActive = true, int order = 0, string foreignId = null, 
                        int? groupId = null )
        {
            Group group = null;
            GroupController controller = new GroupController( Service );

            if ( groupId != null )
            {
                group = controller.GetById( (int)groupId );
                if ( groupId == null )
                {
                    return null;
                }
            }
            else
            {
                group = new Group();
            }

            group.IsSystem = isSystem;
            group.ParentGroupId = parentGroupId;
            group.GroupTypeId = groupTypeId;
            group.CampusId = campusId;
            group.Name = name;
            group.Description = description;
            group.IsSecurityRole = isSecurityRole;
            group.IsActive = isActive;
            group.Order = order;
            group.ForeignId = foreignId;

            if ( groupId == null )
            {
                group.CreatedByPersonAliasId = Service.LoggedInPerson.PrimaryAliasId;
                controller.Add( group );
            }
            else
            {
                group.ModifiedByPersonAliasId = Service.LoggedInPerson.PrimaryAliasId;
                controller.Update( group );
            }

            group = controller.GetByGuid( group.Guid );

            return group.Id;
        }
コード例 #34
0
ファイル: frmGroups.cs プロジェクト: hkiaipc/C3
        private TabPage Create(GroupController gc)
        {
            TabPage page = new TabPage();
            page.Text = gc.Group.Text;
            page.Controls.Add(gc.Viewer.UC);

            return page;
        }